Quratz 2D learning for iPhone Development

Source: Internet
Author: User

IPhoneDevelopmentQuratz 2DThis document describes how to useQuratz 2D, Let's take a look at the details.

1. graphics context graphical context) is an opaque data type CGContextRef ). We can think of graphics context as a drawing target. There are several graphics context: bitmap graphics context, PDF graphics context, window graphics context, and layer context.

2. In IOS, graphics context is obtained by calling the UIGraphicsGetCurrentContext method in method drawRect: to obtain the context. DrawRect: super is not required for the method.

 
 
  1. CGContextRef c = UIGraphicsGetCurrentContext(); 

3. Call the CGContextMoveToPoint method to start a new path,

Call CGContextAddLineToPoint to add a single line.

4. when you want to construct a path in a graphics context, you signal Quartz by calling the function CGContextBeginPath. next, you set the starting point for the first shape, or subpath, in the path by calling the function CGContextMoveToPoint. after you establish the first point, you can add lines, arcs, and curves to the path, keeping in mind the following:

Before you begin a new path, call the function CGContextBeginPath.

Lines, arcs, and curves are drawn starting at the current point. an empty path has no current point; you must call CGContextMoveToPoint to set the startpoint for the first subpath or call a convenience function that implicitly does this for you.

When you want to close the current subpath within a path, call the function CGContextClosePath to connect a segment to the starting point of the subpath. subsequent path callbegin a new subpath, even if you do not explicitly set a new starting point.

When you draw arcs, Quartz draws a line between the current point and the starting point of the arc.

Quartz routines that add ellipses and rectangles add a new closed subpath to the path.

You must call a painting function to fill or stroke the path because creating a path does not draw the path. See "Painting a Path" for detailed information.

Summary: I have explained the content of Quratz 2D learning for iPhone development. I hope this article will help you!

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.