Tuesday, January 17, 2012

Conical Gradients in Inkscape

Let's Draw a Colour Wheel in Inkscape

Inkscape doesn't yet (circa Jan 2012) support conical gradients, but it is getting some sexy love in this area, hopefully soon. Until then, this article shows one way to do it. Look here for an alternative.


1. Create a circle and unset its colour.

Click the big question mark ( ? ) to unset the selected object's colour:

2. Duplicate the circle with ctrl-d (Edit | Duplicate), move it aside and using the Circle tool (F5), modify its arc to be (360 / 255) 1.4117 degrees. The arc End textbox will show 1.4112 but it holds the higher precision number internally, I believe.

3. Move the rotation point of the circle to the top left hand corner.  Use the select and transform tool (F1) and click the arc twice (not double-click) to enable rotation mode. Drag the cross at the centre of the arc to the top left hand corner.

4. Open the Clones dialog (Edit | Clone | Create Tiled Clones...)

Symmetry Tab:

5. Choose P1: simple translation and set the  Rows, columns to 1, 255

Shift Tab:

6. Check the per column Exclude tile box.

Scale Tab: No scale

Rotation Tab:

7. Set the per column rotation to 1.4117 degrees. It will show you that it's only 1.4 degrees, but it uses more precision behind the scenes, apparently.

Blur & Opacity Tab: No Blur or fade.

Color Tab:

8. Set the per column Hue percentage to (100 / 255) 0.4 %.  (Percent seems to be a weird unit for this setting.) The formula of
100 / 255 is percentage-points / hue-points.

9. Click the coloured rectangle beside the Initial color label and set H, S, L, A to 0, 255, 128, 255.

Trace Tab: No Trace.

10. Click the Create button and you should see:

Notice the spiral artefacts around the edges and particularly along the vertical line between dark blue and purple. We will group and blur these cloned circle segments (arcs) to remove that distortion.

If you forgot to set the rotation point in step 3, you will instead see:

Use ctrl-z to undo and go back and do step 3.

11. Using the select and rotation tool (F1), draw a box around the whole colour-wheel to select all of the clones. Use ctrl-g to group them.

12. Using the blur setting on the Fill and Stroke dialog (ctrl-shift-f), set the blur to 2.

Which results in:

If you're happy with that then you can stop here, but if you would like a crisp edge to your colour wheel instead of the fuzz the blur created then we need to clip it with the black circle.

13. Select the black circle and make sure it is the top-most object on the layer by pressing the Home key (Object | Raise to top).

14. With the black circle still selected, shift+click the grouped colour wheel and open the Align and Distribute dialog (with ctrl+shift+a or Object | Align and Distribute) and click the Center on vertical axis button and then the Center on horizontal axis button.

Once the two are aligned, you can just see the blurred colours beneath the black circle:

15. Clip the colour wheel with the black circle by choosing Object | Clip | set.

Done! And your colour wheel should look like this:

Not too shabby. Enjoy. :-)