I use the following code and draws a triangle on the screen. But for some reason, it displays a lower triangle.
Here is the code:
- (void)drawRect:(CGRect)rect {
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path,NULL,10.0f, 100.0f);
CGPathAddLineToPoint(path,NULL,100.0f,10.0f);
CGPathAddLineToPoint(path,NULL,100.0f,100.0f);
CGPathAddLineToPoint(path,NULL,100.0f,100.0f);
CGPathCloseSubpath(path);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(ctx, [UIColor blueColor].CGColor);
CGContextAddPath(ctx, path);
CGContextFillPath(ctx);
}
and here is the result:
/|
/ |
/ |
/ |
/ |
/__ __|
But when I draw it on paper, I came to this diagram:
___________
\ |
\ |
\ |
\ |
\\ |
\
\|
(well, you got the idea right)
What am I missing! Maybe I don’t think directly. x is horizontal and y is vertical. (0,0) is the right start.
source
share