Code: Select all
startshape reptile
rule sub-reptile {
// middle
flip-reptile { rotate -180 y 173.204 x 400 }
// left
flip-reptile { }
// right
flip-reptile { x 300 }
// top
reptile { rotate 120 y 346.408 x 400 }
}
rule reptile {
side { rotate 30 }
side { y 86.602 x -50 rotate 30 }
side { rotate 90 }
side { rotate 90 x -100 }
side { rotate 90 x -200 }
side { rotate -30 x -300 }
side { rotate -30 x -150 y 86.602 }
side { rotate 90 x -150 y 86.602 }
sub-reptile { size 0.5 x -300 }
}
rule sub-flip-reptile {
// middle
reptile { rotate 180 x -100 y 173.204 }
// left
reptile { }
// right
reptile { x 300 }
// top
flip-reptile { rotate -120 y 346.408 x -100 }
}
rule flip-reptile {
side { rotate -30 }
side { y 86.602 x 50 rotate -30 }
side { rotate -90 }
side { rotate -90 x 100 }
side { rotate -90 x 200 }
side { rotate 30 x 300 }
side { rotate 30 x 150 y 86.602 }
side { rotate -90 x 150 y 86.602 }
sub-flip-reptile { size 0.5 x 150 }
}
rule side 6 {
plain-side { }
}
// uncomment the CIRCLE rules to get cool random dots added
rule side 1 {
plain-side { }
//CIRCLE { x 0 size 10 }
}
rule side 1 {
plain-side { }
//CIRCLE { x 50 size 10 }
}
rule side 1 {
plain-side { }
//CIRCLE { x 100 size 10 }
}
rule plain-side {
line { y 0 }
line { y 10 }
line { y 20 }
line { y 30 }
line { y 40 }
line { y 50 }
line { y 60 }
line { y 70 }
line { y 80 }
line { y 90 }
}
rule line {
SQUARE { y 0 }
SQUARE { y 1 }
SQUARE { y 2 }
SQUARE { y 3 }
SQUARE { y 4 }
SQUARE { y 5 }
SQUARE { y 6 }
SQUARE { y 7 }
SQUARE { y 8 }
SQUARE { y 9 }
}
rep-tiles: http://mathworld.wolfram.com/Rep-Tile.html
this would be a lot cleaner with: 1) a 'flip' directive, 2) a line primitive and 3) some way to say "if we're at/near the shape limit, switch to using this version of rule $foo, rather than the other versions". with rep-n-tiles, the outlines of the smallest versions of the rep-n-tile 'merge' to produce the outline of the largest ones. so only the last iteration of rules actually needs to draw any lines. (i hope that is clear.)