Android Canvas DrawArc ()

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.