home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / calculat / sm30a.zip / SYMBMATH.H48 < prev    next >
Text File  |  1993-11-07  |  5KB  |  119 lines

  1.         5.   Graphics
  2.         5.1  Drawing lines and arcs
  3.     SymbMath includes extensive facilities for graphing. It supports
  4. BGI-graphics, which graphics commands are the same as those in Turbo Pascal
  5. and Turbo C, except for:
  6.  
  7.           different graphics commands
  8. ------------------------------------------------
  9. SymbMath             Turbo Pascal or C
  10.  
  11. graph                initgraph(drive,mode,path)
  12. text                 closegraph
  13. writes(x)            outtext(x)
  14. -------------------------------------------------
  15.                                         
  16.     Before graphing, you should initialize the graphics system and puts
  17. the computer hardware into graphics mode by the command:
  18.         graph
  19. then you can draw a line by
  20.         line(x1,y1,x2,y2)
  21.         lineto(x2,y2)
  22.         linerel(dx,dy)
  23. draw a circular arc by                
  24.         arc(x,y,angle1,angle2,radius)
  25. draw an elliptical arc by                
  26.         ellipse(x,y,angle1,angle2,XRadius,YRadius)
  27. put a pixel by                
  28.         putpixel(x,y,color)
  29.     you can move a pointer by
  30.         moveto(x,y)
  31.         moverel(dx,dy)
  32.         A upper left corner on your graphics screen coordinates is (0,0).
  33.         The color and style of the line can be set by setcolor() and
  34. setlinestyle(). You can set screen colors.
  35.      If you are using a color system, you can set the color of the next
  36. line or graph or text with the command:
  37.                  setcolor(color)
  38. where color is an integer in the range 0..15, or one of the color words if
  39. package color.sm has been loaded.
  40.      You can set the background color for your graphs with the command
  41.         setbkcolor(color)
  42. where color is an integer in the range 0..15, or one of the color words if
  43. package color.sm has been loaded.
  44.  
  45.         Table 5.1     Color word and Its value in package color.sm
  46. ------------------------------------------------------------------
  47. color word                value
  48.  
  49. black                     0
  50. blue                      1
  51. green                     2
  52. cyan                      3
  53. red                       4
  54. magenta                   5
  55. brown                     6
  56. lightgray                 7
  57. gray                      8
  58. lightblue                 9
  59. lightgreen                10
  60. lightcyan                 11
  61. lightred                  12
  62. lightmagenta              13
  63. yellow                    14
  64. white                     15
  65. ----------------------------------------
  66.  
  67.      You can set line styles.
  68.      On both monochrome and color systems, you can draw lines and graphs
  69. with different line styles.  (Since the line segments used to draw graphs
  70. are usually very short, different line styles may not be distinguished in
  71. graphs, but they will be distinguished on long lines.)  Linestyles are
  72. indicated by integers in the range 0..3, and are set by the command:
  73.                 setlinestyle(style,u,thickness)
  74. where style, u and thickness are integers.
  75.     You can set the text style by
  76.         settextstyle(font,direction,size)
  77. where font, direction and size are integers.
  78.         You can add labels to your graphs by
  79.                 writes(s)
  80.      You can put alphanumeric labels anywhere on your graphic screens.
  81. They can be horizontal or vertical, and they can be printed in various
  82. sizes. To print a string  s  horizontally on the screen with the
  83. lower-left corner at the screen coordinates (x,y), use two commands:
  84.                 moveto(x,y), writes(s)
  85. To write vertically bottom to top, use two commands:
  86.                 settextstyle(1,2,2), writes(s)
  87.       
  88.       If SymbMath attempts to graph a point (x,y) which is outside the
  89. the screen coordinate, it ignores the point and continues.  No error
  90. message is generated, and even functions which are undefined on part of
  91. the graphing domain can be graphed.
  92.           You can get the max x and max y on your graphics screen
  93. coordinates by
  94.                 getmaxx
  95.                 getmaxy
  96.           You can get the current point(x, y) on your graphics screen
  97. coordinates by
  98.                 getx
  99.                 gety
  100.           You can get the background color and foregroud color on your
  101. graphics screen by
  102.                 getbkcolor
  103.                 getcolor
  104.           You can read a character from the keyboard or pause by the
  105. command:
  106.         readchar
  107.       Finally you should go back the text mode by the command:
  108.                 text
  109.  
  110.       Example 5.1:      
  111. #    drawing a group of circles and ovals.
  112. #    Circles are 9 planets around sun.
  113.  
  114. graph                                        # graph mode
  115. do(circle(getmaxx*0.5+2.5*x,getmaxy*0.5,5), x,0,90,10)
  116. do(oval(getmaxx*0.5,getmaxy*0.5,2.5*x,x), x,10,90,10)
  117. readchar                                     # pause graph by read a char
  118. text                                         # back text mode
  119.