! Example of tree-like fractal.
! Author: Francois Tonneau

! This is a slight modification of the recursion-tree example available on GLE
! 4.2.5. We use the GLE rotation command instead of computing coordinates
! manually.

size 8 8

set lwidth 0.03 cap round

root = 3

maxiters = 10
maxwhite = maxiters + 3

turn = 20
shrinkage = 0.56

sub fork trunk iteration
    if iteration <= maxiters then
        set color iteration/maxwhite
        rline 0 trunk
        local branch = trunk * shrinkage
        begin rotate turn
            fork branch iteration+1
        end rotate
        begin rotate -turn
            fork branch iteration+1
        end rotate
    else
        rmove 0 0.1+rnd(0.3)
        circle 0.03 fill rosybrown
    end if
end sub

amove pagewidth()/2 0

fork root iteration 1

