Graph

* Graph(number subFunction, ...)

Graph performs a number of operations with the screen and background picture. It contains a number of sub functions, listed below.

 

number Graph(grGET_COLORS)
Obtains the color resolution which the interpreter is running in.

The values are as follows:

16 EGA
-1 CGA (doesn't matter if the driver is a mono CGA or four color CGA)

Example
(var colors)
=
colors Graph(grGET_COLORS)
(
if( == colors 16)
  Print("You are running in EGA mode")
)(
else
  (if( == colors -1)
    Print("You are running in CGA mode")
  )
)
 
void Graph(grDRAW_LINE, number y1, number x1, number y2, number x2[, number visColor, number priColor, number ctlColor])
Draws a line on the specified screen(s) with the specified color.

If you specify visColor, then the line is drawn on the visual screen with that color. If visColor is -1, no line is drawn. Use -1 if you, for example, want to draw a line on the control screen, but not the visual or priority screens.

If you specify priColor, then the line is drawn on the priority screen with that color. If priColor is -1, no line is drawn.

If you specify ctlColor, then the line is drawn on the control screen with that color. If ctlColor is -1, no line is drawn.

Example
/* Draw a line from (30,20) to (200,100) on the visual screen in yellow, the priority screen in red, and the control screen in blue. */
Graph(grDRAW_LINE 20 30 100 200 clYELLOW clRED clBLUE)

/* Draw a line from (60,40) to (160,130) on the visual screen in white, and the control screen in brown. */
Graph(grDRAW_LINE 40 60 130 160 clWHITE -1 clBROWN)

/* Draw a line from (10,20) to (40,50) on the visual screen in red. */
Graph(grDRAW_LINE 20 10 50 40 clRED)

number Graph(grSAVE_BOX, number y1, number x1, number y2, number x2[, number screen])
Saves the screen pixels in the specified area and returns a handle to them. If screen is specified, it saves the pixels of that screen (VISUAL,PRIORITY,CONTROL). Otherwise, it uses the VISUAL screen.
Example
/* this saves the center of the screen, draws a line, then restores the area leaving only the line's edges */
(var handle)
=
handle Graph(grSAVE_BOX 50 80 150 240)
Graph(grDRAW_LINE 10 10 180 310 clYELLOW)
Graph(grRESTORE_BOX handle)
number Graph(grRESTORE_BOX, number handle)
Restores the pixels saved with grSAVE_BOX.
Example
/* this saves the center of the screen, draws a line, then restores the area leaving only the line's edges */
(var handle)
=
handle Graph(grSAVE_BOX 50 80 150 240)
Graph(grDRAW_LINE 10 10 180 310 clYELLOW)
Graph(grRESTORE_BOX handle)
void Graph(grFILL_BOX, number y1, number x1, number y2, number x2, number screens[, number visColor, number priColor, number ctlColor])
Fills the specified rectangular region with the specified color(s). The screens parameter specifies which screens to drawn to.

The screens parameter can be any of the following...

VISUAL The visual screen
PRIORITY The priority screen
CONTROL The control screen
VISUAL_PRIORITY The visual and priority screens
VISUAL_CONTROL The visual and control screens
PRIORITY_CONTROL The priority and control screens
ALL_SCREENS All three screens.

If you specify visColor, then the box is drawn on the visual screen with that color. If visColor is -1, no box is drawn. Use -1 if you, for example, want to draw a box on the control screen, but not the visual or priority screens.

If you specify priColor, then the box is drawn on the priority screen with that color. If priColor is -1, no box is drawn.

If you specify ctlColor, then the box is drawn on the control screen with that color. If ctlColor is -1, no box is drawn.

Example
/* Draws a box with the bounds of (30,20) and (200,100) on the visual screen in yellow, the priority screen in red, and the control screen in blue. */
Graph(grDRAW_BOX 20 30 100 200 ALL_SCREENS clYELLOW clRED clBLUE)

// Doesn't draw anything though the colors are specified, no screens are
Graph(grDRAW_BOX 20 30 100 200 0 clYELLOW clRED clBLUE)

/* Draws a box with the bounds of (60,40) and (160,130) on the visual screen in white, and the control screen in brown. */
Graph(grDRAW_BOX 40 60 130 160 VISUAL_CONTROL clWHITE -1 clBROWN)

void Graph(grFILL_BOX_BACKGROUND, number y1, number x1, number y2, number x2)
Operates just like grFILL_BOX, but draws a box on the visual screen with the current port's background color.
Example
Graph(grFILL_BOX_BACKGROUND 40 40 99 119)
void Graph(grFILL_BOX_FOREGROUND, number y1, number x1, number y2, number x2)
Operates just like grFILL_BOX, but draws a box on the visual screen with the current port's foreground color.
Example
Graph(grFILL_BOX_FOREGROUND 40 40 99 119)
void Graph(grUPDATE_BOX, number y1, number x1, number y2, number x2, number screen)
Draws the specified area of the screen's screen to the screen (whew!). You can use this to redraw the background picture, and also to view the priority/control screens.
Example
/* Shows the priority screen for two seconds */
Graph(grUPDATE_BOX 0 0 199 319 PRIORITY)
Wait(120)

/* Shows the control screen for two seconds */
Graph(grUPDATE_BOX 0 0 199 319 CONTROL)
Wait(120)

/* Shows the visual screen*/
Graph(grUPDATE_BOX 0 0 199 319 VISUAL)

void Graph(grREDRAW_BOX, number y1, number x1, number y2, number x2)
Redraws the specified area of visual screen to the screen.
Example
Graph(grREDRAW_BOX 0 0 199 319)
number Graph(grADJUST_PRIORITY, number min, number max)
Sets the minimum and maximum bounds for the priority. By default, these values are 42 and 190.
Example
Graph(grADJUST_PRIORITY 20 150)