MODULE GrafTest; (****************************************************************) (* *) (* Test of music and graphics. *) (* *) (* Programmer: P. Moylan *) (* Last edited: 7 March 1994 *) (* Status: Working *) (* *) (****************************************************************) FROM Timer IMPORT (* proc *) Sleep; FROM MusicDemonstration IMPORT (* proc *) WaitForEndOfMusic; FROM Graphics IMPORT (* proc *) SetMode, PlotMark, PlotLine; FROM MATHLIB IMPORT (* proc *) Sin, Cos, Sqrt, ATan; (************************************************************************) CONST colour = 1; stretch = 2.0; PI = LONGREAL(3.14159265358979323); (************************************************************************) PROCEDURE PlotScaledLine (x0, y0, x1, y1: LONGREAL); (* Draws a line from (x0,y0) to (x1,y1), with coordinates scaled to *) (* the standards expected by procedure Triangle, below. *) CONST xorg = 159.5; yorg = 99.5; scale = 99.5; VAR intx0, inty0, intx1, inty1: CARDINAL; BEGIN intx0 := TRUNC (stretch*(xorg+scale*x0)+0.5); inty0 := TRUNC (yorg+scale*y0+0.5); intx1 := TRUNC (stretch*(xorg+scale*x1)+0.5); inty1 := TRUNC (yorg+scale*y1+0.5); PlotLine (intx0,inty0,intx1,inty1,colour); END PlotScaledLine; (************************************************************************) PROCEDURE Triangle (x0, y0, side, theta, alpha: LONGREAL); (* Plots an equilateral triangle, starting at (x0, y0), with each *) (* side being "side" units long, and tilted at angle theta to the *) (* the horizontal. The units are scaled such that the centre of *) (* the screen is point (0.0,0.0), and side=1.0 gives the biggest *) (* triangle which will fit in the first quadrant. Part of the *) (* second side is deliberately omitted - only the first "alpha" of *) (* it (0