Drawing and animation learning notes (1)

Source: Internet
Author: User

1. Graphic and animation processing frameworks

Uikit

A high-level framework allows developers to create views, windows, buttons, and other UI-related components. It also introduces some low-level APIs to easy-to-use high-level APIs.

Quartz 2D

The main engine for drawing on iOS; quartz is used for uikit.

Core graphics

It supports image context, image loading, image rendering, and so on.

Core Animation

As the name suggests, it is a framework that helps developers implement animation on IOS.


2. You can set the color of graphical context in the Set Method of uicolor.

 

- (void)drawRect:(CGRect)rect {UIColor *magentaColor = [UIColor colorWithRed:0.5f green:0.0f blue:0.5f alpha:1.0f];[magentaColor set];UIFont *helvetivaBold = [UIFont boldSystemFontOfSize:30];NSString *myString = @”I Learn Really Fast”;[myString drawInRect:CGRectMake(100,120,100,200) withFont:helvetivaBold ];}

3. You can use the cgcolorgetcomponents function to obtain the components of a color object.

4. You can use cgcolorgetnumberofcomponents to obtain the number of color components that make up the color.

5. Image Rendering

A) drawatpoint: instance method of uiimage

B) drawinrect: instance method of uiimage

6. Draw a line

 

1) Select a color for the graphic Context

2) use the uigraphicsgetcurrentcontext function to obtain the image context handle.

3) Use cgcontextmovetopoint to set the line start point

4) use cgcontextaddlinetopoint to move your paint brush in the graphic context to specify the end point of the line.

5) Use cgcontextstrokepath to create the path you have set. This process uses the current color set in the graphic context to draw the path.

[[Uicolor bluecolor] set];

Cgcontextref context = uigraphicsgetcurrentcontext ();

Cgcontextsetlinewidth (context, 5.0 );

Cgcontextmovetopoint (context, 50,160 );

Cgcontextaddlinetopoint (context, 150,160 );

Cgcontextaddlinetopoint (context, 150,260 );

Cgcontextaddlinetopoint (context, 50,260 );

Cgcontextaddlinetopoint (context, 50,160 );

Cgcontextsetlinejoin (context, kcglinejoinbevel );

Cgcontextstrokepath (context );

7. You can use cgcontextsetlinejoin to set the style of the connection points between the line and the line.

 

Kcglinejoinmiter

This is the default connection style.

Kcglinejoinbevel

The corner of the connection is normal.

Kcglinejoinround

Literally, the link is circular.

8. Draw a path

 

Cgpathcreatemutable Function

Create a variable path of Type cgmutablepathref and return its handle. Every time we use this path, we should do our best for it. Soon you will see it.

Cgpathmovetopoint Process

Move the current position of the paint brush to a point in the path, which is specified by the cgpoint type parameter.

Cgpathaddlinetopoint Process

Draw a line segment from the current paint brush position to the specified position (also specified by the cgpoint type value.

Cgcontextaddpath Process

Add a path to the drawing context to prepare for drawing.

Cgcontextdrawpath Process

Draw the given path in the graphic Context

Cgpathrelease Process

Release the memory allocated for the path handle

9. Fill in several colors when drawing the path

 

Kcgpathstroke

Use the selected stroke color as the path stroke

Kcgpathfill

Fill the area surrounded by the currently selected fill color path

Kcgpathfillstroke

Combine stroke and fill. Fill the path with the currently selected fill color and draw the edge of the path with the selected stroke color.


 

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.