Core Graphics Tutorial: Curves and Layers

Discussion of the official tutorials published on raywenderlich.com. Please only discuss the official tutorials here - for general questions, use the General Discussion forum instead.

Core Graphics Tutorial: Curves and Layers

Postby rwenderlich » Sat Apr 20, 2013 11:00 am

This is the official thread to discuss the following blog post: Core Graphics Tutorial: Curves and Layers
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
User avatar
rwenderlich
Team Member
Site Admin
 
Posts: 2155
Joined: Thu Dec 23, 2010 4:14 pm
Has thanked: 28 times
Been thanked: 343 times

Re: Core Graphics Tutorial: Curves and Layers

Postby Shai » Fri May 24, 2013 6:33 pm

Thank you for the tutorial!

Here are few typos and one bug:

By placing the curve farther away from the line, the more pronounced the curve.
==>
By placing the control point farther away from the line, the more pronounced the curve.

The next two arguments (200 and 70) are the x and y position of the first control point.
==>
The next two arguments (200 and 70) are the x and y position of the second control point.

Add the falling code to drawMountainsInRect, underneath the call to draw the Bezier Curve
==>
Add the following code to drawMountainsInRect, underneath the call to draw the Bezier Curve

Add the following method SkyView.munderneath the drawMountainsInRect method
==>
Add the following method to SkyView.m underneath the drawMountainsInRect method

It creates a a large path object the clips a bright green gradient to it.
==>
It creates a large path object then clips a bright green gradient to it.

If you try to shift beyond the last emotion, it throws SIGABRT on this line in drawSkyInRect, and all the colors are 0:
NSArray * gradientColors = @[(__bridge id)baseColor.CGColor, (__bridge id)middleStop.CGColor, (__bridge id)farStop.CGColor];
Shai
n00b
 
Posts: 2
Joined: Sun May 19, 2013 9:41 am
Has thanked: 1 time
Been thanked: 0 time

Re: Core Graphics Tutorial: Curves and Layers

Postby FreddyF » Wed Jun 05, 2013 11:57 am

Hi
Great tutorial

Two little details I don't understand in -drawGrass ...

You don't add
Code: Select all
    CGContextAddPath(context, grass);

there, although you did that for the mountains ... could you explain why it's not necessary ?

Also, you don't have
Code: Select all
    CGContextStrokePath(context);

below CGContextSetStrokeColorWithColor.
Does it mean that the path will never be stroked, but only filled with the gradient ?
If that's the case, what would be the use of this :
Code: Select all
    CGContextSetLineWidth(context, 1);
    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);


Thanks for your answers !

Fred
FreddyF
Uber Haxx0r
 
Posts: 92
Joined: Fri Dec 21, 2012 11:28 pm
Has thanked: 11 times
Been thanked: 0 time

Postby james.park » Wed Jul 31, 2013 12:54 pm

Thanks for the tutorial.

I have a question.

The flower drawn in the CGLayer, not clear than the picture drawn in the graphics context.
How can I fix this?
james.park
n00b
 
Posts: 2
Joined: Wed Jul 31, 2013 12:51 pm
Has thanked: 0 time
Been thanked: 0 time

Postby kashif789us » Tue Nov 26, 2013 5:47 pm

Hi, I drew a quad curve, now I want to move its control point and end points with touch, is there a way to do this? Thanks
kashif789us
Baby Hacker
 
Posts: 7
Joined: Fri Mar 22, 2013 8:01 pm
Has thanked: 0 time
Been thanked: 0 time

Postby Tarunkumar » Thu Jul 03, 2014 8:50 am

In cocos-2dx I can schedule a path with given control points in a given time using ccBezierConfig, but i want to schedule a group of paths as we did in iOS using UIBezeirPath by adding group of paths.
Tarunkumar
n00b
 
Posts: 3
Joined: Thu Jul 03, 2014 7:02 am
Has thanked: 0 time
Been thanked: 0 time


Return to Official Tutorials

Who is online

Users browsing this forum: No registered users and 10 guests