PROGRAM dragon; { DRAGON FRACTAL - by Tim Meekins - April 7, 1986 } { Requires DIABLO.LIB for graphics routines. } { Draws a "dragon" fractal curve. Uses Diablo Library for graphics routines } { Loosely adapted from IBM Fractal Graphics from COMPUTE! March 1986, p 80 } { By Michael Galway - Napean, Ontario, K2H 5X5 } { Unfortunately, this based to much on the program from COMPUTE! Fractals } { are intended to be recursive and this isn't because the original BASIC } { version wasn't. This program was slapped together as a demo. } VAR sn : ARRAY[0..14] OF byte; nc,c,d : byte; x,y,l : integer; done,correct : boolean; {$i diablo.lib } BEGIN done := false; WHILE NOT done DO BEGIN correct := false; WHILE NOT correct DO BEGIN write('Enter the number of cycles (1 - 8) >'); readln(nc); IF nc=0 THEN BEGIN done := true; correct := true END ELSE BEGIN nc := abs(nc); correct := (nc>=1) AND (nc<=8); IF NOT correct THEN writeln('ERROR: Cycles must be 1 - 8') END END; IF NOT done THEN BEGIN init_diablo; l := 256; FOR c := 1 TO nc DO l := l div 2; x := 200; y := 300; nc := nc * 2; plot(x,y); FOR c := 0 TO nc DO sn[c] := 0; WHILE (sn[0] = 0) AND (NOT keypressed) DO BEGIN d := 0; FOR c := 1 TO nc DO BEGIN IF sn[c-1] = sn[c] THEN d := d - 1 ELSE d := d + 1; d := (d + 8) mod 8 END; IF d = 0 THEN x := x + l + l ELSE IF d = 2 THEN y := y + l ELSE IF d = 4 THEN x := x - l - l ELSE y := y - l; drawto(x,y); sn[nc] := sn[nc] + 1; FOR c := nc DOWNTO 1 DO IF sn[c] = 2 THEN BEGIN sn[c] := 0; sn[c-1] := sn[c-1] + 1 END END END END; reset_diablo END.