星形を描く

PaintCode で星形を描いてもらいました。なかなかすばらしいツールです。ちょっと個人で買うには躊躇するお値段ですけど。

UIBezierPathを利用したものです。これを応用すればいろいろ描けそうです。

UIColor* fillColor = [UIColor colorWithRed: 1 green: 1 blue: 0.114 alpha: 1];
UIColor* strokeColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 1];

UIBezierPath* starPath = [UIBezierPath bezierPath];
[starPath moveToPoint: CGPointMake(38, 10)];
[starPath addLineToPoint: CGPointMake(45.94, 22.86)];
[starPath addLineToPoint: CGPointMake(59.4, 27.27)];
[starPath addLineToPoint: CGPointMake(50.84, 39.64)];
[starPath addLineToPoint: CGPointMake(51.23, 55.23)];
[starPath addLineToPoint: CGPointMake(38, 50)];
[starPath addLineToPoint: CGPointMake(24.77, 55.23)];
[starPath addLineToPoint: CGPointMake(25.16, 39.64)];
[starPath addLineToPoint: CGPointMake(16.6, 27.27)];
[starPath addLineToPoint: CGPointMake(30.06, 22.86)];
[starPath closePath];
[fillColor setFill];
[starPath fill];
[strokeColor setStroke];
starPath.lineWidth = 1;
[starPath stroke];

こんな感じです。
draw-star

ちなみにMac OS X Cocoaでやると,
UIBezierPath が NSBezierPathにかわります。

NSBezierPath* starPath = [NSBezierPath bezierPath];