3
{ This program draws a fractal snowflake pattern. I think I got it out
4
of some magazine years ago. It was written, as I remember it, for the
5
PC in BASIC, which I converted to AmigaBASIC. I have long since
6
forgotten the details of how it worked, so I could not give the
7
variables meaningful names. To the original author, by the way, goes
8
the credit for those names. Invoke the program with the line "Snow
9
<level>", where <level> is a digit between 1 and 6. In order to get a
10
feel for what's going on, try running the levels in order. Level 6
11
takes a long time, and frankly doesn't look as good as level 5. }
14
Translated to fpc pascal from pcq pascal.
15
Updated the source to the new style. Will
16
now also open a screen.
19
Reworked to use systemvartags.
22
nils.sjoholm@mailbox.swipnet.se
26
uses exec,intuition,graphics,utility,systemvartags;
31
dx : array [0..11] of real;
32
dy : array [0..11] of real;
33
sd : array [0..6] of Longint;
34
rd : array [0..6] of Longint;
35
sn : array [0..6] of Longint;
36
ln : array [0..6] of real;
44
d, ns, i, j : Longint;
49
pens : array [0..0] of integer = (not 0);
53
writeln('Usage: Snow <level>');
54
writeln(' where <level> is between 1 and 6');
58
procedure CleanUp(why : string; err : longint);
60
if assigned(w) then CloseWindow(w);
61
if assigned(s) then CloseScreen(s);
62
if why <> '' then writeln(why);
66
Function readcycles: Longint;
70
if paramcount <> 1 then usage;
71
cycles := ord(paramstr(1)[1]) - ord('0');
72
if (cycles > 6) or (cycles < 1) then
99
for n := 6 to 11 do begin
104
for n := 0 to 5 do begin
105
dx[n] := -(dx[n + 6]);
106
dy[n] := -(dy[n + 6]);
117
s := OpenScreenTags(nil, [SA_Pens, @pens,
119
SA_DisplayID, HIRES_KEY,
120
SA_Title, 'Simple Fractal SnowFlakes',
123
if s = NIL then CleanUp('No screen',20);
125
w := OpenWindowTags(nil, [
126
WA_IDCMP, IDCMP_CLOSEWINDOW,
128
WA_Top, s^.BarHeight +1,
130
WA_Height, s^.Height - (s^.BarHeight + 1),
131
WA_DepthGadget, ltrue,
133
WA_CloseGadget, ltrue,
134
WA_ReportMouse, ltrue,
135
WA_SmartRefresh, ltrue,
137
WA_Title, 'Close the Window to Quit',
141
if w = nil then CleanUp('No window',20);
148
Move(rp, trunc(x), trunc(y));
155
for n := 1 to nc do begin
161
d := (d + 12 - rd[i]) mod 12
163
d := (d + rd[i]) mod 12;
166
x := x + 1.33 * l * dx[d];
167
y := y - 0.5 * l * dy[d];
169
Draw(rp, trunc(x), trunc(y));
170
sn[nc] := sn[nc] + 1;
172
while (n >= 1) and (sn[n] = 7) do begin
174
sn[n - 1] := sn[n - 1] + 1;
178
m := WaitPort(w^.UserPort);
181
m := GetMsg(w^.UserPort);