Re: values for Z Position in Layers
Re: values for Z Position in Layers
- Subject: Re: values for Z Position in Layers
- From: email@hidden
- Date: Sun, 28 Oct 2007 14:40:22 +0900
On 平成 19/10/28, at 13:39, Steve Sheets wrote:
Good evening all...
I have a couple quick questions regarding the Z value of a Layer,
that the documentation does not explain.
What should the Z Position property of CALayers be set to?
The property is a float value, but the documentation does not
explain the intended ranged. Often properties that are float are
meant to be of the range 0.0 to 1.0. Is this the case for Z?
No. It is relative to sibling layers. So it can be any valid CGFloat
value.
If not, is there any suggested range for this value? For example,
even though it is a float, is it more efficient to set the property
to integers (ex. 1.0, 2.0, 10.0)?
Z Value is a coordinate value relative to the Z-position of sibling
layers, that is if a layer is set as a sub-layer to a super-layer its
z value is initially 0.
Increasing it movies "forward" and gradually decreasing it to the max
negative CGFloat value possible will move it "away". This is visually
calculated by applying the 3-d transform, so different z-values will
have different apparent (visual) values depending on how the 3-d
transform is set up. IOW, the z-position and also X/Y are effectively
limited by the super layer it inhabits; the superlayer has its own
coordinate system isolated from the "outside" "environment".
Also, any float value is appropriate, there is no reason to use
integers.
Lastly, does changing a Z value for a layer change the layer depth
position in regards to sibling layers or does it change the depth in
relationship to all layers on the view/window? For example, if
sibling layers A & B have values 1.0 & 2.0, then B layer is stacked
on top of the A layer.
Sibling Layers? Yes. Super/Sub Layers? No. But you will not notice any
change in depth though unless you apply a perspective transform by
setting the 3D Transform (CATransform3D) of the super layer.
The struct is as follows:
struct CATransform3D
{
CGFloat m11, m12, m13, m14;
CGFloat m21, m22, m23, m24;
CGFloat m31, m32, m33, m34;
CGFloat m41, m42, m43, m44;
};
Alter m34. Its value is from -1.0 to 1.0 if memory serves
correctly.... Increasing the value, even slightly above 0.0 can have a
big effect on rendering.
You will then get perspective correct rendering when you alter the z-
position. As per your example, layer B will appear above layer A.
If Layer A has sublayer C, can C's Z value be changed so that it
appears on top of B?
No. Sublayers are rendered as flat textures to the super layer, you
will see layer C get bigger, but it will never overlap B.
Don't even think of constructing a 3-d scene using core-animation by
utilizing sub-layers. Everything will be rendered as a 2-d texture to
the super layer.
Andre
Sub layers are rendered FLAT onto the super layer. Eg, if you have a
complex layer and try to do a 3-d cube, do not do it
While i have had some success programming Core Animation, and the
new CALayer objects, I do have some questions that I will be asking
here and on other locations. If anyone wants to talk about Layer
animation, please feel free to contact me directly. I will shortly
have some Demo Apps and source code examples, that I will be willing
to release.
Thanks,
Steve Sheets
Midnight Mage Software
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden