如何使用CGPathAddCurveToPoint创建一个完美的半圈? [英] How to create a perfect half circle with CGPathAddCurveToPoint?

查看:623
本文介绍了如何使用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创建一个完美的半圈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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