One Quickie


Using CGLayers (Graphics->General)
CGLayer is a Tiger (and beyond) feature that will cache Quartz operations. Kind of like a PICT for CG. Make a new layer based on the context you're going to be drawing it in, then get a context from the layer, and draw into that. So something like this:
- (void) makeLayerInContext: (CGContextRef) enclosingContext
{
    layer = CGLayerCreateWithContext (enclosingContext, CGSizeMake(100, 100),
                                      NULL); // options - unused in Tiger
    CGContextRef context;
    context = CGLayerGetContext (layer);

    // .. and do your drawing

} // makeLayer
And then to draw the layer at a particular point (like replicating it a bunch of different points as done here):
    for (i = 0; i < pointCount; i++) {
        CGContextDrawLayerAtPoint (context, locations[i], layer);
    }



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com