navigation map

Chapters:
  1: Introduction
  2: Simple example
  3: Invocation
  4: Finer Control
  5: X-Y Plots
  6: Contour Plots
  7: Image Plots
  8: Examples
  9: Gri Commands
  10: Programming
  11: Environment
  12: Emacs Mode
  13: History
  14: Installation
  15: Gri Bugs
  16: Test Suite
  17: Gri in Press
  18: Acknowledgments
  19: License

Indices:
  Concepts
  Commands
  Variables
index.html#Top Examples.html#Examples Gri: drawing legends for curve types etc Gri: drawing TS diagrams index.html#Top Gri: drawing TS diagrams

8.7: Drawing gray polygons

The following example shows how to draw polygons of a graylevel that is read in. It also draws a bullet (within the polygon). See the help lines at the start.


`Draw Polygon And Bullet'
Draw a polygon of a given graylevel, with a bullet
(black dot) at an indicated location.  The polygon
coordinates are read in by this command, as are
the graylevel and the location of the bullet.

Variables used: .black. .white.

Input data read:

line 1: A code (which is ignored) and a graylevel to draw the polygon with. The value for this graylevel ranges from .black. (which codes to black ink on the paper) to .white. (which codes to blank paper).

line 2: An (x,y) location for the bullet.

line 3: Skipped.

line 4-n: Locations of vertices of polygon, ended with a blank line. { read .code. .graylevel. # Read line 1 read .x. .y. # Read line 2 skip # Skip line 3 read columns x y # Read a polygon # Adjust .graylevel. to range between 0 # (for black ink) and 1 (for white paper), # then set graylevel and draw polygon. .graylevel. = {rpn .graylevel. \ .black. - .white. .black. - /} set graylevel .graylevel. draw curve filled # Draw black bullet set graylevel 0 draw symbol bullet at .x. .y. # Clean up local storage. delete .code. delete .graylevel. delete .x. delete .y. }

navigation map