InitGc:
PROC ~
{
TRUSTED {gc ← GraphicsToPress.NewContext["maze.press"]};
p ← Graphics.NewPath[];
Graphics.Translate[gc, 72, 72];
The translate call makes the southwest corner of the maze come out one inch right and
one inch up from the southwest corner of the page
Graphics.Scale[gc, scaleFactor, scaleFactor]};
DrawWall:
PROC [w: Wall] ~
{x1, x2, y1, y2: INT;
SELECT
TRUE
FROM
w.Ns =>
{x1 ← w.X;
x2 ← w.X;
y1 ← w.Y - 1;
y2 ← w.Y};
w.Ew =>
{x1 ← w.X - 1;
x2 ← w.X;
y1 ← w.Y;
y2 ← w.Y};
ENDCASE => ERROR;
Graphics.MoveTo[p, x1, y1];
Graphics.LineTo[p, x2, y2];
Graphics.DrawStroke[gc, p, strokeWidth,
FALSE, square]};
DrawMaze:
PROC ~
{InitGc[];
draw the interior walls:
FOR i:
INT
IN [FirstBlack .. NumWalls)
DO
TRUSTED {DrawWall[W[i]]} ENDLOOP;
draw the exterior walls:
Graphics.MoveTo[p, 0, N]; -- northwest
Graphics.LineTo [p, 0, 0]; -- southwest
Graphics.MoveTo[p, 0, 0, FALSE]; -- empty step to placate Cedar Graphics
Graphics.LineTo [p, (M - 1), 0]; -- southeast exit, left
Graphics.DrawStroke[gc, p, strokeWidth, FALSE, square];
Graphics.MoveTo[p, M, 0]; -- southeast
Graphics.LineTo [p, M, N]; -- northeast
Graphics.MoveTo[p, M, N, FALSE]; -- another empty step
Graphics.LineTo [p, 1, N]; -- northwest exit, right
Graphics.DrawStroke[gc, p, strokeWidth, FALSE, square] ;
TRUSTED {GraphicsToPress.Close[gc]}};