Quartz 2D Graphics Context stack matrix
1 //2 //djview.m3 //Graphics Context Stack4 //5 //Created by Zjj on 15/6/30.6 //Copyright (c) 2015 ZJJ. All rights reserved.7 //8 9 #import "DJVIew.h"Ten One @implementationDjview A -- (void) DrawRect: (cgrect) Rect - { theCgcontextrefref=Uigraphicsgetcurrentcontext (); - //copies a copy of ref (current drawing context) into the graphics context stack -Cgcontextsavegstate (ref); - //Matrix Operation rotation +CGCONTEXTROTATECTM (ref, m_pi_4*0.3); - //all pattern scaling on the matrix operator interface +CGCONTEXTSCALECTM (ref,0.5,0.5); A //matrix operation Panning atCGCONTEXTTRANSLATECTM (ref, -, -); - //Set Drawing status -[[Uicolor Redcolor]Set]; -Cgcontextsetlinewidth (ref,Ten); -Cgcontextsetlinecap (ref, kcglinecapround); - inCgcontextmovetopoint (ref, -, *); -Cgcontextaddlinetopoint (ref, the,195); toCgcontextaddellipseinrect (ref, CGRectMake ( -, -, -, -));//round +Cgcontextaddarc (ref, $, $, Max,0, m_pi*2,0);//round -Cgcontextstrokepath (ref); the // //Set Drawing status * //[[Uicolor blackcolor]set]; $ //cgcontextsetlinewidth (ref, 1);Panax Notoginseng //Cgcontextsetlinecap (ref, Kcglinecapbutt); - //Replace the current context with the stack top context theCgcontextrestoregstate (ref); + ACgcontextaddrect (ref, CGRectMake ( $, $, the, the));//Square theCgcontextmovetopoint (ref,Ten, -); +Cgcontextaddlinetopoint (ref,266,225); -Cgcontextstrokepath (ref); $ } $ - @end
Cropping such as: any picture cropped to a circular head, etc.
Quartz 2D Graphics Context stack matrix clipping