Why does giving addArcWithCenter a startAngle of 0 degrees make it start at 90 degrees?

不羁岁月 提交于 2019-11-29 23:32:46
David Rönnqvist

This image comes straight from the documentation.

And there is a discussion of how it works (given the default coordinate system)

Discussion
This method adds the specified arc beginning at the current point. The created arc lies on the perimeter of the specified circle. When drawn in the default coordinate system, the start and end angles are based on the unit circle shown in Figure 1. For example, specifying a start angle of 0 radians, an end angle of π radians, and setting the clockwise parameter to YES draws the bottom half of the circle. However, specifying the same start and end angles but setting the clockwise parameter set to NO draws the top half of the circle.

This is how the angles work for addArcWithCenter:radius:startAngle:endAngle:clockwise:. If that isn't what you are seeing then you are calculating your angles incorrectly.

Have a look at Figure 1 in the bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise: documentation: For a "pie slice" in the upper right corner you have to use the parameters

startAngle:degreesToRadians(-90) endAngle:0 clockwise:YES

(The reason is that the default coordinate system on iOS has a x-axis pointing to the right, and a y-axis pointing down.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!