home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Education / xModels 2D and 3D / Tutorial Examples / Tutorial 2. Basic 2D objects < prev    next >
Encoding:
Text File  |  1995-06-22  |  2.1 KB  |  49 lines  |  [TEXT/X_#9]

  1. ; Tutorial 2: Basic 2D objects
  2. ;
  3. ; From Tutorial 1, you know about the basic objects "square",
  4. ; "circle" and "line".  xModels-2D also lets you use circles and
  5. ; squares filled in with either white, black, or gray color.
  6. ; The commands for these objects are whitecircle, blackcircle,
  7. ; graycircle, whitesquare, blacksquare, and graysquare.  The
  8. ; difference between a "whitesquare" and a plain "square" is
  9. ; that anything behind the whitesquare will be hidden.  For
  10. ; example:
  11.  
  12.        blackcircle scale 2 translate -7,7
  13.        graysquare scale 3 rotate 30 translate 6,6
  14.        whitecircle scale 2 translate 7,7
  15.  
  16. ; You can also draw "polygon objects".  To make a polygon, you
  17. ; need a list of points.  Each point has two coordinates.  The
  18. ; polygon is made by connecting each point in the list to the 
  19. ; with a line.  A line is also drawn from the last point back to
  20. ; the first.  For example:
  21.  
  22.        polygon 3,1 0,6 -2,-2  ; a triangle with vertices
  23.                               ; (3,1), (0,6), and (-2,2)
  24.  
  25. ; Since there are three pairs of numbers, you get a three-sided
  26. ; figure, that is, a triangle.  (If you specify a polygon with
  27. ; just two points, it will be a single line segment.  This is a
  28. ; convenient way to draw the line between two given points.)
  29. ; SYNTAX NOTE:  Commas are included for readability, but the program
  30. ; treats them exactly like spaces.  This is true in all contexts.
  31. ; For example, "translate 6,6" and "translate 6 6" are equivalent.
  32. ; There are filled-in polygons, given by graypolygon, whitepolygon,
  33. ; and blackpolygon.  You can apply transformations to polygons
  34. ; just as to any other objects:
  35.  
  36.       graypolygon 0,0 3,0 1,1 0,3     ; an "arrowhead" shape
  37.             rotate 40                 ; rotated 40 degrees
  38.             translate 0,-7            ; then moved down 7 units
  39.  
  40. ; SYNTAX NOTE: It doesn't matter how you lay out a scene 
  41. ; description on a page.  You can insert comments, carriage returns,
  42. ; and empty spaces at will.  The computer only reads the words and
  43. ; numbers and doesn't care about formating.
  44. ;
  45. ; Render this file to see the five objects that are specified.
  46. ; Try to understand where each object comes from.
  47.