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

  1. c
  2. c drawpoly
  3. c
  4. c    draw some polygons
  5. c
  6.     subroutine drawpoly
  7.     
  8.     integer YELLOW, GREEN, MAGENTA
  9.     parameter (YELLOW = 3, GREEN = 2, MAGENTA = 5)
  10. c
  11. c    An array of points for a polygon
  12. c
  13.     real parray(3,4)
  14.  
  15.     data parray/ -8.0, -8.0, 0.0,
  16.      +          -5.0, -8.0, 0.0,
  17.      +          -5.0, -5.0, 0.0,
  18.      +          -8.0, -5.0, 0.0 /
  19.  
  20.     call color(YELLOW)
  21.  
  22. c
  23. c Draw a polygon using poly, parray is our array of
  24. c points and 4 is the number of points in it.
  25. c
  26.     call poly(4, parray)
  27.  
  28.     call color(GREEN)
  29.  
  30. c
  31. c Draw a 5 sided figure by using move, draw and closepoly.
  32. c
  33.     call makepoly()
  34.         call move(0.0, 0.0, 0.0)
  35.         call draw(3.0, 0.0, 0.0)
  36.         call draw(3.0, 4.0, 0.0)
  37.         call draw(-1.0, 5.0, 0.0)
  38.         call draw(-2.0, 2.0, 0.0)
  39.     call closepoly()
  40.  
  41.     call color(MAGENTA)
  42.  
  43. c
  44. c draw a sector representing a 1/4 circle
  45. c
  46.     call sector(1.5, -7.0, 3.0, 0.0, 90.0)
  47.  
  48.     call getkey
  49.  
  50.     end
  51.  
  52. c
  53. c Using polygons, hatching, and filling.
  54. c
  55.     program fpoly
  56.     integer BLACK, YELLOW, GREEN, MAGENTA
  57.     parameter (BLACK = 0)
  58.     parameter (YELLOW = 3, GREEN = 2, MAGENTA = 5)
  59.         character*50 device
  60.  
  61.     print*,'Enter output device:'
  62.     read(*,'(a)')device
  63.  
  64.     call vinit(device)
  65.  
  66. c
  67. c clear to black
  68. c
  69.     call color(BLACK)
  70.     call clear
  71.  
  72. c
  73. c world coordinates are now in the range -10 to 10
  74. c in x, y, and z. Note that positive z is towards us.
  75. c
  76.     call ortho(-10.0, 10.0, -10.0, 10.0, 10.0, -10.0)
  77.  
  78.     call color(YELLOW)
  79.  
  80. c
  81. c write out the string "Polygon from poly()" in the
  82. c starting at (-8.0, -4.0) and scaled to be 4.0 units long,
  83. c 0.5 units high.
  84. c
  85.     call boxtext(-8.0, -4.0, 4.0, 0.5, 'Polygon from poly()')
  86.  
  87.     call color(GREEN)
  88.  
  89. c
  90. c write out a scaled string starting at (0.0, 6.0)
  91. c
  92.     call boxtext(0.0, 6.0, 4.0, 0.5, 'Polygon from move()/ draw()')
  93.  
  94.     call color(MAGENTA)
  95.  
  96. c
  97. c write out a scaled string starting at (0.0, 6.0)
  98. c
  99.     call boxtext(3.5, -3.5, 1.9, 0.5, 'Sector')
  100.  
  101. c
  102. c draw some polygons
  103. c
  104.     call drawpoly
  105.  
  106. c
  107. c turn on polygon hatching
  108. c
  109.     call polyhatch(.true.)
  110.     call hatchang(45.0)
  111.     call hatchpitch(0.3)
  112.  
  113. c
  114. c  Rotate 20 degrees around x and 30 around y
  115. c
  116.     call rotate(20.0, 'x')
  117.     call rotate(30.0, 'y')
  118.  
  119. c
  120. c draw some polygons with hatching
  121. c
  122.     call drawpoly
  123.  
  124. c
  125. c turn on polygon filling - this automatically turns off hatching
  126. c
  127.     call polyfill(.true.)
  128.  
  129. c
  130. c  Do another set of rotations.
  131. c
  132.     call rotate(20.0, 'x')
  133.     call rotate(30.0, 'y')
  134.  
  135. c
  136. c draw some polygons with filling
  137. c
  138.     call drawpoly
  139.  
  140.     call vexit
  141.  
  142.     end
  143.