【发布时间】:2014-02-12 05:24:47
【问题描述】:
我对我的数学感到震惊....
我在视图上绘制 8 条红线,完全延伸到边缘,但它没有。
我错过了什么吗?附上截图以更好地解释它
NSDictionary *d=@{@(0): @0,
@(1): @45,
@(2): @90,
@(3): @135,
@(4): @180,
@(5): @-45,
@(6): @-90,
@(7): @-135,
@(8): @-180};
for (int i=0; i<8; i++)
{
CGContextSetLineWidth (ctx, 1.5);
CGContextSetRGBStrokeColor (ctx, 255.0, 0.0, 0.0, 1.0);
CGContextMoveToPoint (ctx, 160, 240);
CGFloat degreeFloat = [d[@(i)] floatValue] ;
CGFloat deltaX = radius * cosf(RADIANS([d[@(i)] floatValue] ));
CGFloat deltaY = radius * sinf(RADIANS([d[@(i)] floatValue] ));
CGFloat endX = 160 + deltaX;
CGFloat endy = 240 + deltaY;
CGContextAddLineToPoint(ctx, endX, endy);
CGContextStrokePath(ctx);
//CGContextRef ctx = UIGraphicsGetCurrentContext();
}
【问题讨论】:
标签: ios objective-c core-graphics cgcontext