问题
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