2008 05 14Projected coordinates of a 3D CALayer
CALayer
, but you can use convertRect:fromLayer
to almost get them. Thanks to Simon Fraser on the Quartz ML for that.
Suppose you have layers setup like that :
rootLayer
layerHavingA3DTransform
layer1
layer2
layer3
layer1
, layer2
, layer3
will be transformed by layerHavingA3DTransform
and will appear 3D. To get their projected coordinates, use
CGRect projectedRect = [layer1 convertRect:localRect toLayer:[self layer]];
This will transform localRect
, a rect in layer1
coordinates to root layer coordinates. If you want the layer extent, that's -bounds.width/2, -bounds.height/2, bounds.width, bounds.height
for the default anchorPoint
of (0.5, 0.5). Note that projectedRect
is in layer coordinates, not in NSView
coordinates. For this case I had manually centered layerHavingA3DTransform
in the view and got coordinates reflecting that, going from -size to +size.
convertPoint:fromLayer
to convert each layer point.