The gallery illustrates both Curly Logo pictures and, to some extent, programming techniques. Click on a picture to see it drawn in Curly Logo for real.
cs setpc "#a94 pu bk 100 pd setpw 14 repeat 7 [ fd 200 rt 360 * 1.5 / 7 fd 80 rt 360 * 1.5 / 7 ]
A sort of abstract Samanid Mancala. Note the {7/3} symmetry;
it arises from the fact that the total turn in each repetition
is 360 * 3 / 7 (consisting of two turns of 360 * 1.5 / 7 each). Also
note the use of HTML style colour triples: setpc "#a94
.
to ldragon size level ifelse level = 0 [fd size] [ldragon size level - 1 lt 90 rdragon size level - 1] end to rdragon size level ifelse level = 0 [fd size] [ldragon size level - 1 rt 90 rdragon size level - 1] end cs setpw 1 pu fd 0.5 rt 90 fd 0.5 pd ldragon 2 13
The code is adapted from [TG] (p93). The early versions of Curly Logo do not have any explicit way to return from a procedure, hence having to use the slightly awkward two-branch ifelse. There is also no way to split lists onto more than one line, hence the awkwardly long lines. Note the sequence of half-steps just before the dragon is drawn, this places the turtle at the centre of a pixel which means that the 1 pixel wide lines get drawn exactly.
Earlier versions of Curly Logo had
no real predicates, so used Iverson's
Convention instead of level = 0
; faster but less clear.
My friend Dr Adam Chalcraft kindly contributed this to the gallery.
Warning: May be slow on old machines or Firefox (it takes about 5 seconds on my 2006 era MacBook using Safari, but over 1 minute using Firefox).
to dart x pd lt 36 fd x rt 144 fd x * 0.618033988 lt 36 fd x * 0.618033988 rt 144 fd x rt 144 end to kite x pd lt 36 fd x rt 108 fd x * 0.618033988 rt 36 fd x * 0.618033988 rt 108 fd x rt 144 end to dartn n x ifelse n = 0 [dart x] [kiten n - 1 x * 0.618033988 lt 144 pu bk x dartn n - 1 x * 0.618033988 pu fd x rt 144] end to lkiten n x lt 36 pu fd x rt 144 kiten n x * 0.618033988 lt 144 pu bk x rt 36 end to rkiten n x rt 36 pu fd x lt 144 kiten n x * 0.618033988 rt 144 pu bk x lt 36 end to kiten n x ifelse n = 0 [kite x] [lt 36 dartn n - 1 x * 0.618033988 rt 36 lkiten n - 1 x rkiten n - 1 x] end home pu rt 90 fd 250 lt 90 bk 1500 dartn 9 3000
It's an implementation of the aperiodic tiling documented by Penrose.
Adam's code exposed a bug in Curly Logo which turned out to be because I was using SVG to implement some geometrical calculations; SVG implementations use 32-bit floats, doing the calculations in 64-bit doubles fixed the problems.
to star l repeat 5 [ fd l rt 144 ] end to rainbow l repeat 7 [ setpw 30 - 4 * repcount setpc repcount repeat 1 l ] end rt 18 rainbow [ star 120 ]
This shows several techniques. The star procedure draws
a self-intersecting polygon, and shows a simple use of procedures with
parameters. The rainbow procedure is higher-order, it
takes a list as an argument and repeatedly runs it. rainbow
alters the pen width and pen colour in order to created its orange paint
on top of red paint effect. Note the way rainbow uses
repeat 1 l
to run the list l; this is because
its early version of Curly Logo doesn't provide a more direct way to do
that.
to spike l lt 90 pd fd l pu bk l rt 90 end to cosl angle setpc "black spike 180 / pi * cos angle end to sinl angle setpc "red spike 180 / pi * sin angle end cs setpw 1 pu rt 90 fd 0.5 repeat 360 [cosl repcount sinl repcount fd 1]
Like Dragon this also uses sub-pixel positioning to get the correct rendering. Note that trigonometry functions act on degrees.
to inspin side angle inc n repeat n [ fd side rt angle + inc * repcount ] end cs inspin 2 2 pi 22222
This one takes far too long to run, so I haven't made the picture a runnable link. inspin is the bounded running time version of INSPI from [TG] (Curly Logo currently has no way to stop the execution of procedures so "infinite-loop" procedures are a Bad Idea). Note that if the 3rd argument, inc, to inspin is rational then the resulting figure is either like a regular polygon, or like a straight line. pi is irrational, but in the world of floating point arithmetic on computers there are only rational numbers and rounding error.