Sorry I'm not really sure what your problem is but if you want those lines to be longer, why don't you just increase radius
?
how to draw a full line tlll the end screen
-
10-10-2022 - |
Question
i got struck abit on my math....
i am drawing 8 red lines on a view fully extend till the edge however it didn't.
am i missing something ? attached screenshots to explain it better
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();
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow