Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cacaodev/355563 to your computer and use it in GitHub Desktop.
Save cacaodev/355563 to your computer and use it in GitHub Desktop.
- (void)drawRect:(CGRect)rect
{
var ctx = [[CPGraphicsContext currentContext] graphicsPort];
CGContextSetFillColor(ctx, [CPColor redColor]);
var path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 50,50);
CGPathAddLineToPoint(path, NULL, 50,150);
CGPathAddLineToPoint(path, NULL, 150,150);
CGContextAddPath(ctx, path);
path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 250,60);
CGPathAddLineToPoint(path, NULL, 250,160);
CGPathAddLineToPoint(path, NULL, 350,160);
CGContextAddPath(ctx, path);
var path = CGPathCreateMutable();
CGPathAddArc(path, NULL, 100,250,50,0,Math.PI,1);
CGContextAddPath(ctx, path);
path = CGPathCreateMutable();
CGPathAddArc(path, NULL, 300,260,50,0,Math.PI,1);
CGContextAddPath(ctx, path);
CGContextFillPath(ctx);
}
- (void)drawRect:(NSRect)rect
{
CGContextRef ctx = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetRGBFillColor(ctx, 1, 0, 0, 1);
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 50,50);
CGPathAddLineToPoint(path, NULL, 50,150);
CGPathAddLineToPoint(path, NULL, 150,150);
CGContextAddPath(ctx, path);
path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 250,60);
CGPathAddLineToPoint(path, NULL, 250,160);
CGPathAddLineToPoint(path, NULL, 350,160);
CGContextAddPath(ctx, path);
path = CGPathCreateMutable();
CGPathAddArc(path, NULL, 100,250,50,0,M_PI,1);
CGContextAddPath(ctx, path);
path = CGPathCreateMutable();
CGPathAddArc(path, NULL, 300,260,50,0,M_PI,1);
CGContextAddPath(ctx, path);
CGContextFillPath(ctx);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment