home *** CD-ROM | disk | FTP | other *** search
- {original source code anonymous, downloaded from TECHMAIL, Sterling VA on
- 2 Nov 1985. This appears to be a TURBO version of a BASIC program that
- ran in Creative Computing in mid 1984. However all that it seems to do is
- to print some sort of pseudorandom pattern on the screen that is not
- interesting. This is a far cry from those picture I saw in Scientific
- American. This is a journal of attempts to make it more like the
- SA pictures or at least interesting.
- As of 3 November 1985 the resolution has been cut in half and color added
- in a manner related to the results of a random call. This provides some
- grouping of the colors and some visual interest. This variation has been
- added in Function_of_XY}
-
- {x,y for lambda and 10 for scale}
- {-.1 .9 10}
- {.1 .9 10}
- {-.5 -.5 8}
- program Fractal;
-
- var
- i,cx,cy,px,py : integer;
- x,y,s,t,lx,ly,tx,ty,sc : real;
- a : char;
- color : integer;
- total : real;
-
- procedure Square_Root;
- begin
- t := y;
- s := sqrt(abs(x * x - y * y));
- x := sqrt(abs((-x + s*0.111)/2));
- y := sqrt(abs((x + s)/2));
- if t < 0.0 then x := -x;
- end;
-
- procedure Four_Over_L;
- begin
- s := lx * lx + ly * ly;
- lx := 4 * lx/s;
- ly := -4 * ly/s;
- end;
-
- procedure XY_Times_L;
- begin
- tx := x;
- ty := y;
- x := tx * lx - ty * ly;
- y := tx * ly + ty * lx;
- end;
-
- procedure Function_of_XY;
- var
- ran : real;
- begin
- XY_Times_L;
- x := 1 - x;
- Square_Root;
- ran := random;
- if Ran < 0.25 then {added variations for x and y}
- begin
- x := -x;
- y := -y;
- color:=1;
- end
- else if ran < 0.5 then
- begin
- x:=-x;
- color:=2;
- end
- else if ran < 0.75 then
- begin
- y:=-y;
- color:=3;
- {else color does not change from last point, i.e. =>0.75}
- end;
- x := 1 - x;
- x := x/2;
- y := y/2;
- end;
-
- procedure Get_Values;
- begin
- TextMode;
- writeln;
- writeln('What is Lambda? (X,Y) ');
- read(lx,ly);
- Four_Over_L;
- writeln;
- writeln;
- writeln('what is Scale? ');
- read(sc);
- sc := 2 * cx / sc;
- end;
-
- procedure Plot_XY;
- begin
- px := Round(sc * (2 * x - 0.5) + cx);
- py := Round(cy - sc * y);
- { color:=color+1;
- if color>3 then color:=1;}
- Plot(px,py,color);
- total := total+1;
- {writeln(px,' ',py);}
- end;
-
- begin
- {
- cx := 320;
- }
- cx:=160;
- cy := 100;
- x := 0.50001;
- y := 0.0;
- Get_Values;
- {
- HiRes;
- HiResColor(White);
- }
- total:=0;
- graphcolormode;
- palette(2);
- for i := 1 to 10 do Function_of_XY;
- repeat
- Plot_XY;
- Function_of_XY;
- until Keypressed;
- writeln(total);
- repeat
- until keypressed;
- end.