home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS - Coast to Coast
/
simteldosarchivecoasttocoast2.iso
/
calculat
/
sm30a.zip
/
SYMBMATH.H48
< prev
next >
Wrap
Text File
|
1993-11-07
|
5KB
|
119 lines
5. Graphics
5.1 Drawing lines and arcs
SymbMath includes extensive facilities for graphing. It supports
BGI-graphics, which graphics commands are the same as those in Turbo Pascal
and Turbo C, except for:
different graphics commands
------------------------------------------------
SymbMath Turbo Pascal or C
graph initgraph(drive,mode,path)
text closegraph
writes(x) outtext(x)
-------------------------------------------------
Before graphing, you should initialize the graphics system and puts
the computer hardware into graphics mode by the command:
graph
then you can draw a line by
line(x1,y1,x2,y2)
lineto(x2,y2)
linerel(dx,dy)
draw a circular arc by
arc(x,y,angle1,angle2,radius)
draw an elliptical arc by
ellipse(x,y,angle1,angle2,XRadius,YRadius)
put a pixel by
putpixel(x,y,color)
you can move a pointer by
moveto(x,y)
moverel(dx,dy)
A upper left corner on your graphics screen coordinates is (0,0).
The color and style of the line can be set by setcolor() and
setlinestyle(). You can set screen colors.
If you are using a color system, you can set the color of the next
line or graph or text with the command:
setcolor(color)
where color is an integer in the range 0..15, or one of the color words if
package color.sm has been loaded.
You can set the background color for your graphs with the command
setbkcolor(color)
where color is an integer in the range 0..15, or one of the color words if
package color.sm has been loaded.
Table 5.1 Color word and Its value in package color.sm
------------------------------------------------------------------
color word value
black 0
blue 1
green 2
cyan 3
red 4
magenta 5
brown 6
lightgray 7
gray 8
lightblue 9
lightgreen 10
lightcyan 11
lightred 12
lightmagenta 13
yellow 14
white 15
----------------------------------------
You can set line styles.
On both monochrome and color systems, you can draw lines and graphs
with different line styles. (Since the line segments used to draw graphs
are usually very short, different line styles may not be distinguished in
graphs, but they will be distinguished on long lines.) Linestyles are
indicated by integers in the range 0..3, and are set by the command:
setlinestyle(style,u,thickness)
where style, u and thickness are integers.
You can set the text style by
settextstyle(font,direction,size)
where font, direction and size are integers.
You can add labels to your graphs by
writes(s)
You can put alphanumeric labels anywhere on your graphic screens.
They can be horizontal or vertical, and they can be printed in various
sizes. To print a string s horizontally on the screen with the
lower-left corner at the screen coordinates (x,y), use two commands:
moveto(x,y), writes(s)
To write vertically bottom to top, use two commands:
settextstyle(1,2,2), writes(s)
If SymbMath attempts to graph a point (x,y) which is outside the
the screen coordinate, it ignores the point and continues. No error
message is generated, and even functions which are undefined on part of
the graphing domain can be graphed.
You can get the max x and max y on your graphics screen
coordinates by
getmaxx
getmaxy
You can get the current point(x, y) on your graphics screen
coordinates by
getx
gety
You can get the background color and foregroud color on your
graphics screen by
getbkcolor
getcolor
You can read a character from the keyboard or pause by the
command:
readchar
Finally you should go back the text mode by the command:
text
Example 5.1:
# drawing a group of circles and ovals.
# Circles are 9 planets around sun.
graph # graph mode
do(circle(getmaxx*0.5+2.5*x,getmaxy*0.5,5), x,0,90,10)
do(oval(getmaxx*0.5,getmaxy*0.5,2.5*x,x), x,10,90,10)
readchar # pause graph by read a char
text # back text mode