PostScript Quadtree Grammars

art fractal ps

Quadtree Grammars with PostScript .

/rect {
    1 dict begin
    /size exch def
    newpath
    0 0 moveto
    size 0 rlineto
    0 size rlineto
    size neg 0 rlineto
    closepath
    fill
    end
} def

/quadtree {
    2 dict begin

    /size exch def
    /half size 2 div def

    size 1 eq {
        0 setgray
        size rect
    } {
        half quadtree

        gsave
        0 half translate
        1 setgray
        half rect
        grestore

        gsave
        half 0 translate
        half quadtree
        grestore

        gsave
        half half translate
        half quadtree
        grestore
    } ifelse
    end
} def

1024 quadtree
showpage
quadtree.png

If you have an idea how this page could be improved or a comment send me a mail.