If you've ever seen Phantom of the Opera, you know that the phantom wears a mask to hide his ugly appearance, yet it's the beauty inside of him that is revealed at the end. A recent thread on the Illustrator User to User forum plus other comments I've seen with regards to a seeming struggle with how masks work in Illustrator have lead me to post this description of how masks can be used to complete an illustration. This example also showcases some of the unique strengths of layer clipping masks.
The goal of this exercise is to use masks to hide portions of individual elements within an illustration, as well as an overall masks to clip the entire complete composite. Of course, the file contains layers and the use of layer clipping masks will allow us to preserve this layer structure.
1. In step one, I show a placed image of the skyline of a city. I'd like to add a different sky and also throw in some effects like spotlights in the sky. To do so, I've drawn a vector path that I will use to clip the buildings from the sky. You can see the path, sitting above the image in the layers palette.
2. In step two, I highlight the skyline layer (remember, layers always have gray backgrounds in the layer palette -- white backgrounds are objects) and toggle the mask (by clicking on the icon in the lower left of the Layers palette). This effectively clips the sky out of the illustration. It affects only the image on this layer. The path appears with an underline in the Layers palette indicating that it is now a mask for the contents of its layer.
3. In step three, I turn on a layer which contains a gradient that I've drawn which I will use as the new sky. This layer appears below the image and so the buildings meet the sky nicely.
4. In step four, I turn on a layer which contains spotlights in the sky. These rays are filled white and have a gaussian blur and have an opacity setting applied. Again, because this layer sits below the image, the rays disappear behind the buildings.
5. In step five, I turn on the text layer, which shows the type that has a drop shadow applied (all together now "because I can").
6. In step six, I prepare the file so that I will be able to apply an overall mask. At the top of my document is a layer which I've called Overall Mask. This layer contains a single path which is the final size of what my artwork needs to be. Selecting all of the layers except for the overall mask layer, I drag them all into the overall mask layer, effectively making them sublayers. These sublayers sit beneath the path which will eventually be used as a mask for the overall mask layer.
7. Finally, in step seven, I highlight the overall mask layer and turn on the mask for that layer. This clips all of the artwork in the file, yet the layer structure remains intact. All elements are completely editable and are easily accessible in the Layers palette.
By the way, you'll notice than in this exercise, I use layer clipping masks twice. In general, I try to stay away from using the Object > Clipping Mask > Make command, because it could result in a loss in layer structure (in reality, it works similarly to layer masks, but when I'm using layer masks, I am more conscious of how I set up my layers and therefore avoid such pitfalls).
I hope this example shines some light (pun intended) on how masks can be used in Illustrator.