In today’s quick tip, I will shed some light on a tool that often gets ignored due to the complexity that most associate with the way it behaves. That tool is none other than the Clipping Mask, which in my opinion can help you design a whole lot faster once you get the hang of it.
So, in the following lines I will try to unravel its secrets and then compare it to the Pathfinder panel, and see how the first can match and in some cases even replace the second.
What’s a Clipping Mask?
As with any learning curve, we first have to understand what a Clipping Mask is, and Adobe has done a great job in explaining just that: “A clipping mask is an object whose shape masks other artwork so that only areas that lie within the shape are visible.”
So basically if you want to reveal only certain sections of your artwork, or frame elements inside a specific shape, you can create a top-level object that you can then use to do just that.
As you might have noticed, the definition clearly states that only an object, so a vector shape, can act as a clipping mask. You can mask anything (a vector, a raster image) with an object, but you can’t mask vectors using raster images (jpeg, png, etc.).
Also there’s no limit to the number of objects that you can put inside a clipping mask, which of course is awesome.
Most of the time designers omit the existence of the Clipping Mask option because of its hard-to-grasp mechanism.
I have to confess, at first I myself was overwhelmed by a lot of stuff in Illustrator, from the way layers worked to the way Clipping Masks were created. But I soon pictured everything on my Artboard as little pieces of paper (white sheets, colored sheets, transparent sheets), and that actually helped me see everything differently.
You can try and picture the Clipping Mask as a larger piece of
transparent paper that goes over another colored or white piece. When they
overlay, the transparent paper magically hides everything that goes outside its boundaries, giving a clear view of whatever is underneath it.
How Do You Create a Clipping Mask?
If you didn’t know how to make a Clipping Mask before, don’t worry, because it’s actually really easy.
Let’s take an example and see the tool in action. I’ve created a 320 x 320 px yellow square, which I will use as both a background and a Clipping Mask, and I want to add a 554 x 230 px ellipse that will represent a field.
As you can see, the field goes all
the way outside the square, which is something that I don’t want it to do.
This is where the Clipping Mask option comes in
help. Through a simple process of copying and then pasting a duplicate of the
yellow square (which will act as my mask) over the field (which is the object I
need masking), I then select both shapes and use any of the following methods to
create my mask:
Method One: Right-Click > Make Clipping Mask
Method Two: Control-7
Method Three: Object > Clipping Mask > Make
Method Four: Layers Panel > Make/Release Clipping Mask
It’s as simple as that. Using just a couple of clicks or keys (depending on the method), I’ve managed to hide every single section of the field that falls outside the yellow background. Easy, right?
Hold on for a sec! Some of you may argue that you can do the same thing with little old Pathfinder.
Well, to be honest, you could. As with the Clipping Mask method, you would paste a copy of the square over the ellipse and then use the Intersect option, which would result in a new shape.
But when we compare the two methods, you'll see some advantages of using the first method over the second one.
Advantages of Using the Clipping Mask Over the
First, Clipping Masks offer a high level of editability, allowing you to modify, add or remove elements inside the mask.
This was the thing that ultimately changed my workflow, once I found it gave me more room to play around since my shapes wouldn’t need to be deleted and then created again using Pathfinder’s Intersect option. I could just create something, mask it, and edit things on the fly without worrying.
That being said, don’t get me wrong, Pathfinder is still a great panel. You can get the same result, but what happens once you need to adjust or add things? Well, you have to start cutting and creating and cutting, and for me this just complicates things.
Let’s take the yellow/orange field example, and let’s say I want to add another ellipse on the left side. If I double-click on the field section, I will go directly into Isolation Mode, where I can add my new shape.
If I were to do the same thing using Pathfinder, I would first need to create a duplicate of the yellow background, then create my ellipse, select them both and finally use the Intersect option. Which is OKish I guess.
Now let’s say that I want to make my recently added field a little bit wider.
Using the Clipping Mask method, I can simply select the shape either using my Direct Selection Tool (A) or by entering Isolation Mode, and then give it a higher width value.
If I added the second field using the Pathfinder method, well if I’m lazy and not that into details I could just select the right anchor point using the Direct Selection Tool (A) and drag it to the right. But since I’m neither, I would have to create the larger ellipse and then intersect it again with my background.
But this is a pretty nice scenario, where our background is a square, and our shape is not that complicated. What would have happened if the background object had more curved lines, and my inner shapes were something other than ellipses?
I’ll tell you what would happen. You would have deleted a lot of shapes and recreated them from scratch since the sections that were facing the border of the main shape (the one used as a base intersection object) would need some serious repairing.
Of course some might say: “Well I can actually select the shape and drag the right side of its bounding box either to the left of right to shrink or enlarge it. Once I've done that I can simply intersect it one more time with the base shape from underneath.”
Well, sure, that works when you’re not working on a pixel-perfect basis, but try to do that when you have every precious pixel and anchor point snapped to the grid, and see what happens.
I pointed out this advantage a few lines ago. By using Clipping Masks you will create more quickly, in fact a whole lot more quickly than if you were to use the Pathfinder panel. Just give it a try, and if I’m wrong then you can leave a nasty “liar, liar, pants on fire” comment in the bottom section.
But trust me, I know what I’m saying. I’ve been
there, tried that, and gotten here, so I know from first hand.
Some of you guys out there, at this point probably know that I’m super deep in the whole pixel-perfect workflow. I want, need, must have everything on my Artboard perfectly snapped to my Pixel Grid, otherwise I go cuckoo.
So I’m going to let you in on a little secret that really makes a difference when adding details to illustrations that are built on a pixel-perfect foundation: Clipping Masks can and will always be a better choice over Pathfinder’s options.
Once you have a perfectly snapped object, using it as a mask will make all the inner elements adhere to that same crisp and clean look.
I’m going to give you a little example to show you what I’m talking about.
OK, so let’s go back to our little field illustration, and let’s say we want to add a shadow between the two fields, but contain it so that it will only go over the smaller left field and not the entire background.
Using the Ellipse Tool (L) I’ve created a 574 x 250 px shape, which I then colored using black and lowered its Opacity level to 10%. As you can see, I’ve positioned the shadow right on top of all my other elements.
Let’s start by using the Pathfinder method.
First I’ll create a copy of the left field, and then with both it and the shadow selected, I’ll use the Intersect option. Then, I’ll need to create a copy of the squared background and Intersect that with the resulted shape. Finally I can cut the shape and paste it inside the Clipping Mask, making sure to position it under the first field.
At a first glance you might say that the result is exactly what we wanted.
But let’s zoom in a little and select the shadow using the Direct Selection Tool (A) while in Pixel Preview mode.
As you can see, due to the Intersect operation, the new shape has a misaligned anchor (actually it has about three). In this case they aren’t harmful since they don’t go outside the surface of our main square, and most importantly since the shape is already contained inside a clipping mask.
But this isn’t always the case. I used to play with the Intersect option a lot when I started out creating with pixel perfection in mind, and at some point I started getting problems since the intersection would create anchors that required re-snapping. The problem was that by doing so, in most cases my anchors would fall outside the shape onto which I positioned them, making it impossible to perfectly align them to my margins.
If we go back to our example, we can see that not only did the intersection misalign the anchors, it also added newer ones since the shadow gained a different overall shape.
Now let’s try to replicate the same result using the Clipping Mask method.
First I’m going to select the smaller field shape, paste it on top of the shadow, and with both of them selected I’m going to right click > Make Clipping Mask.
Once I have my masked object, I’m simply going to copy it inside my larger mask and position it underneath the larger bottom field.
As you’ve probably noticed, the process is actually faster, and if I zoom in and select my shadow, we can see that it is perfectly snapped to the Pixel Grid, no extra anchors included.
At this point I’m hoping that you start thinking twice before using the Pathfinder panel when adding details to your artwork, and give the Clipping Mask a chance, since it might turn out to be a lot more versatile.
There you have it. I’ve laid it all on the
table for you to see, so that in the end you can make a decision based on your
own needs. I hope your decision is based on the little piece of insight that
I’ve managed to pull out of my own experience.