quartz2d Draw the White

Source: Internet
Author: User

Today's initial quartz2d, I am so excited ah, happy, inexplicable will like with graphics-related courses ...

Well, gossip less, today with the Quartz2d method to draw the most love of the Great White. I can't wait to share it with you.

1, the first instance of the view

2, in the instance of the view of the write code can be, is not very simple.

Calling the DrawRect method directly is not allowed, using Setneedsdisplay to call the DrawRect method indirectly

-(void) DrawRect: (cgrect) Rect {

Get the graphics context

Get the current drawing context

Cgcontextref context = Uigraphicsgetcurrentcontext ();

Head

[Self drawheader:context];

[Self drawheader2:context];

Eyes

[Self draweye:context];

[Self draweye2:context];

[Self draweye3:context];

[Self draweye4:context];

[Self draweyeline:context];

Body

[Self drawbody:context];

[Self drawbody2:context];

[Self drawbody3:context];

[Self drawbody4:context];

[Self drawbody5:context];

Feet

[Self drawbody6:context];

[Self drawbody7:context];

}

#pragma Mark's head (top)

-(void) Drawheader:(cgcontextref) context{

1. Center, RADIUS, start and end angle, direction

Cgcontextaddarc (context, SELF.FRAME.SIZE.WIDTH/2, 0,-m_pi, 1);

Cgcontextstrokepath (context);

}

#pragma Mark's head (bottom)

-(void) DrawHeader2:(cgcontextref) context{

1. Center, RADIUS, start and end angle, direction

Cgcontextaddarc (context, SELF.FRAME.SIZE.WIDTH/2, 0,-m_pi, 0);

Cgcontextstrokepath (context);

}

#pragma Mark's eyes (lower left)

-(void) DrawEye: (cgcontextref) context{

Cgcontextaddarc (context, 162, Max, 0,-m_pi, 0);

Cgcontextfillpath (context);

}

#pragma Mark's eyes (upper left)

-(void) DrawEye2: (cgcontextref) context{

Cgcontextaddarc (context, 162, Max, 0,-m_pi, 1);

Cgcontextfillpath (context);

}

#pragma Mark's eyes (lower right)

-(void) DrawEye3: (cgcontextref) context{

Cgcontextaddarc (context, 212, Max, 0,-m_pi, 0);

Cgcontextsetlinewidth (context, 3);

Cgcontextfillpath (context);

}

#pragma Mark's eyes (upper right)

-(void) DrawEye4: (cgcontextref) context{

Cgcontextaddarc (context, 212, Max, 0,-m_pi, 1);

Cgcontextsetlinewidth (context, 3);

Cgcontextfillpath (context);

}

#pragma mark's eye connection.

-(void) Draweyeline:(cgcontextref) context{

Move to a point

Cgcontextmovetopoint (context, 162, 160);

Add a line

Cgcontextaddlinetopoint (context, 212, 160);

Cgcontextsetlinewidth (context, 3);//Line width

3. Drawing graphics

Cgcontextstrokepath (context);

}

#pragma mark Body (left) Bezier

-(void) Drawbody: (cgcontextref) context{

Cgpoint P1=cgpointmake (152, 185);

Cgpoint P2=cgpointmake (20, 290);

Cgpoint P3=cgpointmake (120, 400);

Cgcontextmovetopoint (context, p1.x, p1.y);

Cgcontextaddquadcurvetopoint (context, p2.x, P2.y, p3.x, P3.Y);

Cgcontextstrokepath (context);

}

#pragma mark Body (right) Bezier

-(void) DrawBody2: (cgcontextref) context{

Cgpoint P1=cgpointmake (222, 185);

Cgpoint P2=cgpointmake (355, 290);

Cgpoint P3=cgpointmake (255, 400);

Cgcontextmovetopoint (context, p1.x, p1.y);

Cgcontextaddquadcurvetopoint (context, p2.x, P2.y, p3.x, P3.Y);

Cgcontextstrokepath (context);

}

#pragma mark Body (next) Bezier

-(void) DrawBody3: (cgcontextref) context{

Cgpoint P1=cgpointmake (120, 400);//First point

Cgpoint P2=cgpointmake (187.5, 450);//The Middle point

Cgpoint P3=cgpointmake (255, 400);//second point

Cgcontextmovetopoint (context, p1.x, p1.y);

Cgcontextaddquadcurvetopoint (context, p2.x, P2.y, p3.x, P3.Y);

Cgcontextstrokepath (context);

}

#pragma mark body (left arm) Bessel

-(void) DrawBody4: (cgcontextref) context{

Cgpoint P1=cgpointmake (148, 180);

Cgpoint p2=cgpointmake (0, 300);

Cgpoint P3=cgpointmake (103, 380);

Cgcontextmovetopoint (context, p1.x, p1.y);

Cgcontextaddquadcurvetopoint (context, p2.x, P2.y, p3.x, P3.Y);

Cgcontextstrokepath (context);

}

#pragma mark body (right arm) Bessel

-(void) DrawBody5: (cgcontextref) context{

Cgpoint p1=cgpointmake (226, 180);

Cgpoint P2=cgpointmake (375, 300);

Cgpoint P3=cgpointmake (272, 380);

Cgcontextmovetopoint (context, p1.x, p1.y);

Cgcontextaddquadcurvetopoint (context, p2.x, P2.y, p3.x, P3.Y);

Cgcontextstrokepath (context);

}

#pragma mark Foot (left) Bezier

-(void) DrawBody6: (cgcontextref) context{

Cgpoint P1=cgpointmake (120, 400);

Cgpoint P2=cgpointmake (140, 450);

Cgpoint p3=cgpointmake (175, 424);

Cgcontextmovetopoint (context, p1.x, p1.y);

Cgcontextaddquadcurvetopoint (context, p2.x, P2.y, p3.x, P3.Y);

Cgcontextstrokepath (context);

}

#pragma mark Foot (left) Bezier

-(void) DrawBody7: (cgcontextref) context{

Cgpoint P1=cgpointmake (255, 400);

Cgpoint P2=cgpointmake (234, 450);

Cgpoint P3=cgpointmake (199, 424);

Cgcontextmovetopoint (context, p1.x, p1.y);

Cgcontextaddquadcurvetopoint (context, p2.x, P2.y, p3.x, P3.Y);

Cgcontextstrokepath (context);

}

@end

Forgive small rookie to see the less, but, really have to write the code seriously, please like the white children's shoes, take to try it, white to you.

Today study very happy, continue to refuel tomorrow, everybody refuels together yo ~ ~

quartz2d Draw the White

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.