Common methods for canvas and paint

Source: Internet
Author: User

:

page code:
   @Overrideprotected void OnDraw (CanvasCanvas) {Super.ondraw (Canvas);        Mpaint = new Paint (); Mpaint.setcolor (Color.Black);//Set Brush colorMpaint.settextsize ( -);//Set Font size        Canvas. DrawText (Actionstr, -, -, Mpaint);//writeMpaint.setstrokewidth (Ten);//Set line widthMpaint.setstyle (Paint.Style.STROKE);//Set Hollow        Canvas. Drawcircle ( $, -, the, Mpaint);//Draw a circleMpaint.setantialias (TRUE);//anti-aliasing        Canvas. DrawLine ( -, Max, -, -, Mpaint);//Draw line        Canvas. DrawRect ( -, -, -, -, Mpaint);//Draw Rectangle        Canvas. Save ();//Save Canvas StateMpaint.setstyle (Paint.Style.FILL);//Set solid        Canvas. ClipRect (New Rect ( -,550, -, -));//Cut out a rectangular area        Canvas. Drawcolor (Color.ltgray);//Set canvas color        Canvas. Drawcircle ( Max, -, -, Mpaint);//within the cropping area, can display        Canvas. Restore ();//restore Canvas StateMpaint.setstyle (Paint.Style.STROKE);//Set HollowRECTF RECTF = new RECTF ( -, -, -, the);//Set a new rectangle        Canvas. Drawroundrect (RECTF, -, -, Mpaint);//Draw the arc rectangle, the second parameter is the x radius, the third parameter is the y radius        Canvas. Drawpoint ( -, $, Mpaint);//Draw a dot        Canvas. drawpoints (Newfloat[]{ -, -,420, -, the, -}, Mpaint);//Draw multiple pointsBitmap Bitmap = Bitmapfactory.decoderesource (Getresources (), r.drawable.smile);//instantiation of a bitmap        Canvas. Drawbitmap (Bitmap, -, Max, Mpaint);//Painting picturesPath PATH = new Path (); Path.moveto ( -, -);//will not be drawn, only for moving the move brush, equivalent to the starting point. Path.lineto ( -, -);//lineto is used for line drawing. Path.moveto ( -,310);//will not be drawn, only for moving the move brush, equivalent to the starting point. Path.quadto (650, -, -, -);The//quadto is used to draw a smooth curve, the Bezier curve. Mpath.quadto (x1, y1, x2, y2) (x1,y1) is the control point, (X2,y2) is the end point. Path.moveto ( -,610);//will not be drawn, only for moving the move brush, equivalent to the starting point. Path.cubicto ( -, the, -,550, -, the);The//cubicto is also used to achieve Bezier curves. Mpath.cubicto (x1, y1, x2, y2, X3, y3) (X1,Y1) is the control point, (X2,y2) is the control point, (X3,Y3) is the end point. Path.moveto ( -, +);//will not be drawn, only for moving the move brush, equivalent to the starting point. RECTF MRECTF = new RECTF ( -, the, -,1100); Path.arcto (MRECTF,0, the);//arcto is used to draw arcs (actually part of a circle or ellipse        Canvas. DrawPath (path, mpaint);//Draw a curveRECTF rectF1 = new RECTF ( -, the, $, +);Canvas. DrawArc (RectF1,the size of the rectangular area used by the//ARC                0,//Start angle                 the,//Sweep angleFalse//Whether to use the centerMpaint);//Draw text content according to established pointsMpaint.settextsize ( -); Mpaint.setstrokewidth (1);Canvas. Drawpostext ("Hello World", newfloat[]{ -, -,//first letter in coordinates 20,20                 -, -,//second letter in coordinate 30,30                 +, +, -, -, -, -, -, -, the, -, -, -, -, +, the, -, -, -}, Mpaint);Canvas. Drawtextonpath ("123456789", Path, -, - -, Mpaint);//Draw text content according to established path}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Common methods for canvas and paint

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.