Category : Modula II Source Code
Archive   : LINEDRAW.ZIP
Filename : SIERPIN.MOD

 
Output of file : SIERPIN.MOD contained in archive : LINEDRAW.ZIP
MODULE Sierpin;

(* Adapted from the code listings in the April 1988 issue of Dr. Dobbs
Journal of Software Tools. The article was the Structed Programming
Column by Kent Porter in which he developed an implementation of Dr.
Writh's line drawing module. This FST adaptation of the module by
Larry Maturo, 12209 Arrowwood Drive, Austin, Texas 78727. *)


FROM InOut IMPORT Read;
FROM LineDraw IMPORT width, height, Px, Py, clear, line, text;

CONST SquareSize = 512;

VAR i, h, xO, yO : CARDINAL;
ch : CHAR;


PROCEDURE A(k : CARDINAL);
BEGIN
IF (k > 0) THEN
A(k-1); line(7,h); B(k-1); line(0,2*h);
D(k-1); line(1,h); A(k-1);
END;
END A;

PROCEDURE B(k : CARDINAL);
BEGIN
IF (k > 0) THEN
B(k-1); line(5,h); C(k-1); line(6,2*h);
A(k-1); line(7,h); B(k-1);
END;
END B;

PROCEDURE C(k : CARDINAL);
BEGIN
IF (k > 0) THEN
C(k-1); line(3,h); D(k-1); line(4,2*h);
B(k-1); line(5,h); C(k-1);
END;
END C;

PROCEDURE D(k : CARDINAL);
BEGIN
IF (k > 0) THEN
D(k-1); line(1,h); A(k-1); line(2,2*h);
C(k-1); line(3,h); D(k-1);
END;
END D;

BEGIN
clear;
i := 0;
h := SquareSize DIV 4;
xO := CARDINAL(width) DIV 2;
yO := CARDINAL(height) DIV 2 + h;
REPEAT
i := i + 1;
xO := xO - h;
h := h DIV 2;
yO := yO + h;
Px := xO;
Py := yO;
A(i); line(7,h); B(i); line(5,h);
C(i); line(3,h); D(i); line(1,h);
UNTIL (i = 4);
Read(ch);
text;
END Sierpin.


  3 Responses to “Category : Modula II Source Code
Archive   : LINEDRAW.ZIP
Filename : SIERPIN.MOD

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/