{ > Src.Mandel } { MANDELBROT SETS in Pascal } program Mandel(input,output,points) ; const Maxiter = 320 ; type byte = 0..255 ; var points : packed file of byte ; ptstep,blx,bly,scale : real ; i,j : integer ; function colour(cx,cy:real) : integer ; var x,y,x2,y2 : real ; n : integer ; begin n:=0 ; x:=0 ; y:=0 ; REPEAT y2:=y*y ; x2:=x*x ; y:=2*x*y+cy ; x:=x2-y2+cx ; n:=n+1 UNTIL (n = Maxiter) OR (x2+y2 >= 4.0) ; colour:=n end ; procedure writebytes (x: integer) ; begin write (points,x MOD 256, x DIV 256) end ; { MAIN PROGRAM } begin mode(0) ; rewrite (points,'ManPts') ; { write ('Bottom Left') ; readln (blx,bly) ; } blx := -1.02 ; bly := 0.28 ; { write ('Scale') ; readln (scale) ; } scale := 0.0375 ; settime (0) ; ptstep := scale/512 ; { MAIN LOOP } FOR i:=0 TO 511 do begin write(i) ; FOR j:=0 TO 256 do {TO 511 STEP 2} begin writebytes(colour(blx+i*ptstep,bly+(j+j)*ptstep)) end end ; writeln('END ',time) END.