如何使用CGPathAddCurveToPoint创建一个完美的半圈?

编程入门 行业动态 更新时间:2024-10-09 11:17:13
本文介绍了如何使用CGPathAddCurveToPoint创建一个完美的半圈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试用CGPathAddCurveToPoint创建一个15点半径的完美右半圆,如下所示:

I am trying to create a perfect right half circle of 15 points radius with CGPathAddCurveToPoint, like this:

CGPathMoveToPoint(path, NULL, 0, 0); CGPathAddCurveToPoint(path, NULL, 15, 0, 15, 30, 0, 30);

它从圆圈的中间开始。 然后第一个控制点设置在圆的边界框的右上角。 第二个控制点设置在圆圈边界框的右下角。 圆圈终止于边界框的底部中间。

It starts at the top middle of the circle. Then the first control point is set to the top right corner of the circle's bounding box. The second control point is set to the bottom right corner of the circle's bounding box. The circle ends at bottom middle of the bounding box.

但绘制时,圆圈呈卵形。

But when drawn, the circle has an egg-like shape.

如何从0,0点向右开始到0,30结束,制作一个完美无瑕的右半球?

How can I make a perfect, flawless right semisphere starting at point 0,0 going to the right and ending at 0,30?

推荐答案

CGPathAddCurveToPoint 创建Bézier曲线,而不是圆弧。您正在寻找的方法是 CGPathAddArc 或 CGPathAddArcToPoint ,如下所示:

CGPathAddCurveToPoint creates a Bézier curve, not a circular arc. The method you’re looking for is CGPathAddArc or CGPathAddArcToPoint, as below:

CGPathMoveToPoint(path, NULL, 0, 0); CGPathAddArc(path, NULL, 0, 15, 15, M_PI_2, -M_PI_2, true);

更多推荐

如何使用CGPathAddCurveToPoint创建一个完美的半圈?

本文发布于:2023-11-30 13:40:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650189.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   创建一个   完美   CGPathAddCurveToPoint

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!