Kodeco Forums

Video Tutorial: Beginning Core Graphics Part 2: Paths

Learn more about paths: how to use them as clipping areas and how to use them to outline CAShapeLayers. Then learn the difference between points and pixels.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3402-beginning-core-graphics/lessons/3

It would be great if the video mentioned why startAngle is Pi and endAngle is 0 (because of the coordinate system iOS uses?).

@chenglu - great comment.

The default coordinate system is based on an upside down standard unit circle.

Here’s the standard unit circle:

And here’s Apple’s unit circle:

When we specify clockwise in the arc’s function call, we go in a clockwise direction, so 90 degrees (or π / 2) is at the bottom.

In the video I went clockwise from π to 0. But equally I could have gone anti-clockwise from 0 to π.

I had two questions I was hoping to get help with:

I noticed in the second curve you add to the point, the line width is multiplied by two, whereas the previous curve used the line width by itself. Is there a reason to this that I am missing?

Secondly, is there a reason we are using CAShapeLayer vs just drawing over whatever was previously drawn in Core Graphics?