(******************************************************************************) (* POLYGONS.MOD *) (* *) (* MetaWINDOW HOWTO: program series. Demonstrates usage of polygons. *) (* Transcribed from POLYGONS.C METAGRAPHICS SOFTWARE CORPORATION (c) 1987-1989*) (* *) (* PSW 10/31/90 02:44am *) (******************************************************************************) MODULE Polygons; (* * Graphix * Release 3.7 * (c) Copyright 1986-1992 PMI * Green Bay, Wisconsin * (414) 468-6040 * All rights reserved * *) IMPORT GrConst; IMPORT GrPorts; IMPORT Meta; IMPORT GrQry; IMPORT IO; FROM GrConst IMPORT rect, point, polyHead; CONST NUMPTS = 11; (* how many points in polygon points array *) VAR GrafixCard, CommPort: INTEGER; scrnR: rect; i: INTEGER; c: CHAR; PROCEDURE DrawPoly(); VAR x, y, z: INTEGER; p_pts: ARRAY[0..NUMPTS-1] OF point; (* The polygon point series *) p_hdr: ARRAY[0..1] OF polyHead; (* the polygon header array *) BEGIN x := scrnR.Xmax DIV 15; (* obtain some scaling factors *) y := scrnR.Ymax DIV 12; (* set up the first polygon header array - 8 points *) p_hdr[0].polyBgn := 0; p_hdr[0].polyEnd := 7; p_hdr[0].polyRect := scrnR; (* set up the second polygon header array - 3 points *) p_hdr[1].polyBgn := 8; p_hdr[1].polyEnd := 10; p_hdr[1].polyRect := scrnR; (* set up the polygon point series *) z := 0; p_pts[z].X := x*2; p_pts[z].Y := y*2; INC(z); p_pts[z].X := x*6; p_pts[z].Y := y*5; INC(z); p_pts[z].X := x*12; p_pts[z].Y := y*2; INC(z); p_pts[z].X := x*7; p_pts[z].Y := y*8; INC(z); p_pts[z].X := x*12; p_pts[z].Y := y*10; INC(z); p_pts[z].X := x*8; p_pts[z].Y := y*7; INC(z); p_pts[z].X := x*2; p_pts[z].Y := y*9; INC(z); p_pts[z].X := x*2; p_pts[z].Y := y*2; INC(z); p_pts[z].X := x*15; p_pts[z].Y := y*12; INC(z); p_pts[z].X := x*13; p_pts[z].Y := y*12; INC(z); p_pts[z].X := x*14; p_pts[z].Y := y*10; INC(z); Meta.PaintPoly(2, ADR(p_hdr), ADR(p_pts)); (* draw two polygons with one call *) c := IO.RdChar(); Meta.ErasePoly(2,ADR(p_hdr),ADR(p_pts)); c := IO.RdChar(); Meta.FillPoly(2,ADR(p_hdr),ADR(p_pts),3); c := IO.RdChar(); END DrawPoly; BEGIN (* init the system *) GrQry.GrQuery(GrafixCard, CommPort); i := Meta.InitGrafix(-GrafixCard); IF (i # 0) THEN (* Display reason for no go *) GrQry.GrInitErr(GrafixCard, CommPort, i); END; Meta.SetDisplay(GrConst.GrafPg0); Meta.ScreenRect(scrnR); Meta.EraseRect(scrnR); DrawPoly(); GrQry.GrQuit('', 0) END Polygons.