Adobe Illustrator - Masking using layers with stroke?
I'm working with Google Maps in making a campus map comprised of a number of tile overlays. Two of these overlays- accessibility (paths) and parking- are layered under other elements (with strokes) which help define it's shape within sidewalks and parking lots:
However, to create their individual tile overlays, I need to export only what is shown of these two layers as seen in the right side of the below image.
My approach up to now:
- Make every element layered below the target layer hidden.
- Take every element which exists above the target layer and make their fill and/or stroke black as needed. (Essentially making a mask which compensates for the strokes of the other layers. See below image, left.)
- Export the file to Photoshop.
- Using Magic Wand or Color Selector, remove the black, resulting in the target layer in the desire shape.
This does exactly what I want and fits perfectly in the space, but it is somewhat complex for other users and leaves some evidence behind of the approach- namely, darker pixels at the edges- in the final product (below, right)
*(Note: In the right image, "white" is equivalent to "transparent".)
Thus, my question is "is there a way to include the stroke in 'masking' elements"? For instance, is there a way to make a mask which also includes the stroke on an element rather than just along the drawn path?
Or, perhaps even more fun, is there a way to color/swatch a shape to be "transparent" rather than simply "none" so that it still hides what is below it, but prints/exports as being transparent?
Alternatively, is there any other more simple approach which does not include the following:
- Combining the render and overlay layers. (Results in 6 overlays rather than 3.)
- Drawing the overlay layers to perfectly match the sidewalk/lot. (Most higher elements use strokes which are not easily traced, and would be much more work.)
EDIT: Here is an .ai file with a simple arrangement of what I'm working with if anyone would like to play around or get some additional context.
After the comments above, try this.
This is a temporary step to get the export which could then be discarded or undone if needed.
- Green objects are on their own layer/layers
- stripe pattern is on its own layer
- pink/purple/blue paths are on a layer.
- the black areas in your image above are simply flat shapes, no effects.
If all of this is true.......
- Select all the black objects in your second attached image
- Edit > Cut
- Select everything on a layer you wish to mask (like the blue stripes)
- Edit > Paste in Front
- Pathfinder > Unite (this creates one compound shape from all the black areas)
- Select everything on the layer - stripes and black areas.
- In the Transparency Panel, click the Make Mask button
- Tick the "inverted" option on the Transparency Panel.
This should leave you with only the visible areas on the fill layers which could then be exported. If the green shapes change later, you would need to go through the steps again, deleting the existing mask and replacing it with a new one.
Once you do these steps a couple times I'm certain you could streamline or even create an action to do most of it. For example - copy green shapes, turn off green layer visibility, select blue layer, paste in front, set fills to black, pathfinder > unite, select all, make mask, export.
For this to work, all the green areas much touch each other at some point... any point
- Duplicate the green layer
- Select all on the duplicate.
- Pathfinder > Unite
- From the Layer Panel menu, choose Make Clipping Mask
- Expand the duplicate layer in the Layers Panel so you can see it's contents
- Drag all other layers in the Layers Panel below the Clipping Path item in the duplicate layer
The primary difference between these two methods is whether or not the green areas are touching each other. The opacity mask allows you to create masks form any number of shapes regardless of where they are or how they interact with each other. The Second, clipping mask, method requires that all shapes be touching and the mask is a single path or compound path.
Opacity masks can even use gradient fills to create graduated masks. Clipping masks are always hard edged, flat, shapes.
Opacity masks work.....
Using your file I had no issue setting up an opacity mask.
- copy "Buildings", "Detail Layer", and "Green" layer contents.
- Create a new layer below the three layers listed in #1.
- Drag all other layers into this new layer
- Click the circle to the right of this new layer's name on the Layer Panel to select the Layer itself
- Choose Make Opacity mask from the Transparency Panel menu
- Click the black mask box on the Transparency Panel.
- Edit > Paste In Front
- Object > Expand
- Set fill color to black and stroke to "none" (if it's not "none" already)
- Untick the "Clip" option on the Transparency Panel.
As you can see it's pretty straight-forward and I don't really understand where you may have issues with this technique. Not sure where "random spattering" would enter the scenario. You can continually add new sub-layers to the masked layer and the objects will continue to be masked by the shape of the opacity mask. If you need to alter the opacity mask, just click the circle next to it's name, then click the mask thumbnail on the transparency panel. You can then paste in new objects or remove objects as needed. Just be certain they are filled with black and expanded so any strokes are seen as shapes.