home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / EXAMPLES / PPOLY.P < prev    next >
Text File  |  2000-02-11  |  3KB  |  137 lines

  1. program poly;
  2.  
  3. #include "Vogle.h"
  4.  
  5. var    
  6.     device: string_t;
  7.     parray: Poly3_array_t;
  8.     i: integer;
  9.  
  10.     procedure init;
  11.     (*
  12.      * Don't ya just love pascal....
  13.      *)
  14.     begin
  15.         parray[1, 1] := -8.0;
  16.         parray[1, 2] := -8.0;
  17.         parray[1, 3] :=  0.0;
  18.         parray[2, 1] := -5.0;
  19.         parray[2, 2] := -8.0;
  20.         parray[2, 3] :=  0.0;
  21.         parray[3, 1] := -5.0;
  22.         parray[3, 2] := -5.0;
  23.         parray[3, 3] :=  0.0;
  24.         parray[4, 1] := -8.0;
  25.         parray[4, 2] := -5.0;
  26.         parray[4, 3] :=  0.0
  27.     end;
  28.  
  29.     procedure drawpoly;
  30.     begin
  31.         Color(YELLOW);
  32.  
  33.         (*
  34.          * Draw a polygon using poly, parray is our array of
  35.          * points and 4 is the number of points in it.
  36.          *)
  37.         Poly(4, parray);
  38.  
  39.         Color(GREEN);
  40.  
  41.         (*
  42.          * Draw a 5 sided figure by using move, draw and closepoly.
  43.          *)
  44.         MakePoly;
  45.             Move(0.0, 0.0, 0.0);
  46.             Draw(3.0, 0.0, 0.0);
  47.             Draw(3.0, 4.0, 0.0);
  48.             Draw(-1.0, 5.0, 0.0);
  49.             Draw(-2.0, 2.0, 0.0);
  50.         ClosePoly;
  51.  
  52.         Color(MAGENTA);
  53.  
  54.         (*
  55.          * draw a sector representing a 1/4 circle
  56.          *)
  57.         Sector(1.5, -7.0, 3.0, 0.0, 90.0);
  58.  
  59.         i := GetKey
  60.     end;
  61.  
  62. begin
  63. (*
  64.  * Using polygons, hatching, and filling.
  65.  *)
  66.     init;
  67.     write('Enter output device: ');
  68.     readln(device);
  69.  
  70.     Voutput('ppoly.ps');
  71.     Vinit(device);
  72.  
  73.     Color(BLACK);        /* clear to bleck */
  74.     Clear;
  75.  
  76.     (*
  77.      * world coordinates are now in the range -10 to 10
  78.      * in x, y, and z. Note that positive z is towards us.
  79.      *)
  80.     Ortho(-10.0, 10.0, -10.0, 10.0, 10.0, -10.0);
  81.  
  82.     Color(YELLOW);
  83.  
  84.     (*
  85.      * write out the string "Polygon from poly()" in the
  86.      * starting at (-8.0, -4.0) and scaled to be 4.0 units long,
  87.      * 0.5 units high.
  88.      *)
  89.     BoxText(-8.0, -4.0, 4.0, 0.5, 'Polygon from poly()');
  90.  
  91.     Color(GREEN);
  92.  
  93.     (*
  94.      * write out a scaled string starting at (0.0, 6.0)
  95.      *)
  96.     BoxText(0.0, 6.0, 4.0, 0.5, 'Polygon from move()/ draw()');
  97.  
  98.     Color(MAGENTA);
  99.  
  100.     (*
  101.      * write out a scaled string starting at (0.0, 6.0)
  102.      *)
  103.     BoxText(3.5, -3.5, 1.9, 0.5, 'Sector');
  104.  
  105.     drawpoly;        (* draw some polygons *)
  106.  
  107.     (*
  108.      * turn on polygon hatching
  109.      *)
  110.     PolyHatch(true);
  111.     HatchAng(45.0);
  112.     HatchPitch(0.3);
  113.  
  114.     (*
  115.      *  Rotate 20 degrees around x and 30 around y
  116.      *)
  117.     Rotate(20.0, 'x');
  118.     Rotate(30.0, 'y');
  119.  
  120.     drawpoly;        (* draw some polygons with hatching *)
  121.  
  122.     (*
  123.      * turn on polygon filling - this automatically turns off hatching
  124.      *)
  125.     PolyFill(true);
  126.  
  127.     (*
  128.      *  Do another set of rotations.
  129.      *)
  130.     Rotate(20.0, 'x');
  131.     Rotate(30.0, 'y');
  132.  
  133.     drawpoly;        (* draw some polygons with filling *)
  134.  
  135.     Vexit
  136. end.
  137.