[Openmcl-devel] Core Animation demo

Raffael Cavallaro raffaelcavallaro at mac.com
Wed Jul 8 13:30:26 UTC 2009


On Jul 8, 2009, at 1:58 AM, Neil Baylis wrote:

> My project involves managing a large number of layers, and my intent  
> was to define a CLOS layer class to manage them. Each sprite needs  
> to have a unique name so that they can be referred to by constraints  
> for positioning them relative to each other. I haven't decided  
> whether to use the layer container provided by NSView, or to use a  
> separate lisp collection.
>
> I'm attaching an image of the kind of thing I want to create. I made  
> this image using Inkscape, but I find that rather clumsy to use, and  
> prone to cumulative errors on a large drawing. This is a  
> reproduction of a tiling pattern I saw at a house in Australia  
> recently.

The image you've attached (which is quite striking by the way) seems  
to me to cry out for NSBezierPath.  If you mean to use Core Animation,  
you could have a tile class and a path class. Many tile instances  
could share the same path instance since it is the layer of each tile  
that would be scaled, rotated, transformed, etc. not the bezier path  
itself (if I'm understanding the Apple docs correctly). Ordinarily,  
rotations and other path transforms mutate the NSBezierPath itself,  
but I think Core animation layers are themselves transformed and leave  
the underlying NSBezierPath unchanged. What's really going on is that  
the layer is rendered unmodified and this rendering is used as an  
OpenGL texture which is mapped to an appropriately scaled, rotated,  
and translated polygon. Fill and stroke don't affect the path itself  
of course, only how it is drawn, so each tile sharing the same path  
could also have a different fill and/or stroke color.

Of course you could simply use NSBezier Path alone, just be aware that  
each transform mutates the path itself - for example,  
transformUsingAffineTransform: returns (void) - i.e., it mutates it's  
argument (aka, "the receiver") rather than returning a new,  
transformed path.

warmest regards,

Ralph





Raffael Cavallaro
raffaelcavallaro at me.com








More information about the Openmcl-devel mailing list