TPATTERN.MOD 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. (******************************************************************************)
  2. (* TPATTERN.MOD *)
  3. (* *)
  4. (* MetaWINDOW HOWTO: program series. Demonstrates patterns and shapes. *)
  5. (* Transcribed from TPATTERN.C METAGRAPHICS SOFTWARE CORPORATION (c) 1987-1989*)
  6. (* *)
  7. (* PSW 10/31/90 02:44am *)
  8. (******************************************************************************)
  9. MODULE TPattern;
  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. VAR
  26. GrafixCard,
  27. CommPort: INTEGER;
  28. sR,R: rect;
  29. ScrnXmax,
  30. ScrnYmax,
  31. x,y,z,
  32. dx,dy,
  33. dxx,dyy,
  34. h,i,j,k,
  35. clr,pat,
  36. object: INTEGER;
  37. p_pts: ARRAY[0..6] OF point; (* The polygon point series *)
  38. p_hdr: polyHead; (* the polygon header array *)
  39. BEGIN
  40. (* init the system *)
  41. GrQry.GrQuery(GrafixCard, CommPort);
  42. i := Meta.InitGrafix(-GrafixCard);
  43. IF (i # 0) THEN
  44. (* Display reason for no go *)
  45. GrQry.GrInitErr(GrafixCard, CommPort, i);
  46. END;
  47. IO.WrStr('TPATTERN - Color and pattern display');
  48. IO.WrLn; IO.WrLn;
  49. IO.WrStr('What object to use ?');
  50. IO.WrLn;
  51. IO.WrStr(' 1) Rectangles');
  52. IO.WrLn;
  53. IO.WrStr(' 2) RoundRectangles');
  54. IO.WrLn;
  55. IO.WrStr(' 3) Ovals');
  56. IO.WrLn;
  57. IO.WrStr(' 4) Arcs');
  58. IO.WrLn;
  59. IO.WrStr(' 5) Polygons [ ]');
  60. IO.WrChar(CHR(8));
  61. IO.WrChar(CHR(8));
  62. object := IO.RdInt();
  63. IF (object < 1) OR (object > 5) THEN
  64. GrQry.GrQuit('Illegal object!', 1);
  65. END;
  66. Meta.SetDisplay(GrConst.GrafPg0);
  67. Meta.ScreenRect(sR);
  68. Meta.EraseRect(sR);
  69. Meta.RasterOp(GrConst.zREPz);
  70. ScrnXmax := sR.Xmax;
  71. ScrnYmax := sR.Ymax;
  72. (* set up the polygon header array *)
  73. p_hdr.polyBgn := 0;
  74. p_hdr.polyEnd := 6;
  75. p_hdr.polyRect := sR;
  76. dx := (ScrnXmax+1) DIV 8;
  77. dy := (ScrnYmax+1) DIV 4;
  78. dxx := dx DIV 5;
  79. dyy := dy DIV 6;
  80. clr := Meta.QueryColors();
  81. k := clr - 1;
  82. FOR h := 0 TO 15 DO
  83. INC(k, 31);
  84. pat := 0;
  85. y := 0;
  86. FOR i := 0 TO 3 DO (* 4 down *)
  87. x := 0;
  88. FOR j := 0 TO 7 DO (* 8 across *)
  89. Meta.SetRect(R, x, y, x+(dx-dxx), y+(dy-dyy));
  90. Meta.BackColor(k); Meta.PenColor(clr-k);
  91. CASE object OF
  92. | 1:
  93. Meta.FillRect(R, pat);
  94. Meta.FrameRect(R);
  95. | 2:
  96. Meta.FillRoundRect(R, dxx, dyy, pat);
  97. Meta.FrameRoundRect(R, dxx, dyy);
  98. | 3:
  99. Meta.FillOval(R, pat);
  100. Meta.FrameOval(R);
  101. | 4:
  102. Meta.FillArc(R, pat*80, 450, pat);
  103. Meta.FrameArc(R, pat*80, 450);
  104. | 5:
  105. z := 0;
  106. p_pts[z].X := x;
  107. p_pts[z].Y := y;
  108. INC(z);
  109. p_pts[z].X := x + ((dx-dxx) DIV 2);
  110. p_pts[z].Y := y + (dy-dyy);
  111. INC(z);
  112. p_pts[z].X := x + (dx-dxx);
  113. p_pts[z].Y := y;
  114. INC(z);
  115. p_pts[z].X := x + (dx-dxx);
  116. p_pts[z].Y := y + (dy-dyy);
  117. INC(z);
  118. p_pts[z].X := x + ((dx-dxx) DIV 2);
  119. p_pts[z].Y := y;
  120. INC(z);
  121. p_pts[z].X := x;
  122. p_pts[z].Y := y + (dy-dyy);
  123. INC(z);
  124. p_pts[z].X := x;
  125. p_pts[z].Y := y;
  126. Meta.FillPoly(1, ADR(p_hdr), ADR(p_pts), pat)
  127. END;
  128. INC(x, dx);
  129. INC(pat);
  130. INC(k)
  131. END;
  132. INC(y, dy)
  133. END
  134. END;
  135. GrQry.GrQuit('', 0)
  136. END TPattern.