Varying Transparencies in Live Paint

Something I hadn’t considered before it came up at work was that it might be useful to sometimes have areas of varying transparency in a single live paint group. Live paint is a useful shortcut in Illustrator that people probably take for granted now, but it was probably originally a way of making things in Illustrator a bit more Photoshop-like for newcomers. Before live paint, you’d probably construct everything you needed to fill as a closed path, which makes a bit of planning and close attention to the stacking order of objects essential for complex drawing. With live paint, you can just draw and let those things take care of themselves for the most part. Read up here if you’re unfamiliar.

Anyway, one thing you can’t do without breaking your live paint group into separate closed paths is adjust the transparency of individual filled areas. Not in the usual way, at least. You can still select individual paths (and the fills themselves with the live paint selection tool), but if you look at the appearance panel you’ll find you still just have the live paint group selected — there’s no way to add a stroke to an individual path either. Take this giant butterfly:

An image of a butterfly against a background of the sun setting behind pylons. This image will be used to demonstrate varying transparencies in live paint groups.

He’s a live paint group, of course. Say I wanted his colourful wing segments to appear transparent, but the dark areas to remain opaque. The first clue as to how you can go about this is here:

The butterfly image as a live paint group filled with various patterns

You can fill a live paint group with anything in the swatches panel, including patterns and gradients. Patterns can be transparent!  In fact, if you make a transparent filled object and drag it to swatches, a pattern swatch is what you get:

Creating a pattern swatch with transparency

It’s just colour; it’s only attribute as a pattern is that it has 50% opacity. So naturally, you create a set and colour away with the live paint bucket.

The butterfly live paint group, filled with some transparent pattern swatches

Looks delightful! However, there’s one pitfall I’ve found of this method. It’s quite a niche situation, but could be critical if you fall into that tiny niche and can’t figure out what’s wrong. Say you wanted to add a stroke around your butterfly. You’d add it in the appearance panel, drag it below the live paint contents so it doesn’t visually cover the whole group, and then set knockout group so it doesn’t show through the transparent areas (read more about the very useful option knockout group here).

butterfly-pylon5

Pretty silly, but that’s what you want for some reason. Looks fine in Illustrator, but you’ll get a hint as to what’s wrong with this if you check a preview of it in Bridge or your OS:

butterfly-pylon6

You can see the stroke through the transparent areas! Knockout group should prevent this, but for some reason it doesn’t. You’ll see the same thing if you place the AI file in InDesign, or if you export a raster file such as PNG. This is because other applications can only view the PDF side of the AI file, and while this method works fine in Illustrator, something evidently gets lost in the translation to PDF. This isn’t great news if you actually need to produce something using this method!

Fortunately, there’s another way. Remember that you can add gradients to the swatch panel too, and these can also contain transparency. Obviously you could have any combination of transparent gradient stops, but if you just want to replicate what we’ve made above, you’d need a gradient with two identical stops, with the same opacity setting.

butterfly-pylon7

A bit of a pain, and rather odd, But for whatever reason, this setup translates fine into the PDF, and makes an image created in this way usable elsewhere.

Blending modes in Adobe Illustrator

If you’re anything like me, you probably know what a few of the blend modes do intuitively, but have no idea what they’re actually doing to the colours you use. Multiply darkens things, Screen produces highlights, et cetera. But how? Here I’m going to attempt to explain what they’re doing behind the scenes, and hopefully gain a better understanding myself in the process. I’m going to use the modes in Illustrator as examples; there are more modes in Photoshop, but the same principles apply to both. I compiled this using the following sources:

http://photoblogstop.com/photoshop/photoshop-blend-modes-explained

http://www.deepskycolors.com/archivo/2010/04/21/formulas-for-Photoshop-blending-modes.html

https://en.wikipedia.org/wiki/Blend_modes

Wherever possible I’ve verified the results with experimentation, but if you spot any errors I will gladly correct them.

Basics
Blending modes are equations between two or more colour values that sit on top of one another in the stack order. You’re probably aware that in RGB colour, each 8-bit channel contains a colour value between 0-255. When doing the maths for blending modes, Illustrator converts this into a value between zero and 1. For example, if a colour has a green value of 200, this becomes 0.78125 (200 ÷ 255).

In the basic lightening and darkening blends at least, colours are compared channel by channel. So, in Multiply, for example, Red is multiplied by Red, Green by Green, and Blue by Blue. The resulting colour is the combination of all three. Again with Multiply as an example, the top colour is multiplied by the bottom colour.

An example
With all this talk of examples, we’d better have an actual one. Multiply is the simplest mode to demonstrate as it has the simplest equation: x = a × b, in which x is the resulting colour value, a is the top or active layer, and b the background. So, here are two green squares.

Overlapping squares with colour values of 0/125/0, used to demonstrate the Multiply blending mode in Adobe Illustrator.

They have colour values of 0/125/0 − only the green channel has a value, to make this as simple as possible. Naturally, the top square is set to Multiply. So what’s going on at the overlap? First up, that 125 green value needs to be converted to a value between zero and 1. This gives us ~0.488. Therefore, the sum involved is 0.488 × 0.488, which gives us ~0.238, or a green value of about 61 between zero and 255, darker than the original colour, of course.

This works differently in CMYK, we should note, because of the differences between additive and subtractive colour. Ink values in a CMYK document don’t work on a digital scale of fixed levels, but an analogue one of ink saturation percentages. Say we have two squares in a CMYK document that are both 50% yellow, which gives us a sum of 0.5 × 0.5. The result is 0.25, but since we’re dealing with additive colour, this means more ink achieves a darker result: a value of 75% (zero would be 100% yellow). CMYK documents won’t be covered here because of these additional complexities.

Zero and One
Because a colour value of 255 equals 1 in the equation, and a value of zero equals 0 (of course), 255 will have no effect on the colour beneath (x × 1), and 0 will result in black (x × 0) if we ignore any other channel interactions.

An example with all three channels
Let’s do one more example of multiply with all three channels involved. The bottom square here has values of 180/120/60, the top square 200/80/220.

An example of blending with all three colour channels (R, G and B)
This means our sums are as follows:

Red = 0.78125 × 0.703125 = 0.54931640625
Green = 0.3125 × 0.46875 = 0.146484375
Blue = 0.859375 × 0.234375 = 0.201416015625

Multiply those results by 255 to once again get the 8-bit value, and resulting colour values should therefore be 141/38/52. Let’s flatten transparency and see if we’re correct.

Looks good! Excellent.

Blend modes in illustrator
Now let’s look at the individual blend modes in the order they occur in the Illustrator UI. In any equations listed, a is the active, foreground layer, b is the background layer, and x is the resulting colour.

Normal
No blending is applied and colours are opaque (unless you’ve modified the objects in other ways).

Darken
No sums needed in Darken, where the colour values are simply compared and the darkest ones kept. In the example here, a = 240/120/200, and b = 150/200/180, therefore x = 150/120/180.

The Darken blend mode, demonstrated with overlapping squares

Multiply
As we’ve already discussed, Multiply darkens colours with the formula x = a × b.

Colour Burn
A darkening effect, corresponding to a ‘burn’ in Photoshop. The formula here is 1-(1-ba.

The Colour Burn blend mode, demonstrated with overlapping squares

For two squares with 180 green, this gives us:
1 – 0.7058823529411765 = 0.2941176470588235
0.2941176470588235 ÷ 0.7058823529411765 = 0.4166666666666666
1 – 0.4166666666666666 = 0.5833333333333334
0.5833333333333334 × 255 = 149 (rounded)
This results in more darkening than Multiply at lower colour values, and less at higher values. At values above ~230 and below ~130, the results will be greater than 1 or less than zero, resulting in pure colour or black respectively.

Lighten
The opposite of Darken, of course. The colour values are compared and the lightest retained.

Screen
The usual counterpart to Multiply for highlights, the formula for Screen is 1-(1-a)×(1-b).

The Screen blend mode, demonstrated with overlapping squares

So using the 180 green example again:
1 – 0.7058823529411765 = 0.2941176470588235 (since our colours are the same, this value is, of course, both 1-a and 1-b)
0.2941176470588235 × 0.2941176470588235 = 0.0865051903114187
1 – 0.0865051903114187 = 0.9134948096885813
0.9134948096885813 × 255 = 233 (rounded)

Colour Dodge
The opposite effect to Colour Burn − think of the ‘dodge’ tool. The formula is b÷(1-a).

The Color Dodge blend mode, demonstrated with overlapping squares

So for two squares of 120 green:
1 – 0.4705882352941176 = 0.5294117647058824
0.4705882352941176 ÷ 0.5294117647058824 = 0.888888888888888
0.888888888888888 × 255 = 226 (rounded)
As the inverse of Colour Burn, values above about 130 will result in pure colour.

Overlay

The Overlay blend mode, demonstrated with overlapping squares
Colours with values lower than 0.5 have Multiply applied on a curved scale, and values over 0.5 have Screen applied the same way − basically, dark colours get darker and lights get lighter, and the effect is more extreme towards each end of the spectrum. The equation here is significantly more complex than the simpler lightening and darkening blends, and produces an S-curve (see below) where the extreme ends of the graph are full Multiply and Screen respecively.

An S-curve graph, approximating the effect of the Overlay blend mode

Soft Light

The Soft Light blend mode, demonstrated with overlapping squares
The same principle as Overlay, but the effects of Multiply and Screen are halved, giving a more muted result (effectively a shallower S-curve).

Hard Light

The Hard Light blend mode, demonstrated with overlapping squares
This mode is the same as Overlay, but with the position of the active layer and background layer on the graph reversed, thus:

An S-curve graph, approximating the effect of the Hard Light blend mode

Difference

The Difference blend mode, demonstrated with overlapping squares
Subtracts colour values on the active layer from values on the background layer. If the number is negative, it is converted into positive. For example, given a background of 120 and an active layer of 180, the result is -60 − which becomes simply 60. If the number is positive, it remains so. The effect is that similar colours end up darker, and different colours edge towards the lighter end.

Exclusion

The Exclusion blend mode, demonstrated with overlapping squares
Exclusion has a rather more complex equation: 0.5-2×(b-0.5)×(a-0.5), but the result is comparable to Difference except that similar colours end up as a midtone (0.5).

Hue

The Hue blend mode, demonstrated with overlapping squares
The next four modes work by combining Hue, Saturation, and Brightness levels (HSB) rather than RGB values. Hue applies the hue value of the active object to the background object, and blends the saturation and brightness levels.

Saturation

The Saturation blend mode, demonstrated with overlapping squares
Saturation applies the saturation value of the active layer, and blends the hue and brightness levels.

Colour

The Colour blend mode, demonstrated with overlapping squares
Keeps the hue and saturation of the active layer and the brightness of the background layer.

Luminosity

The Luminosity blend mode, demonstrated with overlapping squares
Keeps the brightness of the active layer and the hue and saturation of the background layer. The inverse of Colour.

The HSB-related modes don’t always give the numbers one might expect from their outcomes in the colour palette. I think this is because Illustrator is not carrying out the relevant maths on the HSB values, but on the RGB values still. This means the HSB sliders will display values that result in the correct colour output, but since this might be achieved with a spectrum of HSB combinations, the numerical result seen here is arbitrary − similar to the result seen if one views CMYK sliders for an RGB colour.