Basic plot Functions

Source: Internet
Author: User

0 cgcontextref context = uigraphicsgetcurrentcontext (); set the context

1 cgcontextmovetopoint

2 cgcontextaddlinetopoint draw a straight line

4 cgcontextaddellipseinrect draws an elliptic

4 cgcontextsetlinecap

4 cgcontextsetlinedash draw the dotted line

4 cgcontextaddrect draw a box

4 cgcontextstrokerect: Specify the rectangle

4 cgcontextstrokerectwithwidth specifies the width of the rectangle line

4 cgcontextstrokelinesegments some straight lines

5 cgcontextaddarc draws a curve. The first two stores are in the center. The center two stores start with radians. The last data is 0, and 1 is clockwise.

5 cgcontextaddarctopoint (context, 2, 9, 40); // draw two lines from point to point 1, and cut the circle from Point 1 to point 2.

6 cgcontextsetshadowwithcolor

7 cgcontextsetrgbfillcolor: fill color

7 cgcontextsetrgbstrokecolor paint color settings

7 cgcontextsetfillcolorspace color space filling

7 cgconextsetstrokecolorspace Color Space paint settings

8 cgcontextfillrect supplement rect of current fill color

8 cgcontextsetalaha transparency

9 cgcontexttranslatectm change the canvas position

10 cgcontextsetlinewidth: Set the line width

11 cgcontextaddrects draw multiple lines

12 cgcontextaddquadcurvetopoint draw Curve

13 cgcontextstrokepath

13 cgcontextdrawpath

14 cgcontextclosepath: closes the current line

15 cgcontexttranslatectm (context, 0, rect. Size. Height); cgcontextscalectm (context, 1.0,-1.0); invert the canvas

16 cgcontextsetinterpolationquality background built-in color quality level

16 cgimagecreatewithimageinrect small image from the source Image

17. You can use the nsstring Plotting Method-(cgsize) drawinrect :( cgrect) rect withfont :( uifont *) font linebreakmode :( break) linebreakmode alignment :( wait) alignment; To write the string.

18. The function of enlarging and downgrading images is slow.

Uigraphicsbeginimagecontext (newsize );

Uiimage * newimage = uigraphicsgetimagefromcurrentimagecontext ();

Uigraphicsendimagecontext ();

19 cgcolorgetcomponents () returns the directness and transparency of each color. Read-Only const float can be used to receive an array.

20 picture cgimageref image = cgimageretain (IMG. cgimage );

Cgcontextdrawimage (context, cgrectmake (10.0, height-

100.0, 90.0, 90.0), image );

21 implement the change-by-color Filling Method cgcontextclip (context );

Cgcolorspaceref RGB = cgcolorspacecreatedevicergb ();

Cgfloat colors [] =

{

204.0/255.0, 224.0/255.0, 244.0/255.0, 1.00,

29.0/255.0, 156.0/255.0, 215.0/255.0, 1.00,

0.0/255.0, 50.0/255.0, 126.0/255.0, 1.00,

};

Cggradientref gradient = cggradientcreatewithcolorcomponents

(RGB, colors, null, sizeof (colors)/(sizeof (colors [0]) * 4 ));

Cgcolorspacerelease (RGB );

Cgcontextdrawlineargradient (context, gradient, cgpointmake

(0.0, 0.0), cgpointmake (0.0, self. Frame. Size. Height ),

Kcggradientdrawsbeforestartlocation );

22 Note: It is required

Use cgcontextstrokepath to describe the line, that is, the shape.

Then, cgcontextfillpath is used to fill the color in the shape.

When filling a path, the sub-paths in the path are independently filled.

If it is an overlapping path, it determines whether a vertex is filled. There are two rules:

1, nonzero winding number rule: non-zero round number rule. If a point is crossed from left to right, counter + 1, from right to left, counter-1, and finally, if the result is 0, it is not filled. If it is non-zero, it is filled.

2. Even-odd rule: a parity rule. If a vertex is crossed, then + 1 is followed by an odd number, and the even number is not filled. It has nothing to do with the direction.

Function

Description

Cgcontexteofillpath

Fill the current path with the parity rule

Cgcontextfillpath

Use a non-zero round number rule to fill the current path

Cgcontextfillrect

Fill in the specified rectangle

Cgcontextfillrects

Fill in the specified rectangle

Cgcontextfillellipseinrect

Fill in the ellipse in the specified rectangle

Cgcontextdrawpath

The filling rules are determined by the two parameters. kcgpathfill indicates a non-zero round number rule, kcgpatheofill indicates a parity rule, kcgpathfillstroke indicates filling, and kcgpatheofillstroke indicates Line tracing, not filling

Set how to mix two colors when one color overwrites the other.

The default method is

Result = (alpha * foreground) + (1-alpha) * Background

Cgcontextsetblendmode: sets blend mode.

Cgcontextsavegstate: Save the blend mode.

Cgcontextrestoregstate: use this function to restore the blend mode before saving it.

Cgcontextsetblendmode mixed colors

Community post: http://www.cocoachina.com/bbs/read.php? Tid = 75122

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.