Spray the spines on to a hedgehog

Recently I had occasion to draw a hedgehog tentatively handing his car in for an MOT, as hedgehogs sometimes need to do.

hedgehog-MOT-01

Doodling a hedgehog is simple enough, but how to take a holistic approach to drawing hundreds of spines? There are already a few different art brushes here to give his fur a bit of furriness, but I don’t think we want to be drawing an individual path for every spine too. Here’s how he looks without them:

nospines-02

At the moment he’s a sketch with a calligraphic brush (the black lines), filled shapes for the darker and lighter areas of his body (the brown shades), and some art brushes from Adobe’s Artistic_Paintbrush set to give him a bit of fluffyness (hedgehogs aren’t entirely spiny after all). So what tools do we have that can create and modify hundreds of objects at once?

The Symbol Sprayer tool!

Most approaches to drawing in Illustrator tend to be quite methodical — you draw in layers of discrete shapes, and people who come to it expecting to sketch and paint like they might in Photoshop can quickly hit brick walls with this approach. To me, the symbol sprayer always seemed a bit incongruous in this environment. What use could there be for something that randomly plasters your artboard in symbols? Well I finally found one. The key here is there is a set of tools behind the basic sprayer for modifying the symbol set (as it’s termed) after the fact. But firstly, we need a symbol to work with.

spine

This is just a symmetrical shape with a gradient fill, a couple of millimetres wide in our A4 document. Now we can get spraying.

spray

Go nuts with it. Set the density options (double-click on the tool) as high as they go and cover him. Use the square bracket keys to increase or decrease the size of the brush. Here the spin (rotation) is set to ‘User Defined’, so it initially appears random. After that it’s time for the scruncher.

scrunch-shift

This drags symbols towards the centre of the brush. Use it to pull any outliers into the large brown area of his back. Spray and scrunch until you have a decent density of spines, and your hedgehog will either have absurdly neat upright spines (if you left Spin as ‘Average’) or a complete mess (if you set Spin to ‘User defined’):

mess

I don’t think we can in good conscience leave him like that. Next up is the Symbol Spinner. This tool drags symbols to face the direction of movement of the brush cursor, so you can effectively comb him by dragging the cursor over the symbol set. Note the direction arrows that appear on symbols within the brush area:

brush

Just keep brushing him down until you have a nice neat hedgehog, who might feel a bit more confident about getting his car back:

neat

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.

asset-1

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.

asset-2
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.

asset-4

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.

asset-5

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).

asset-6

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).

asset-7

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

asset-8
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.

asset-9

Soft Light

asset-10
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

asset-11
This mode is the same as Overlay, but with the position of the active layer and background layer on the graph reversed, thus:

asset-18

Difference

asset-12
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

asset-13
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

asset-14
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

asset-15
Saturation applies the saturation value of the active layer, and blends the hue and brightness levels.

Colour

asset-16
Keeps the hue and saturation of the active layer and the brightness of the background layer.

Luminosity

asset-17
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.

Fun with Zig-Zag Spirals

My initial reasons for hanging around the Adobe Illustrator forum was to look for puzzles; that is, things that people couldn’t work out how to achieve that I’d then have a think about and see if I could figure out. They’re squeezed in between complaints about Adobe CC and real beginner questions mostly, but every now and then one pops up. Here’s one I found recently that was quite satisfying to figure out:

How to make a hynpotic spiral (sic)

This person (who unfortunately never followed up their initial post) wanted to make something like the swirl of zigzags in this image (which I cannot credit, having no idea where it came from):

IMG_6544

I couldn’t think of a way right off the bat. Thinking about Illustrator’s own spiral tools and brushes was a dead end, as they introduce innaccuracy and distortion. But then I stopped thinking about it in terms of a spiral, because that’s not really what it is: it’s entirely a construction of straight lines, after all. So what is it made of? Well, what solved it for me was viewing it as a set of radiating lines.

radiate

Each pair of lines will be guides for the peak and trough of the zigzag. The zig and the zag, if you will. One is rotated slightly from the other an arbitrary distance based on how sharp you want your zigzags to be. Take the rotate tool and alt/option-click on the bottom end of your first line. Type in an amount in degrees (four in this case) and click on ‘copy’.

We want an amount that divides nicely into 360, so the pair of lines is then rotated and copied 20 degrees around the centre, so we end up with the image above.

The next stage is ending up with zigzags that shrink smoothly towards the centre of the image. To do this, we want to end up with a polar grid of sorts (but don’t bother with Illustrator’s polar grid tool – it won’t save any time here). All we want is a set of circles that increase in size by a percentage each time.

Screen Shot 2016-06-07 at 19.19.41

Start as close to the centre as you dare – the more circles in this grid, the more work you’ll have to do. I’ve scaled this one by 110% each time. At this stage it might be worth making the whole thing into guides – you won’t need these actual lines in the spiral, they’re just here as scaffolding. Now we need to draw our zigs and zags. Make sure smart guides (ctrl + U) are turned on for this.

Screen Shot 2016-06-07 at 19.29.59

There are probably other viable patterns, but to get something like the original image it’s best to go three down, one up. Use smart guides and draw paths using the ‘intersect’ indicator to make sure you’re hitting where the guides cross. Keep going until you get to the centre of the circle (I’m cheating here by going for wider zigzags).

As a shortcut, you could just draw the one nearest the centre, then scale and copy 110% from the centre point of the guides, just as we did with the circles. Either way, once you’re done with one row, copy 20 degrees around the centre again to end up with this beauty.

Screen Shot 2016-06-07 at 19.48.18

There’s some inaccuracy at very high zoom levels that I can’t quite work out; I think it may be to do with the inherent inaccuracy of bezier curve circles, but it doesn’t affect the next step too much so I’m not going to worry about it. First up make an outer circle (or other shape) to act as a bounding area for a live paint group. Then hide your guides, give all the lines no stroke, and go nuts with fill colours.

Screen Shot 2016-06-07 at 19.56.07

What I liked most about this is that, as a problem that could be solved with a pen and compass, this obviously must be a known solution. But as someone looking at this completely fresh, it felt good to come up with that on my own through experimentation.

Slings and arrowheads

I’ve seen a few posts on the Adobe forums from time to time asking how one might ‘attach’ objects or symbols to path endpoints (or anchor points in general), so that you might have elements that move as you move points around.

arrowheads1

Like a lot of things in Illustrator, this isn’t really possible, but there are a number of odd ways you can accomplish things that might do the job well enough. I had a need to do something similar at work; producing a sort of annotation symbol for use by people who didn’t really have any Illustrator expertise, so it needed to be as simple as possible to manipulate. I went with custom arrowheads.

arrowheads2

I’ve got the appearance and stroke open there so you can see what’s going on. If you don’t know how to create your own arrowheads, Adobe provide the bare minimum of information here. There’s more info in the arrowheads file itself, but nevertheless there are a bunch of odd pitfalls and ways of going wrong, exacerbated as I was a CC user making an arrowheads file for CS5 users too. But after a bit of a struggle I had a nice bunch they could use, with some caveats. Ideally I didn’t want anyone moving the leader line from the horizontal, as this would happen:

arrowheads3

…and having symbols flying off at different angles just looked kind of unprofessional. So I was left trying to figure out a way of having a symbol stuck to one end of a path that maintained its rotation relative to the page, rather than the path. The clue to what I did is in the wording there. It’s a silly method, but within the confines of the page we use it works perfectly. Scatter brushes!

arrowheads4

Note the spacing: 9999%. This means you’ll see one instance of the brush every 100 times the maximum dimension of the brush object. Over half a metre in this case! More than we’ll ever need in a document 100 mm wide. The other key option is to have the rotation set relative to the page, so it won’t rotate as you change the angle of the path. This means although this is rather an awkward solution, the users shouldn’t see any difference, except the style now works as they wanted. Here’s the new path with its appearance:

arrowheads5

The top stroke has the scatter brush applied, the next has the arrowhead at the other end and the red swatch. The next two define the white backing to the stroke and the arrowheads respectively.