3

次のコードを使用して、Objective C で弧を描きました。

    [newPath appendBezierPathWithArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle];

今度は、円弧の中心から両端まで 2 本の線を引きたいと思います。それ、どうやったら出来るの?片面は次のコードで描画できます。

    [newPath lineToPoint:center];

しかし、反対側はどうでしょうか。

4

2 に答える 2

0

現時点ではテストする機会はありませんが、このようなことを試すことができます。

#import "math.h"

[newPath moveToPoint:center];
[newPath addLineToPoint:CGPointMake(center.x + radius * cos(endAngle * M_PI / 180),
                                    center.y + radius * sin(endAngle * M_PI / 180))];

[newPath moveToPoint:center];
[newPath addLineToPoint:CGPointMake(center.x + radius * cos(startAngle * M_PI / 180),
                                    center.y + radius * sin(startAngle * M_PI / 180))];
于 2013-08-22T05:33:11.830 に答える