Blend if

The icon below is simple. Simple, but difficult to construct in most design tools, while maintaining the ability to scale for different pixel densities.

A simple icon

Vitox asked for advice on how to build the icon in Photoshop. I suggested using mask feathering. That works, and is an acceptable solution. But, Philipp Antoni’s suggested a great method using blending options on a group. With blend if, Philipp converted black and white pixels to transparent and white pixels. It’s an amazing approach, with some incredible implications.

I think this is kind of a big deal — transparency can now be painted, using any layer, tool or feature that can draw colour. Whoa.

Converting greyscale to transparency

Blend if can be found under the layer and group blending options (the same window that contains layer styles). We’re most interested in the “this layer” section, which dictates if and how brightness levels are mapped to transparency.

Blending options

Dragging the black stop towards the right makes dark areas transparent.

Blending options

Dragging the white stop towards the left makes light areas transparent.

Blending options

Option-dragging the white or black stop splits it in two, creating a smooth blend between transparent and opaque areas. We’d like to map black to fully transparent, white to fully opaque, and all brightness levels in between to a corresponding transparency level.

This can be done by leaving the white stop to the right, and option-dragging the black stop so it starts on the far left and ends on the far right.

Blending options

This gives us the correct transparency effect, but the colours remain the same — black is still black, white is still white, and the varying levels of grey are still grey. Enclosing everything within another group, and applying a colour overlay lets us override the colour, but maintain transparency.

Group with blend if

It requires two enclosing groups for the effect, but many icons or elements can be placed inside those groups, and processed together. The color overlay that is being used to apply an overall color also provides a single place to make colour adjustments, which could help when styling many icons at once.

Layer styles

Using the same technique, a drop shadow can be applied to paint transparent areas. This is how Philipp constructed his version of the icon. I’ve used a drop shadow below, but any layer style can be used to paint transparency.

Blend if and layer styles

Strokes

Blend if works well with vector strokes. The example below contains three circles on separate layers. The stroke widths can be altered in unison. The fills can be varying levels of opacity and overwrite the opacity of the layers below.

Blend if and strokes

Sure, you could do that using only shape layers and some elements set to subtract, but it would require more shapes and be harder to maintain.

The benefits become apparent with a more complex icon. The chat icon below could be built without using blend if, but it would be far more complex (keep in mind the semi-transparent portions as you think through other ways to construct it).

Chat icon

Editable text

Editable text, with strokes that paint transparent areas? Sure thing.

Editable text

Adjustment layers

Given we’re dealing with greyscale data, adjustment layers and blending modes can also be used. And, here’s where things can get a little wild — draw some shapes, blur with mask feathering, then increase the contrast for organic, vector-based shapes in Photoshop.

Metaballs

They’re just shape layers. They can be moved around in realtime. Or animated.

Metaballs

Everything above assumes the final result can be coloured using layer styles on a group — flat colours, gradients, shapes clipped to the group or similar. I think this method can be taken even further, but I need to do a little more experimentation to see how far it can go.

Thanks Philipp, you’ve definitely given me something to think about.

Example PSD

Metaballs

The examples above are available for download as an attachment on this Dribbble shot:

Blend if is awesome

Questions? Hit me up on Twitter.

Published 28 October 2014.