home *** CD-ROM | disk | FTP | other *** search
- ! Space filling curve, by David Hilbert
- !
- SET COLOR MIX(0) .3,.3,.3
-
- SET MODE "graphics"
- ASK PIXELS px,py
- SET WINDOW 0,px-1,0,py-1 ! make pixels work nicely
- LET xc = 2^(Int(Log2(px)))
- LET yc = 2^(Int(Log2(py)))
- LET step = Min(xc,yc)/2
- LET xbase = (px/2)-step
- LET ybase = (py/2)-step ! center the picture
-
- DO while step > 2
- LET x = xbase + step/2
- LET y = ybase + step/2
- LET level = level + 1
- IF end data then RESTORE
- READ color$
- SET COLOR color$
- CALL hilbert (0,step,step,0,level)
- PLOT x,y
- LET step = step / 2
- LOOP
-
- DATA magenta,white,cyan
-
- SUB draw (xs, ys)
- PLOT x,y;
- LET x = x + xs
- LET y = y + ys
- END SUB
-
- SUB hilbert (xs, ys, x2, y2, lev)
- IF lev = 0 then EXIT SUB
- CALL hilbert (x2, y2, xs, ys, lev-1)
- CALL draw (xs, ys)
- CALL hilbert (xs,ys,x2,y2,lev-1)
- CALL draw (x2,y2)
- CALL hilbert (xs,ys,x2,y2,lev-1)
- CALL draw (-xs,-ys)
- CALL hilbert (-x2,-y2,-xs,-ys,lev-1)
- END SUB
-
- END
-