quartz2d If separate from the quartz, then will find Quartz is an open-source Java Job scheduling framework, from the perspective of English translation from the point of view of the quartz of the English is quartz, if sometimes careless search will find the watch recommended. The Quartz described in this article is a drawing layer on top of the Drawin core of Mac OS X, sometimes considered a coregraphics. Quartz directly supports Aqua, creating user interfaces by displaying 2D drawing graphics, including real-time rendering (rendering) and sub-pixel (sub-pixel) precision anti-aliasing, consisting of quartz compositor and quartz components.
quartz2d Introduction
Quartz compositor is a synthetic Windows system that manages and synthesizes behind-the-scenes Windows video to create a Mac OS x user interface, a Quartz 2D graphics library based on a PDF specification, used to draw two-dimensional text and graphics.
Quartz 2D is the main drawing function library in Mac OS x. It replaces the QuickDraw used by earlier versions of Mac OS (now called "Classic"). Quartz 2D is based on the 1.4 version of Adobe PDF (a unified archive format that retains all fonts, formats, colors, and drawings on that platform, regardless of the files in any source). He is a descendant of the display PostScript from next. Quartz 2D and QuickDraw differ in several key areas.
QuickDraw is inherently based on raster graphics, and the basic drawing elements are pixels. Quartz 2D instead of using a more mathematical approach, the coordinate space is the abstract concept defined by the two-dimensional real number. The points in this space can be wired up to form a path, such as a straight line, a Bezier curve, and so on. To create an actual image on the display, those paths are rasterized to produce pixels at the resolution of the display device. This allows the same drawing instruction to produce the same output on any device, using the best resolution available. Like in PostScript, a path can be underlined as a frame, a line, and so on, and a closed path can be filled to create the shape of the entity. The text is simply generated by the path and then forms the shape of the text marker.
On iOS, all drawing, whether or not using OpenGL, Quartz, UIKit, or Core animation-, occurs within the area of the UIView object. The view defines the area of the screen where the drawing occurs. You can write an integrated UIView class yourself, and then draw the necessary graphics (such as triangles), draw the text, draw the picture, read the PDF, (Uiimagepicker capture the picture) and other common functions.
quartz2d Working principle
Generally a bit of development experience should have heard of the context, have made the net MVC know that Microsoft provides the EF context is simply developer benefits, other languages have, probably is two objects interoperate with one bridge, EF is the data layer and controller layer interaction must, iOS if you want to draw pictures, Also inseparable from the context, specifically to see a piece of code, need to create a new view inheritance sub-UIView, the default will have a DrawRect method
before invoking the DrawRect: method in a custom view, the View object automatically configures its drawing environment so that the code can be drawn immediately. As part of these configurations, the UIView object creates a graphics context for the current drawing environment (corresponding to the CGCONTEXTREF encapsulation type). The graphical context contains the information needed to draw the system to perform subsequent drawing commands, and defines basic drawing properties such as the color used for drawing , clipping area, line width and style information, font information, compositing options, and several other information.
-(void) DrawRect: (cgrect) Rect { Cgcontextref context = (); Set the starting point cgcontextmovetopoint (context, in.); Cgcontextaddlinetopoint (context, N.); Cgcontextaddlinetopoint (context, A.); Set the boundary [[Uicolor Blackcolor] setstroke]; Fill Color [[Uicolor Redcolor] setfill]; Draw Path Cgcontextdrawpath (context, Kcgpathfillstroke); }
quartz2d is a C language framework whose API is pure C, and the Quartz2d API comes from The Core graphics Framework, in which the code instantiates a Uigraphicsgetcurrentcontext context, draws a graph, sets the output path of the graph through the context, and the final effect is a right triangle:
The code call is very simple, if the method is not very familiar to find, the general principle or relatively simple, if not very clear, you can look at an Apple's official website map:
There are five available context instances for our selection, Printer,pdf,bitmap,layer,window use, Window,printer used in the OS x~ development generally used to be btimap,layer more, About the need for PDFs according to the business, the next look at a piece of code is a circle:
Gets the context cgcontextref contexts = Uigraphicsgetcurrentcontext (); CGRect rect = CGRectMake (n, A, A, a); Whether there is a border// uirectframe (rect); Adds an ellipse to the rectangle cgcontextaddellipseinrect (context, rect); [[Uicolor Greencolor] setstroke]; Set the green background [[Uicolor Greencolor] setfill]; 3. Draw Path Cgcontextdrawpath (context, kcgpathfillstroke);
The final effect is as follows:
Initial knowledge of iOS development-quartz2d