Why CGPath and UIBezierPath define “clockwise” differently in SpriteKit?

荒凉一梦 提交于 2019-12-05 20:36:13

CGPath and UIBezierPath use different coordinate systems. UIBezierPath's origin is at the top-left corner of the drawing area and CGPath's origin in at the bottom-left. Consequently, 90º is the lowest point on the circle for UIBezierPath and the highest point for CGPath. Since 0º is at the same point (right-most point) on the circle for both paths, the resulting clockwise arcs from 0º to 90º are drawn differently.

With the origin at the top-left, 90º (π/2) is at the lowest point on the circle and, therefore, a clockwise UIBezierPath arc is drawn as shown in the figure below. Since SpriteKit's origin is at the bottom-left, this arc appears flipped (vertically) when used to create the SKShapeNode.

With the origin at the bottom-left, 90º is at the top of the circle and a clockwise CGPath arc is drawn as shown below. Since SpriteKit's origin is also at the bottom-left, the shape node arc appears in the same orientation.

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