Showing posts with label inkscape. Show all posts
Showing posts with label inkscape. Show all posts

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.

Recipe

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

Sunday, January 15, 2012

Duplicate Inkscape Layer Across Multiple SVGs

Note: I use Vim for this tutorial. Possibly, your editor or your favourite scripting language could serve as a suitable alternative.

The goal of this tutorial is to show one way of inserting a new layer into many SVG files. The SVG with the layer we want to copy is called the source layer in this tutorial. The term target layer is used here to identify the layer in the destination SVGs under which we want to paste the source layer.

Here is my source SVG containing the source layer, called "red star":

 

Here are two destination SVGs:



In this workflow, we've added a layer with a new object to one of several similar designs. Rather than duplicate that effort across all three SVG files, it would be better to duplicate the layer instead.  Let's do that.

Open the SVG with your source layer in Vim and search for "red star"

  /red star

Save the whole <g ...> tag in register a:

  "ayat

Edit your first target SVG:

  :e vi.svg

Find the target layer. In my files, that's the layer called text:

  /label.*text

Move to the beginning of the <g ...> tag:

  vato<esc>

Paste the star:

  "aP

Save:

  :w

And repeat for all destination SVGs.

Of course, you could open many files at once with:

  :args *.svg

and then:

  :wn

To save and move to the next file.

Seeing the Results

Open the files again in Inkscape (or use File | Revert if they were already open in a session) and you should see your source layer dutifully copied to each of the destination files.



This is a kludge. It is. Hand editing XML files is always a kludge.  This could be better done with a script, possibly an Inkscape plugin.  I might even write it. About time I revisited that corner of the world again. I'll let you know if I do. Until then... hack away on those XML files by hand. :-/

Thursday, January 12, 2012

Concentric Circles

How I tamed the Tiled Clones tool in Inkscape

The goal of this tutorial is to show you how to create a set of concentric circles with uniform line width using the Create Tiled Clones tool in Inkscape.

First, create your original object in Inkscape. In this tutorial, I'm using a plain circle.


Make sure your object is selected and open the Create Tiled Clones dialog window (Edit | Clone | Create Tiled Clones...)


For this tutorial, I am creating 9 concentric circles. We don't want any of the preset clone styles, so just choose P1: simple translation from the dropdown. Set your rows,columns to be 1,9. Make sure the Use saved size and position of the tile checkbox is off (unchecked). The settings on the Symmetry tab should look something like this:


On the Shift tab, make sure all Shift X and Shift Y offsets are zeroed. Keep the Exponents at 1, and check the per column Exclude tile checkbox:


I wanted neat, even, concentric circles, so I set my per column Scale X and Scale Y values to 100% each. Again use an Exponent of 1:


Leave everything zeroed on the Rotation, Blur & opacity, Color and Trace tabs. Or not, if you want to mess with those settings. But in this tutorial, we'll leave them zeroed.

Click the Create button and you should get concentric clones:


Notice how the successive circles at this stage are evenly spaced apart (good), but have increasing line widths (bad). I haven't found a way to tell Inkscape not to do this for me, even when I try to turn off the Scale Stroke Widths Proportionately affect. :-/ If you know how to do this, I'd love to learn.

So, the rest of this tutorial will focus on making all stroke widths equal.

Select all of the circles:


Unlink them (Edit | Clone | Unlink Clone) or Alt+Shift+D:


Group them (Object | Group) or Ctrl+G:


Open the Fill and Stroke dialog (Object | Fill and Stroke...) or Ctrl+Shift+F:


Set whatever Stroke Style you want. I'm using a plain solid line with width 1px here:


And the final result:


There are many more weird and wonderful things you can do with the clone tool, and I'm only starting to fathom its depths. Until this morning, this tool scared me because nearly every time I tried to use it I would end up with many copies of something I didn't want. Finally with some experimentation this morning, I have tamed the beast! Well... found out where he lives and what he likes to drink, at least. If I have made a flub, omitted something crucial or just plain messed up, let me know.