POLYGONS.MOD 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. (******************************************************************************)
  2. (* POLYGONS.MOD *)
  3. (* *)
  4. (* MetaWINDOW HOWTO: program series. Demonstrates usage of polygons. *)
  5. (* Transcribed from POLYGONS.C METAGRAPHICS SOFTWARE CORPORATION (c) 1987-1989*)
  6. (* *)
  7. (* PSW 10/31/90 02:44am *)
  8. (******************************************************************************)
  9. MODULE Polygons;
  10. (*
  11. * Graphix
  12. * Release 3.7
  13. * (c) Copyright 1986-1992 PMI
  14. * Green Bay, Wisconsin
  15. * (414) 468-6040
  16. * All rights reserved
  17. *
  18. *)
  19. IMPORT GrConst;
  20. IMPORT GrPorts;
  21. IMPORT Meta;
  22. IMPORT GrQry;
  23. IMPORT IO;
  24. FROM GrConst IMPORT rect, point, polyHead;
  25. CONST
  26. NUMPTS = 11; (* how many points in polygon points array *)
  27. VAR
  28. GrafixCard,
  29. CommPort: INTEGER;
  30. scrnR: rect;
  31. i: INTEGER;
  32. c: CHAR;
  33. PROCEDURE DrawPoly();
  34. VAR
  35. x, y, z: INTEGER;
  36. p_pts: ARRAY[0..NUMPTS-1] OF point; (* The polygon point series *)
  37. p_hdr: ARRAY[0..1] OF polyHead; (* the polygon header array *)
  38. BEGIN
  39. x := scrnR.Xmax DIV 15; (* obtain some scaling factors *)
  40. y := scrnR.Ymax DIV 12;
  41. (* set up the first polygon header array - 8 points *)
  42. p_hdr[0].polyBgn := 0;
  43. p_hdr[0].polyEnd := 7;
  44. p_hdr[0].polyRect := scrnR;
  45. (* set up the second polygon header array - 3 points *)
  46. p_hdr[1].polyBgn := 8;
  47. p_hdr[1].polyEnd := 10;
  48. p_hdr[1].polyRect := scrnR;
  49. (* set up the polygon point series *)
  50. z := 0;
  51. p_pts[z].X := x*2;
  52. p_pts[z].Y := y*2;
  53. INC(z);
  54. p_pts[z].X := x*6;
  55. p_pts[z].Y := y*5;
  56. INC(z);
  57. p_pts[z].X := x*12;
  58. p_pts[z].Y := y*2;
  59. INC(z);
  60. p_pts[z].X := x*7;
  61. p_pts[z].Y := y*8;
  62. INC(z);
  63. p_pts[z].X := x*12;
  64. p_pts[z].Y := y*10;
  65. INC(z);
  66. p_pts[z].X := x*8;
  67. p_pts[z].Y := y*7;
  68. INC(z);
  69. p_pts[z].X := x*2;
  70. p_pts[z].Y := y*9;
  71. INC(z);
  72. p_pts[z].X := x*2;
  73. p_pts[z].Y := y*2;
  74. INC(z);
  75. p_pts[z].X := x*15;
  76. p_pts[z].Y := y*12;
  77. INC(z);
  78. p_pts[z].X := x*13;
  79. p_pts[z].Y := y*12;
  80. INC(z);
  81. p_pts[z].X := x*14;
  82. p_pts[z].Y := y*10;
  83. INC(z);
  84. Meta.PaintPoly(2, ADR(p_hdr), ADR(p_pts)); (* draw two polygons with one call *)
  85. c := IO.RdChar();
  86. Meta.ErasePoly(2,ADR(p_hdr),ADR(p_pts));
  87. c := IO.RdChar();
  88. Meta.FillPoly(2,ADR(p_hdr),ADR(p_pts),3);
  89. c := IO.RdChar();
  90. END DrawPoly;
  91. BEGIN
  92. (* init the system *)
  93. GrQry.GrQuery(GrafixCard, CommPort);
  94. i := Meta.InitGrafix(-GrafixCard);
  95. IF (i # 0) THEN
  96. (* Display reason for no go *)
  97. GrQry.GrInitErr(GrafixCard, CommPort, i);
  98. END;
  99. Meta.SetDisplay(GrConst.GrafPg0);
  100. Meta.ScreenRect(scrnR);
  101. Meta.EraseRect(scrnR);
  102. DrawPoly();
  103. GrQry.GrQuit('', 0)
  104. END Polygons.