DrawArc method: Drawing arcs
Feature description This method is used to draw arcs on the canvas, by specifying the ellipse object that the arc is in, the starting angle, and the terminating angle. This method is the main method for drawing arcs.
"Basic syntax" public void DrawArc (RECTF oval, float startangle, float sweepAngle, Boolean usecenter, Paint paint)
Parameter description
Oval: The Ellipse object where the arc is located.
StartAngle: The starting angle of the arc.
SweepAngle: The angle of the arc.
Usecenter: If the RADIUS line is displayed, true indicates that the radius of the arc is displayed with the center of the circle, and False indicates no display.
Paint: The brush that is used when drawing.
The example below demonstrates how to draw arcs on the canvas by using code.
protected void OnDraw (canvas canvas) {
//TODO auto-generated method Stub
Super.ondraw (canvas);
Paint.setantialias (TRUE);//Set Brush to non-aliased
Paint.setcolor (color.black);//Set Brush color
Canvas.drawcolor ( Color.White); White background
Paint.setstrokewidth ((float) 3.0);//Line width
Paint.setstyle (style.stroke);
RECTF oval=new RECTF ();//RECTF object
oval.left=100;//left
oval.top=100;//Top
oval.right=400;//Right
ov al.bottom=300; Below
Canvas.drawarc (oval, 225, N, false, paint);//Draw arc
//RECTF oval=new RECTF ();//RECTF Object
oval.left=10 0; Left
oval.top=400;//Top
oval.right=400;//Right
oval.bottom=700;//Bottom
Canvas.drawarc (Oval, $, 135, True, p aint); Draw Arc
}
In this code, the color of the paint brush is set first, and the canvas canvas is set to a white background. It then sets the line width and the hollow effect of the brush. The
then defines a RECTF object and sets its coordinates, calling the DrawArc method to draw the first arc, where the radius line is not displayed.
Finally, the RECTF object coordinates are reset, and the DrawArc method is called to draw the second arc, where the display radius lines are set.