如何获得弧点? [英] How to get points of Arc?

查看:57
本文介绍了如何获得弧点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究核心动画和核心图形。我正在绘制一个中心为(0,0)的弧线。现在我想在arc之后画线。我可以绘制arc,但是之后我无法得到两个不同的弧这是代码:

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.

推荐答案

在向路径中添加直线或圆弧时,会自动从当前点添加它。如果由于某种原因需要知道当前点是什么,则可以通过调用 CGPathGetCurrentPoint(yourPath);

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);

在您的情况下,您正在绘制一条圆弧并希望在其后绘制一条线。下图说明了添加圆弧时路径发生的情况。橙色线是添加到路径的实际弧线,橙色点是当前点移动到的位置。

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.

我写了有关以下内容的详细说明路径是如何工作的这两个插图都来自哪里。您可以在示例中单击CGPath按钮,以查看代码的每一行如何添加到路径中。

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.

这篇关于如何获得弧点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆