| 1 |
|
|---|
| 2 |
Gdadin |
|---|
| 3 |
http://freaknet.org/alpt/src/gdadin |
|---|
| 4 |
GUI to Draw Algorithms Designed with Inkscape |
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
Gdadin is an Inkscape effect. It creates complex drawings from simple rules |
|---|
| 8 |
The rules are defined with an intuitive GUI based on the Copy&Paste principle. |
|---|
| 9 |
|
|---|
| 10 |
The Gdadin concept and its main design have been heavily inspired by |
|---|
| 11 |
Cfdg ( http://www.contextfreeart.org/ ), a programming language used to |
|---|
| 12 |
compose and create drawings. Almost all drawings created with Cfdg can be |
|---|
| 13 |
reproduced with Gdadin. |
|---|
| 14 |
|
|---|
| 15 |
-- |
|---|
| 16 |
0. Examples and Lessons |
|---|
| 17 |
1. General workflow |
|---|
| 18 |
2. Recursion and cycles |
|---|
| 19 |
2.1 Size rule |
|---|
| 20 |
3. Shape call parameters |
|---|
| 21 |
3.1 Recursion depth |
|---|
| 22 |
3.2 Colors |
|---|
| 23 |
4. Random shapes |
|---|
| 24 |
4.1 Random seed |
|---|
| 25 |
5. Limits |
|---|
| 26 |
6. Tips |
|---|
| 27 |
-- |
|---|
| 28 |
|
|---|
| 29 |
0. Examples and Lessons |
|---|
| 30 |
|
|---|
| 31 |
For examples look in examples/ or here: http://freaknet.org/alpt/src/gdadin/examples/ |
|---|
| 32 |
|
|---|
| 33 |
You can find video lessons here: http://freaknet.org/alpt/src/gdadin/lessons/ |
|---|
| 34 |
|
|---|
| 35 |
1. General workflow |
|---|
| 36 |
|
|---|
| 37 |
A Gdadin shape is a group of objects created with inkscape, f.e. a square, a |
|---|
| 38 |
star, text. |
|---|
| 39 |
To define a new shape: |
|---|
| 40 |
- select the objects |
|---|
| 41 |
- Use "Effects->Gdadin->Define" a new shape |
|---|
| 42 |
- The defined shape will be exactly on top of the selected objects. |
|---|
| 43 |
The shape contains a copy of the objects therefore you can freely |
|---|
| 44 |
delete the originals. |
|---|
| 45 |
|
|---|
| 46 |
Defined shapes can be copied and pasted like any other normal object. |
|---|
| 47 |
In order to edit a defined shape, you must enter inside its group: |
|---|
| 48 |
"Right click->Enter" group (and remember to exit: "Right click -> Go to Parent"). |
|---|
| 49 |
|
|---|
| 50 |
You can paste a shape A inside another shape B: |
|---|
| 51 |
- select the shape A |
|---|
| 52 |
(be sure to select its whole group and not just some single elements |
|---|
| 53 |
of the shape) |
|---|
| 54 |
- copy it |
|---|
| 55 |
- enter in the shape B (enter group) |
|---|
| 56 |
- paste |
|---|
| 57 |
- exit from the shape B |
|---|
| 58 |
|
|---|
| 59 |
NOTE: The pasted shape is just a reference to the original shape: the rendering |
|---|
| 60 |
will delete the reference and substitute it with the original. Therefore, |
|---|
| 61 |
1) if you want to modify the pasted shape you have to modify just the |
|---|
| 62 |
original one. |
|---|
| 63 |
2) you can't delete the shape if it has been referenced by another |
|---|
| 64 |
shape and you want to render it. |
|---|
| 65 |
|
|---|
| 66 |
To define a recursive shape: copy and paste the shape inside itself. In other |
|---|
| 67 |
words, |
|---|
| 68 |
- copy the shape A |
|---|
| 69 |
- enter inside the shape A |
|---|
| 70 |
- paste it |
|---|
| 71 |
- exit from the shape A |
|---|
| 72 |
|
|---|
| 73 |
Finally, select the final shapes you'd like to render and use |
|---|
| 74 |
"Effects->Gdadin->Render selected shapes". |
|---|
| 75 |
|
|---|
| 76 |
Here below we'll explain how to use cycles, color variations and random |
|---|
| 77 |
shapes. |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
2. Recursion and cycles |
|---|
| 81 |
|
|---|
| 82 |
2.1 Size rule |
|---|
| 83 |
|
|---|
| 84 |
Suppose you've defined a recursive shape A and you render it. |
|---|
| 85 |
If it definitively grows smaller, Gdadin will halt the recursion when the |
|---|
| 86 |
shape becomes too small to be seen. |
|---|
| 87 |
Example: |
|---|
| 88 |
- draw a rectangle, select it and define a new shape. |
|---|
| 89 |
- copy the shape, enter inside the shape, paste it |
|---|
| 90 |
- shrink it |
|---|
| 91 |
- go to parent, select the shape, render it |
|---|
| 92 |
|
|---|
| 93 |
When it isn't possible to apply the size rule you have to manually set a |
|---|
| 94 |
limit. The render dialog offers you the "Maximum number of shapes" option. |
|---|
| 95 |
It is the absolute maximum number of shape substitution that will be performed |
|---|
| 96 |
during the rendering. |
|---|
| 97 |
This option is useful to experiment with complex drawings: with a low number |
|---|
| 98 |
you can render the drawing quickly, hit CTRL+z, and return to edit. |
|---|
| 99 |
|
|---|
| 100 |
3. Shape call parameters |
|---|
| 101 |
|
|---|
| 102 |
3.1 Recursion depth |
|---|
| 103 |
|
|---|
| 104 |
The recursion depth parameter can be assigned to a referenced/pasted shape, |
|---|
| 105 |
generally a recursive one. It specifies how many child shapes of the referenced |
|---|
| 106 |
shape will be created. This is useful to create cycles. |
|---|
| 107 |
For example: |
|---|
| 108 |
- Let's create a tower using the size rule: |
|---|
| 109 |
- draw a rectangle, select it |
|---|
| 110 |
- define new shape, copy the shape, enter inside the shape, paste |
|---|
| 111 |
- shrink the pasted shape and move it on top of the big |
|---|
| 112 |
rectangle |
|---|
| 113 |
- go to parent |
|---|
| 114 |
- Now we'll rotate the tower three times: |
|---|
| 115 |
- select the tower shape, copy it |
|---|
| 116 |
- enter in the tower shape, paste in place (CTRL+ALT+v) |
|---|
| 117 |
- rotate it |
|---|
| 118 |
- keep it selected, and open the dialog |
|---|
| 119 |
"Effects->Gdadin->Set the shape call parameter" |
|---|
| 120 |
- Set "Recursion depth" to 2. |
|---|
| 121 |
- go to parent |
|---|
| 122 |
- Let's render it (without any limit, i.e. "maximum number of shape" |
|---|
| 123 |
set to 0) |
|---|
| 124 |
- You should get the tower rotated three times. |
|---|
| 125 |
|
|---|
| 126 |
You've just seen how to create a cycle. |
|---|
| 127 |
|
|---|
| 128 |
3.2 Colors |
|---|
| 129 |
|
|---|
| 130 |
These parameters define how the color of a referenced shape will change over |
|---|
| 131 |
time, i.e. the new color that its same child shape will have. |
|---|
| 132 |
|
|---|
| 133 |
The parameters are Hue, Saturation, Brightness, Opacity (If you don't know |
|---|
| 134 |
what they are, just draw an object, hit CTRL+SHIFT+f "Fill and Stroke", go to the |
|---|
| 135 |
HSL tab, and experiment) |
|---|
| 136 |
|
|---|
| 137 |
We'll describe just the Hue parameter: |
|---|
| 138 |
|
|---|
| 139 |
- The "Relative hue change" is an integer in the range [-1000, 1000]. |
|---|
| 140 |
It is used to calculate the new Hue of the child of the referenced |
|---|
| 141 |
shape: |
|---|
| 142 |
newhue = referenced_shape_hue + relative_hue_change/1000.0 |
|---|
| 143 |
|
|---|
| 144 |
Note: relative_hue_change can be also negative. |
|---|
| 145 |
Note: the Hue is a real parameter in the range [0, 1]. Thus, |
|---|
| 146 |
relative_hue_change = 1 is a very little increment |
|---|
| 147 |
relative_hue_change = 10 is a smooth, gradual increment |
|---|
| 148 |
relative_hue_change = 100 is a steep increment |
|---|
| 149 |
|
|---|
| 150 |
- "Maximum hue value" sets a ceil for the newhue: |
|---|
| 151 |
|
|---|
| 152 |
if newhue >= maximum_hue_value/1000.0 then |
|---|
| 153 |
newhue = maximum_hue_value/1000.0 |
|---|
| 154 |
|
|---|
| 155 |
In other words, when the hue reaches the maximum_hue_value, the |
|---|
| 156 |
variation stops: the new childs will have the same hue. |
|---|
| 157 |
|
|---|
| 158 |
You can disable it by choosing a negative value, f.e. -1. |
|---|
| 159 |
This is the default. |
|---|
| 160 |
In this case, the hue will change cyclically, f.e. |
|---|
| 161 |
|
|---|
| 162 |
initial_hue = 312, relative_hue_change = 10 |
|---|
| 163 |
312 322 332 ... 982 992 2 12 22 ... |
|---|
| 164 |
|
|---|
| 165 |
initial_hue = 312, relative_hue_change = -10 |
|---|
| 166 |
312 302 292 ... 32 22 12 2 992 982 ... |
|---|
| 167 |
|
|---|
| 168 |
- "Minimum hue value". The same as before, but sets a floor instead. |
|---|
| 169 |
|
|---|
| 170 |
4. Random shapes |
|---|
| 171 |
|
|---|
| 172 |
When you define a new shape, you can set two (optional) parameters: |
|---|
| 173 |
1) The shape name |
|---|
| 174 |
2) The shape weight |
|---|
| 175 |
Suppose now that you define more than one shape with the same name and you |
|---|
| 176 |
reference, i.e. copy and paste, at least one of them. |
|---|
| 177 |
In this case, during the rendering, Gdadin will resolve the reference by |
|---|
| 178 |
choosing randomly one of the shapes with the same name. |
|---|
| 179 |
|
|---|
| 180 |
The weight specifies how much probability has each the shape to be chosen. |
|---|
| 181 |
|
|---|
| 182 |
Hint: random shapes are useful to give an organic feel to the drawing. |
|---|
| 183 |
|
|---|
| 184 |
4.1 Random seed |
|---|
| 185 |
|
|---|
| 186 |
Naturally, each time you render a random shape, you'll get a different |
|---|
| 187 |
results. |
|---|
| 188 |
In order to fix a unique result, you can set an arbitrary alphanumeric string |
|---|
| 189 |
in the "Random seed" parameter of the render dialog. |
|---|
| 190 |
|
|---|
| 191 |
You can check what seed has been used during the rendering by looking in the |
|---|
| 192 |
XML editor: |
|---|
| 193 |
- select the final rendered shape |
|---|
| 194 |
- hit CTRL+SHIFT+x |
|---|
| 195 |
- read the "inkscape:seed" attribute. |
|---|
| 196 |
This procedure is useful if you want to reproduce a same random rendering. |
|---|
| 197 |
|
|---|
| 198 |
5. Limits |
|---|
| 199 |
|
|---|
| 200 |
It's slow: very complicated shapes, with more than thousand shapes can take a |
|---|
| 201 |
while to render and can easily fill up memory. |
|---|
| 202 |
|
|---|
| 203 |
6. Tips |
|---|
| 204 |
|
|---|
| 205 |
1) use a low Max Number of Shapes to test the drawing |
|---|
| 206 |
|
|---|
| 207 |
2) save before rendering |
|---|
| 208 |
|
|---|
| 209 |
3) After a long rendering: |
|---|
| 210 |
- don't touch anything |
|---|
| 211 |
- export to bitmap (SHIFT+CTRL+e) as soon as possible. |
|---|
| 212 |
As export area choose "Page", because after a rendering |
|---|
| 213 |
Gdadin will automatically resize the page to contain the |
|---|
| 214 |
final drawing. |
|---|
| 215 |
- you can export to bitmap by commandline (it's better): |
|---|
| 216 |
- save the rendering to file.svg |
|---|
| 217 |
- inkscape file.svg -C -e out.png -w 640 -h 480 |
|---|
| 218 |
|
|---|
| 219 |
4) Learn to use the XML editor |
|---|
| 220 |
|
|---|
| 221 |
7. Authors |
|---|
| 222 |
|
|---|
| 223 |
Andrea Lo Pumo aka AlpT (@freaknet.org) |
|---|
| 224 |
|
|---|