Graphics Reference
In-Depth Information
Backfaces
Now that we can rotate our layers in 3D, we can look at them from behind. If we change the
angle in Listing 5.4 to M_PI (180 degrees) rather than M_PI_4 (45 degrees) as it is
currently, we will have rotated the view a full half-circle, such that it is facing directly away
from the camera.
What does a layer look like from the back? See Figure 5.14 to find out.
Figure 5.14 The rear side of our view, showing a mirrored snowman image
As you can see, layers are double-sided; the reverse side shows a mirror image of the front.
This isn't necessarily a desirable feature, though. If your layer contains text or controls, it's
going to be very confusing if the user sees the mirror image of these. It's also potentially
wasteful: Imagine a solid object such as an opaque cube formed from layers—why waste
GPU cycles drawing the layers on the reverse side of the cube if we can never see them?
CALayer has a property called doubleSided that controls whether the reverse side of a
layer should be drawn. The doubleSided property is a BOOL and defaults to YES . If you
set it to NO , then when the layer is facing away from the camera, it will not be drawn at all.
Layer Flattening
What happens if we transform a layer containing another layer that has itself been
transformed in the opposite direction? Confused? See Figure 5.15.
Search WWH ::




Custom Search