My study was inspired by amazing works by Pasternak
STEP 1: Basic tutorial
structuresynth.sourceforge.net…
A short tutorial explaining the basics of the software, such as shapes, rules and transformations. At this point, I was able to create a nice little box. Even 3 boxes
//Creates a huge grey box to work as base for the fractal.
//Not really needed but whatever
{z -0.1 s 5 5 0.1 color grey}box
//those 2 commands create the small red boxes
{x 0.25 y 0.25 s 0.48 0.48 0.1}box
{x -0.25 y 0.25 s 0.48 0.48 0.1}box
Here they are
STEP 2: Creating rules
While the boxes are pretty neat and I was very proud of them, something more fractal looking would be desirable. My target was to fill a big square with smaller squares following the pattern below:
This requires a bit of maths. Lets assume that the origin - (0,0) - is located in the center of the big square, and its side has length 1. The upper half of the tile is easy - we can just create 2 boxes (actually the code I posted in step 1). Now we scale them down, move them down and right, and then create another scaled down copy and move it down and left:
For the scaling and moving down, we will need two rules.
//draws the grey "base" box
{x 0 y 0 z -0.1 s 5 5 0.1 color grey}box
//executes rule 1
r1
//defines rule 1, with 7 iterations
rule r1 md 7 {
{ x 0.25 y -0.25 s 0.5 0.5 1 rz 0} r1
{ x -0.25 y -0.25 s 0.5 0.5 1 rz 0} r1
base}
//creates the base for the tile
//2 boxes
rule base {
{x 0.25 y 0.25 s 0.45 0.45 0.1}box
{x -0.25 y 0.25 s 0.45 0.45 0.1}box}
Rule Base just creates the two upper boxes. Rule 1 creates 2 copies of Rule Base, shifted down and scaled to 50%.
Also, Rule 1 is recursive and is applied not only on the Base, but also on itself.
STEP 3: Adding randomstuff
To be honest, the previous step could be made in apo too.
Anyways, I wanted to add some randomness to the square. For example, different coloured boxes
For this, I just created a second version of the Base rule, with different coloring. Structure Synth selects one of them randomly (you can set weights too):
{x 0 y 0 z -0.1 s 5 5 0.1 color grey}box
r1
rule r1 md 7 {
{ x 0.25 y -0.25 s 0.5 0.5 1 rz 0} r1
{ x -0.25 y -0.25 s 0.5 0.5 1 rz 0} r1
base}
//version 1 of base
rule base {
{x 0.25 y 0.25 s 0.45 0.45 0.1}box
{x -0.25 y 0.25 s 0.45 0.45 0.1}box}
//version 2 of base
rule base {
{x 0.25 y 0.25 s 0.45 0.45 0.1}box
{x -0.25 y 0.25 s 0.45 0.45 0.1 color white}box}
For different seeds, the code above resulted in things like:
STEP 4: Something a bit crazier
Actually, boooooring. Interesting as learning experience, but at this point the dummy here was quite eager to create something more exciting.
So I mixed up some different tiles, and added some height changes between steps:
{color white} r1
{x 0 y 0 z -0.05 s 5 5 0.1 color grey}box
rule r1 md 4 {
{ x -0.25 y 0.25 s 0.5 0.5 0.5 rz 180} r1
{ x 0.25 y -0.25 s 0.5 0.5 0.5 rz 0} r1
{ x -0.25 y -0.25 s 0.5 0.5 1.2 rz 90} r1
base}
rule r1 md 5 {
{ x -0.25 y 0.25 s 0.5 0.5 1.1 rz 0} r1
{ x 0.25 y -0.25 s 0.5 0.5 0.5 rz 90} r1
{ x -0.25 y -0.25 s 0.5 0.5 1.3 rz 90} r1
base}
rule base {
{x 0.25 y 0.25 s 0.48 0.48 0.1}box}
STEP 5: replace the boring boxes with something cool
And Finally i figured out how to replace fixed shapes - the boxes in the example above - by some random crazy things. You just make a rule (or couple) to use instead of using directly the base shape:
{color white} r1
{x 0 y 0 z -0.05 s 5 5 0.1 color grey}box
//rule 1, fills the square
rule r1 md 4{
{ x -0.25 y 0.25 s 0.5 0.5 0.75 rz 180} r1
{ x 0.25 y -0.25 s 0.5 0.5 1 rz 0} r1
{ x -0.25 y -0.25 s 0.5 0.5 1 rz 90} r1
tower}
rule r1 md 5 {
{ x -0.25 y 0.25 s 0.5 0.5 1 rz 0} r1
{ x 0.25 y -0.25 s 0.5 0.5 0.75 rz 90} r1
{ x -0.25 y -0.25 s 0.5 0.5 1 rz 90} r1
tower}
//this rule creates the spires
rule tower w 1{
{z 0.01 rz 3 s 0.8}tower
base}
rule tower w 1{
{z 0.01 rz 3 s 1.01}tower
base}
rule tower w 1{
{z 0.01 rz 3 s 1.02}tower
base}
rule tower w 1{
{z 0.01 rz 3 s 0.95}tower
base}
rule tower w 0.5{}
//baseshape for the spires
rule base {
{x 0.25 y 0.25 s 0.45 0.45 0.01 sat 0.3}box}
STEP 6: And keep learning
Still exploring the stuff now, some mazy and non fractal things as: