home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
ega
/
egatest.arc
/
DRAWPOLY.MOD
< prev
next >
Wrap
Text File
|
1986-12-23
|
2KB
|
58 lines
IMPLEMENTATION MODULE DrawPoly;
(*
Title : DrawPoly.MOD -- Draw lines and boxes
LastEdit: July 22, 1986
Author : John T. Cockerham, M.D.
System : LOGITECH MODULA-2/86
*)
FROM LowEGA IMPORT DrawPoint;
FROM PointLib IMPORT Point;
PROCEDURE DrawLine(p1, p2 : Point; color : CARDINAL);
(* Brensheman's Algorthim for drawing a line from
p1 to p2. *)
VAR deltax, deltay, xup, yup, supx, supy,
temp, corrs, corrd, direction, maxdim, i : INTEGER;
a : Point;
BEGIN
xup := 1; yup := 1;
deltax := p2.x-p1.x; deltay := p2.y-p1.y;
IF deltax < 0 THEN xup := -1; deltax := -deltax; END;
IF deltay < 0 THEN yup := -1; deltay := -deltay; END;
supx := xup; supy := yup; maxdim := deltax;
IF deltax < deltay THEN
maxdim := deltay; supx := 0;
temp := deltax; deltax := deltay;
deltay := temp;
ELSE
supy := 0;
END;
corrs := 2 * deltay; corrd := 2 * (deltay - deltax);
direction := (2 * deltay) - deltax;
a := p1;
FOR i := 1 TO maxdim DO
DrawPoint(a, color);
IF direction >= 0 THEN
a.x := a.x + xup; a.y := a.y + yup;
direction := direction + corrs;
ELSE
a.x := a.x + supx; a.y := a.y + supy;
direction := direction + corrs;
END;
END;
END DrawLine;
PROCEDURE DrawBox(UpperLeft, LowerRight : Point; c : CARDINAL);
(* Draw a Box with the two points specifying two opposite
corners. Color the lines according to palette c *)
VAR p1, p2 : Point;
BEGIN
p1 := UpperLeft; p2 := LowerRight; p2.x := UpperLeft.x;
DrawLine(p1, p2, c);
p2 := LowerRight; p2.y := UpperLeft.y; DrawLine(p1, p2, c);
p1 := LowerRight; p2 := UpperLeft; p2.x := LowerRight.x;
DrawLine(p1, p2, c);
p2 := UpperLeft; p2.y := LowerRight.y; DrawLine(p1, p2, c);
END DrawBox;
END DrawPoly.