## 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

This is the official thread to discuss the following blog post: Core Graphics Tutorial: Curves and Layers
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - -

rwenderlich

Posts: 2333
Joined: Thu Dec 23, 2010 4:14 pm
Has thanked: 28 times
Been thanked: 412 times

### Re: Core Graphics Tutorial: Curves and Layers

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

Hi
Great tutorial

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

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);`

Fred
FreddyF
Uber Haxx0r

Posts: 135
Joined: Fri Dec 21, 2012 11:28 pm
Has thanked: 18 times
Been thanked: 2 times

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

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

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