mirror of
https://git.sr.ht/~rabbits/macintosh_cookbook
synced 2024-12-29 08:29:18 +00:00
57 lines
863 B
ObjectPascal
57 lines
863 B
ObjectPascal
|
program ExampleSpiral;
|
||
|
|
||
|
{Program to build spiral pattern, using}
|
||
|
{relative line routine in a recursive loop}
|
||
|
|
||
|
var
|
||
|
sign: Integer;
|
||
|
|
||
|
procedure Spiral (x, y, sign: integer);
|
||
|
|
||
|
{Procedure to spiral into limbo}
|
||
|
|
||
|
var
|
||
|
temp: Integer;
|
||
|
|
||
|
begin
|
||
|
|
||
|
sign := (-1) * sign;
|
||
|
if (abs(x) < 10) and (abs(y) < 10) then
|
||
|
halt {Done recurring - ground case}
|
||
|
else {Spiral still sizable}
|
||
|
begin
|
||
|
|
||
|
line(x, y); {Plot relative line}
|
||
|
|
||
|
{Reduce magnitude of relative move by 5 pixels}
|
||
|
|
||
|
if abs(x) > abs(y) then
|
||
|
x := x - (x div abs(x) * 5)
|
||
|
else
|
||
|
y := y - (y div abs(y) * 5);
|
||
|
|
||
|
{Exchange x<--> y}
|
||
|
|
||
|
temp := x;
|
||
|
x := y;
|
||
|
y := temp;
|
||
|
|
||
|
{On even calls, change sign}
|
||
|
|
||
|
x := sign * x;
|
||
|
y := sign * y;
|
||
|
Spiral(x, y, sign); {Recur}
|
||
|
end;
|
||
|
|
||
|
end;
|
||
|
|
||
|
begin
|
||
|
|
||
|
ShowDrawing;
|
||
|
|
||
|
sign := 1;
|
||
|
PenSize(9, 9);
|
||
|
MoveTo(20, 20);
|
||
|
Spiral(200, 0, -1);
|
||
|
|
||
|
end.
|