Quartz 2D Graphics Context stack matrix clipping

Source: Internet
Author: User

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

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.