CoreGraphics == Good times.
Some time has passed since I did something by hand, what I do these days is all that is needed to perform drawing operations. Remember that there is an implicit โcursorโ starting with Logo , and you can move it without having to move the drawing operation, but you must specify it. I believe that a good approach (at least for static numbers) is to create the paths that you will need to draw first, and then use the path again and again for things like fill, stroke, shade.
CGColorRef fillColor = // yadda CGColorRef strokeColor = // yadda const CGFloat radius = 5.0; // Create the path first - rounded rectangle CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 100.0 - radius, 10.0); CGPathAddLineToPoint(path, NULL, 10.0 + radius, 10.0); CGPathAddArcToPoint(path, NULL, 10.0, 10.0, 10.0, 10.0 + radius, radius); CGPathAddLineToPoint(path, NULL, 10.0, 100.0 - radius); CGPathAddArcToPoint(path, NULL, 10.0, 100.0, 10.0 + radius, 100.0, radius); CGPathAddLineToPoint(path, NULL, 100.0 - radius, 100.0); CGPathAddArcToPoint(path, NULL, 100.0, 100.0, 100.0, 100.0 - radius, radius); CGPathAddLineToPoint(path, NULL, 100.0, 10.0 + radius); CGPathAddArcToPoint(path, NULL, 100.0, 10.0, 100.0 - radius, 10.0, radius); CGPathCloseSubpath(path); // Then use it in your draw commands CGContextSetStrokeColor(context, CGColorGetComponents(strokeColor)); CGContextSetFillColor(context, CGColorGetComponents(fillColor)); CGContextSetLineJoin(context, kCGLineJoinMiter); CGContextSetLineWidth(context, strokeWidth); CGContextAddPath(context, path); CGContextDrawPath(context, kCGPathFillStroke); CGPathRelease(path);
Etc. You can free the path at the end if you want, or save the link for later use.