How to get points of Arc?

假如想象 提交于 2019-12-24 14:05:03

问题


I am working on core animation and core graphics.I am drawing one arc with centre (0,0).Now i want to draw line after arc.i can draw arc but then after i am not able to get two different point of arc.How can i get it?Here is code :

CGMutablePathRef retPath = CGPathCreateMutable();
CGPathMoveToPoint(retPath, NULL, 20, 0);
CGPathAddLineToPoint(retPath, NULL, 75,10);
CGPathAddArc(retPath, NULL, 75, 10, 20, 240, 360, YES);

return retPath;

Please help me.Thanking you.Hint will also be appreciated.


回答1:


When you add a line or an arc to a path it is automatically added from the current point. If you for some reason need to know what the current point is then you can get it by calling CGPathGetCurrentPoint(yourPath);

Adding a line after an arc

In your case you are drawing an arc and want to draw a line after it. Below is an illustration of what happens to the path when the arc is added. The orange line is the actual arc that is added to the path and the orange dot is where the "current point" moves to.

When you then add a line to the path after that it will be added from the end of the arc as you would expect, as illustrated in the image below.

Learn more

I wrote a detailed explanation of how paths work where both these illustrations come from. You can click on the CGPath button in the examples there to see how each line of the code adds to the path.



来源:https://stackoverflow.com/questions/17738605/how-to-get-points-of-arc

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