CGPathAddArc & CGPathAddArcToPoint

CGPathAddArc & CGPathAddArcToPoint

 

参考:http://blog.csdn.net/xcysuccess3/article/details/24001571

 

CGPathAddArc

 

 

注意:由于iOS中的坐标体系是和Quartz坐标体系中Y轴相反的,所以iOS UIView在做Quartz绘图时,Y轴已经做了Scale为-1的转换,因此造成CGPathAddArc函数最后一个是否是顺时针的参数结果正好是相反的,也就是说如果设置最后的参数为YES,根据参数定义应该是顺时针的,但实际绘图结果会是逆时针的。

其实Quartz 2D的坐标系同UIKit并不一样,它的坐标原点在屏幕左下方,但是为了统一编程方式,UIKit对其进行了转换,坐标原点统一在屏幕左上角。

where the red line is what will be drawn, sA is startAngle, eA is the endAngle, r is radius, and x and y are x and y. If you have a previous point the function will line from this point to the start of the arc (unless you are careful this line won't be going in the same direction as the arc).

 

 

CGPathAddArcToPoint

 

If the current point and the first tangent point of the arc (the starting point) are not equal, Quartz appends a straight line segment from the current point to the first tangent point.

假如当前点和第一条切线的点(Starting point)不是同一个点,Quartz 将会在这2点之间画一条直线。

(x1,y1): Starting point     (x2,y2) ending point

Where P1 is the current point of the path, the x1, x2, y1, y2 match the functions x1x2y1y2 and r is radius. The arc will start in the same direction as the line between the current point and (x1, y1)and end in the direction between (x1, y1) and (x2, y2). it won't line to (x2, y2) It will stop at the end of the circle.

 

 

posted @ 2014-11-02 18:50  fanghao  阅读(1281)  评论(0编辑  收藏  举报