Opacity Mask Basics: Illustrator
by Jay Hilgert
on March 27, 2007
If our freebies have benefited you personally or have helped you earn a profit please consider donating via paypal. Donate NowLearn how to earn $125 or more per hour as a freelancer - Click Here
Hi all, I just got back from 4 days away from home, so here is something to chew on while I get back into the swing of things. If you have ever downloaded (or not) one of my free sets of buttons or webpage elements, you might notice that I use a lot of opacity masks in my Illustrator files. I do this for a number of reasons, some of which may be obvious, but I would like to clarify a little better on how to use these (opacity masks), and why.
An opacity mask is essentially like a mixture of a clipping mask and a layer mask at the same time. in other words, you can use an opacity mask to control the appearance (transparency of a shape) using, in most cases, a black to white gradient. Because you can’t fill an object in Illustrator with a gradient that has transparency, we can use a mask to take away all of the areas covered by the black part of the gradient (or gray in some cases). There are many uses, which I’m sure you will discover rapidly on your own, and soft opacity gives illustrator a whole other dimension to work with.
An “Opacity Mask” refers to a mask in Illustrator that you place over an existing shape that controls its transparency based on the values of black and white in the mask. White being visible, black being transparent, and all shades of gray are in between on the opacity scale.
First make a background shape so you can see the mask work (I used dark brown).
Select your background shape and lock it. You can do this by hitting Command + 2 Mac, or Control + 2 PC. Or the object menu:
Now make a shape on top of your background and fill it with a different color.
Now we need to make a mask for our shape. The easiest way I’ve found is to use “Offset Path,” because it is more precise than simply making a new shape on top. Keep your top shape selected and go to the Object menu and select Path > Offset Path.
Offset Path Settings: I usually set this to a 2 pixel offset, with the Miter setting. (positive pixels makes the new shape bigger, negative smaller). I’m not sure what miter limit is yet, haven’t played with it. I usually leave it at the default value.
Once you click ok, Illustrator will make you a new shape, perfectly aligned with the original, and 2 pixels larger on each side! Like this: (Showing in wireframe view)
The only problem is (from my experience) Illustrator might place the new shape behind the original. Now simply select your new (bigger shape) and bring it to the front.
Now fill your top (mask) shape with a black to white gradient.
Once you have your gradient fill, select both of your shapes Like this: (You can simply do this by clicking and dragging, since we locked our background)
With BOTH shapes selected, go to your transparency palette, and in the upper right, click on the little arrow. (Palette Options) Select “Make Transparency Mask.”
Result: All areas of the gradient containing white will be opaque. All black will be transparent, and grays are a mixture (the fade). If you don’t want to take your shape all the way to transparent, replace your black side of the gradient with a shade of gray.
Tips for exploring this on your own:
1. This can be applied to ANY shape, so think outside the box, but be aware that it increases file size quite a bit, so keep an eye on file size if you find illustrator running slower.
2. The gradient is the master. Change the gradient, change the mask, but you must use black and white.
3. Explore your options in the Transparency palette (mask is clipping) For example, you can use a simple shape and have a complex Opacity mask if “Mask is Clipping” is enabled. In other words, take advantage of this feature as not only an opacity mask, but a clipping mask at the same time. This gives you greater control over the starting and ending values (opacity) of your gradient.
4. There is no (as far as I can tell) shortcut to apply an Opacity Mask. If you want to backup, you will have to release the mask in the same way you applied it; from the Transparency Palette Options, or undo.