Android: looking for a drawArc() method with inner & outer radius

You can do this: Paint paint = new Paint(); final RectF rect = new RectF(); //Example values rect.set(mWidth/2- mRadius, mHeight/2 – mRadius, mWidth/2 + mRadius, mHeight/2 + mRadius); paint.setColor(Color.GREEN); paint.setStrokeWidth(20); paint.setAntiAlias(true); paint.setStrokeCap(Paint.Cap.ROUND); paint.setStyle(Paint.Style.STROKE); canvas.drawArc(rect, -90, 360, false, paint); The key is in paint.setStyle(Paint.Style.STROKE);, it crops the arc’s center with the stroke that you define in … Read more

How to draw a circle with animation in android with circle size based on a value

You have to draw the circle view, and after that you should create an animation to it. Creating the circle view: public class Circle extends View { private static final int START_ANGLE_POINT = 90; private final Paint paint; private final RectF rect; private float angle; public Circle(Context context, AttributeSet attrs) { super(context, attrs); final int … Read more

Android: how to draw a border to a LinearLayout

Do you really need to do that programmatically? Just considering the title: You could use a ShapeDrawable as android:background… For example, let’s define res/drawable/my_custom_background.xml as: <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle”> <corners android:radius=”2dp” android:topRightRadius=”0dp” android:bottomRightRadius=”0dp” android:bottomLeftRadius=”0dp” /> <stroke android:width=”1dp” android:color=”@android:color/white” /> </shape> and define android:background=”@drawable/my_custom_background”. I’ve not tested but it should work. Update: I think that’s better to … Read more

Pygame how to fix ‘trailing pixels’?

Normally you will do: def draw(): # fill screen with solid color. # draw, and flip/update screen. But, you can update just dirty portions of the screen. See pygame.display.update(): pygame.display.update() Update portions of the screen for software displays update(rectangle=None) -> None update(rectangle_list) -> None This function is like an optimized version of pygame.display.flip() for software … Read more

Write text on an image in C#

To draw multiple strings, call graphics.DrawString multiple times. You can specify the location of the drawn string. This example we will draw two strings “Hello”, “Word” (“Hello” in blue color upfront “Word” in red color): string firstText = “Hello”; string secondText = “World”; PointF firstLocation = new PointF(10f, 10f); PointF secondLocation = new PointF(10f, 50f); … Read more

draw polar graph in java

You might like to look at Lissajous curves; an example of a = 5, b = 4 (5:4) is shown below. Addendum: Once you see how to plot points in xy coordinates, then you should look at converting between polar and Cartesian coordinates. public class LissajousPanel extends JPanel { private static final int SIZE = … Read more

JFreechart draw arc on chart

The critical thing about Arc2D is the bounding rectangle. To make the half-arc H units high, the bounds must be 2 * H units high. AFAIK, PolarPlot does not support annotations. import java.awt.BasicStroke; import java.awt.Color; import java.awt.geom.Arc2D; import java.util.Random; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYLineAnnotation; import org.jfree.chart.annotations.XYShapeAnnotation; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYDataset; … Read more

Can I draw rectangle in XML?

Yes you can and here is one I made earlier: <?xml version=”1.0″ encoding=”UTF-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/listview_background_shape”> <stroke android:width=”2dp” android:color=”#ff207d94″ /> <padding android:left=”2dp” android:top=”2dp” android:right=”2dp” android:bottom=”2dp” /> <corners android:radius=”5dp” /> <solid android:color=”#ffffffff” /> </shape> You can create a new XML file inside the drawable folder, and add the above code, then save it as rectangle.xml. To … Read more

tech