Displaying Text and Graphics / 9
Sample Program:
This procedure draws a series of diagonally-cut arcs on a graphics window screen.
PROCEDURE arcing
pDIM MX,MY,XRAD,YRAD,XCOR,YCOR,XCOR2,YCOR2:INTEGER
pDIM T,X,Y,Z:INTEGER
OPRINT CHR$C12)
pFOR T=1 TO 90 STEP 2
ORUN GFX2C"ARC",318,95,150,T,0,1 ,0,1 )
ORUN GFX2C"ARC",324 ,95,150,T,1 ,0,1 ,1 )
ON E X T T
9-51
BASIC09 Reference
BAR
Fill a rectangle
Syntax: RUN GFX2([path,]"BAR"[,xcorl,ycorl],xcor2,
ycor2)
Function: Fills a rectangular area defined by two sets of coordinates. BAR defines its area with an imaginary diagonal
line from the first set of coordinates to the second set of coordinates. The X coordinates are in the range 0-639. The Y
coordinates are in the range 0-191.
Parameters:
path The route to the window in which you want to
draw a bar.
xcorl,ycorl The beginning coordinates of the line defining
the area to fill. If you omit these coordinates,
BAR uses the draw pointer position. See the
previous section "The Graphics Cursor and
The Draw Pointer." Also see SETDPTR.
xcor2,ycor2 The ending coordinates of the line defining the
area to fill.
Examples:
RUN GFX2("BAR",200,100)
RUN GFX2("BAR",0,0,100,50)
Sample Program:
This procedure draws a bar chart on a window screen.
PROCEDURE OSgraf
pDIM COLOR,T,X,XCOR1,YCOR1,XCOR2,YCOR2:
INTEGER; RESPONSE:STRING[1]
pPR I NT CHR $ (1 2 )
ORUN GFX2("DEFCOL")
OCOLOR=1 3 \ XCOR1 =1 0 \ YCOR1 =180
DXCOR2=XCOR1 +40
pRUN GFX2("CUROFF")
9-52
Displaying Text and Graphics / 9
pFOR T=1 TO 10
DREAD YCOR2
pRUN GFX2C"COLOR",COLOR)
RUN GFX2C"BAR",XCOR1,YCOR1,XCOR2,YCOR2)
ORUN GFX2C"COLOR",7)
pRUN GFX2C"BOX",XCOR1,YCOR1,XCOR2,YCOR2)
OCOLOR=COLOR+1 XCOR1 =XCOR1 +50 \ XCOR2=XCOR1 +40
pNEXT T
OPRINT \ PRINT " OS-9 Sales Chart"
ORUN GFX2C"BOX",0,0,510,180)
OGET *1 ,RESPONSE
DRUN GFX2C"CURON")
OPRINT CHR$C12)
OEND
ODATA 170,150,140,130,110,90,70,60,50,30
9-53
BASIC09 Reference
BELL
Ring the terminal bell
Syntax: RUN GFX2("BELL")
Function:
Rings the terminal's
bell
(produces a beep through
the speaker).
Parameters:
None
Examples:
RUN GFX2C"HELL")
9-54
Displaying Text and Graphics / 9
BLNKON
Character blink on
BLNKOFF
Character blink off
Syntax:
RUN GFX2([path,]"BLNKON")
RUN GFX2([path,]"BLNKOFF")
Function:
Executing BLNKON causes all subsequent characters sent to a window on a
hardware
screen to blink. A hardware screen is one of the predefined device windows /W1
through /W7. Executing BLNKOFF cancels a previous blink
command; characters already blinking continue to do so. Blink
does not operate on graphics windows.
Parameters:
path The
route to the window in which you want to
blink characters.
Examples:
RUN GFX2("BLNKON")
RUN GFX2("BLNKOFF")
9-55
BASIC09 Reference
BOLDSWSwitch bold characters on or off
Syntax:
RUN GFX2([path,]"BOLDSW","switch")
Function:
Causes characters to display in either regular or
bold typeface. The default is regular typeface. BOLD only
works on graphics screens.
Parameters:
path
The route to the window in which you want
bold characters.
switch
Can be either "ON" or "OFF." If
switch is
"ON," subsequent characters are bold. If
switch is
"OFF," subsequent characters are
not bold.
Examples:
RUN GFX2("BOLDSW","ON")
Sample Program:
This procedure demonstrates the BOLDSW function by displaying both bold and normal text on a window screen.
PROCEDURE bold
ODIM LINE:STRING
OD I M LETTER : STR I NG I 1
DDIM T,J,K,FLAG:INTEGER
ORUN GFX2("CLEAR")
OFLAG=1
OFOR T=1 TO 8
DREAD LINE
OFOR J=1 TO LEN(L I NE
0LETTER=MID$(LINE,J,1)
DIF LETTER<>"!" AND LETTER<>"#" THEN
OPRINT LETTER;
DEND I F
DIF LETTER="!" THEN
OFLAG=FLAG*-1
9-56
Displaying Text and Graphics l 9
OIF FLAG>O THEN
pRUN GFX2C"HOLDSW","OFF")
pELSE
ORUN GFX2C"HOLDSW","ON")
OENDIF
CIEND I F
OIF LETTER-"#" THEN
pPRINT CHR$C34);
pEND I F
pNEXT J
OPRINT
ONE XT T
OPRINT \ PRINT
REND
ODATA "This
i5
a demonstration of"
ODATA "the !Hold! function of"
ODATA "HASIC09'S GFX2 module."
ODATA "U5e the command"
ODATA "!RUN GFX2C*HOLDSWx,xON#)!"
ODATA "to turn boldface on."
ODATA "U5e !RUN GFX2C#HOLDSWx,xOFFx)!"
ODATA "to turn boldface off"
9-57
BASIC09 Reference
BORDER
Set the border color
Syntax:
RUN GFX2 ([path,)"BORDER", color)
Function: Resets the palette register that affects a window's
border color (Register 0) to the specified color code. For information on the palette and on screen colors, see "The Palette"
and Table 9.7 earlier in this chapter.
Parameters:
path The route to the window in which you want to
change border color.
color One of the current palette colors. Color can be
either a constant or a variable.
Examples:
RUN GFX2("BORDER",1)
Sample Program:
This procedure lets you select different border colors by
pressing
CE
or ~ to select higher or lower color codes.
Press
a)
to end the procedure.
PROCEDURE border
EDIM COLOR: INTEGER
pDIM KEY:STRINGt1 J
OCOLOR=8
DRUN GFX2("CLEAR"
OWHILE KEY<>"q" AND KEY<>"Q" DO
pGET #1 ,KEY
OIF KEY="-" OR KEY="=" THEN
OCOLOR=COLOR-1
pEND I F
OIF KEY="+" OR KEY=";" THEN
OCOLOR=COLOR+1
DENDIF
9-58
Displaying Text and Graphics / 9
5IF COL015 OR COLOR<0 THEN COLOR=8
OEND I F
f
ORUN GFX2C"BORDER",COLOR)
ORUN GFX2C"CURXY",0,0)
DENDWHILE
OE N D
9-59
BASIC09 Reference
BOX
Draw a rectangle
Syntax:
RUN GFX2 ([path, ]"BOX"[, xcorl, ycorl ],
xcor2,ycor27
Function:
Draws a rectangle. BOX defines its area with an
imaginary diagonal line from the first set of coordinates to
the second set of coordinates. BOX does not reset the draw
pointer. The X coordinates are in the range 0-639. The Y
coordinates are in the range 0-191.
Parameters:
path The route to the window in which you want to
draw a box.
xcorl,ycorl The beginning coordinates for the line that
defines the rectangle to drawn. If you omit
these coordinates, BOX uses the draw pointer
position.
xcor2,cor2 The ending coordinates for the line that
defines the rectangular area to be drawn.
Examples:
RUN GFX2("BOX",200,100)
RUN GFX2("BOX",0,0,100,50)
Sample Program:
This procedure draws a series of progressively smaller boxes of
different colors on a window screen. Then, it rapidly changes the
colors of the boxes to produce a hypnotic effect.
PROCEDURE hypbox
pDIM X,Y,X1 ,Y1 ,T,R,COLOR: INTEGER
ODIM KEY:STRING[1 l
OK EY=""
OX=18 \Y=6
OY 1 =185 \ X 1 =621
ORUN GFX2("CLEAR")
9-60
Displaying Text and Graphics l 9
OFOR T=0 TO 15
pCOLOR=T
ORUN GFX2C"COLOR",3)
ORUN GFX2C"BOX",X,Y,X1 ,Y1 )
ORUN GFX2C"COLOR",COLOR)
ORUN GFX2C"FILL",X-1 ,Y-1 )
OX=X+18 \Y=Y+6
[]X1 =X1 -18 \Y1 =Y1 -6
ONEXT T
OWHILE KEY="" DO
ORUN INKEYCKEY)
OFOR T=1 TO 16
OR=RNDC65)
ORUN GFX2C"PALETTE",T,R)
ONEXT T
OENDWHILE
ORUN GFX2C"DEFCOL")
REND
9-61
BASIC09 Reference
CIRCLE
Draw a circle
Syntax:
RUN GFX2 ([ps th, ]"CIRCLE"[,xcorycor],
radius)
Function:
Draws a circle with a specified radius. If you specify
coordinates, CIRCLE uses them for the center point. Otherwise, CIRCLE locates the center of the circle at the current
draw pointer position. See "The Graphics Cursor and the
Draw Pointer" earlier in this section. Also see SETDPTR.
Parameters:
path The route to the window in which you want to
draw a circle.
xcor,ycor The coordinates for the circle's center. The X
coordinates are in the range 0-639. The Y
coordinates are in the range 0-191.
radius The radius of the circle.
Examples:
RUN GFX2C"CIRCLE",100)
RUN GFX2C"CIRCLE",100,200,50)
9-62
Displaying Text and Graphics l 9
Sample Program:
This procedure uses circles to produce a geometric design.
PROCEDURE ciraround
ODIM T,X,Y:INTEGER
pPRINT CHR$C12)
ORUN GFX2C"COLOR",1,2)
pFOR T=1 TO 130
OX=150*SINCT)+320
OY=25*COSCT)+96
ORUN GFX2C"CIRCLE",X,Y,100)
ONEXT T
ORUN GFX2C"COLOR",3,2)
OFOR T=1 TO 45
OX=150*SINCT)+320
OY=25*COSCT)+96
ORUN GFX2C"CIRCLE",X,Y,100)
ONEXT T
REND
9-63
BASIC09 Reference
CLEAR
Clear the screen
Syntax: RUN GFX2([path,]"CLEAR")
Function: Clears the current working area of a window.
CLEAR does not change the location of the draw pointer but
does set the text cursor and graphics cursor location to the
upper left corner of the window.
Parameters:
path The route to the window you want to clear.
Examples:
RUN GFX2C"CLEAR")
9-64
Displaying Text and Graphics / 9
COLOR
Set screen colors
Syntax: RUN GFX2([path,]"COLOR",
foreground[, background][, border])
Function:
Changes any of the foreground, background, or the
border colors. COLOR does not change the draw pointer
position.
Parameters:
path
The route to the window in which you want to
change one or more screen or text colors.
foreground
The register number for the foreground
palette.
background
The register number for the background
,,~. palette.
border
The register number for the border palette.
Changing the border color for any window on a
screen, changes the border color for all win
dows on the same screen.
Examples:
RUN GFX2C"COLOR",1)
RUN GFX2C"COLOR",1,2)
RUN GFX2C"COLOR",1 , 2, 1
9-65
BASIC09 Reference
Sample Program:
This procedure fills a window screen with multicolored filled
circles. ''
PROCEDURE bubbles
aDIM X,Y,W,Z,T:INTEGER
OZ =1
pRUN GFX2C"COLOR",1,0,0)
ORUN GFX2C"CLEAR")
OFOR T=1 TO 80
OX=RNDC635)+4
OY=RNDC 18S)+S
pW=RNDCSO+S)
pZ=Z+ 1
DIF Z>3 THEN Z=1
DENDIF
pRUN GFX2C"CIRCLE",X,Y,W)
ORUN GFX2C"COLOR",Z)
ORUN GFX2C"FILL",X,Y)
ONEXT T
pRUN GFX2C"COLOR",3,2,2)
OEND
9-66
Displaying Text and Graphics l 9
CRRTN
Carriage return
Syntax:
RUN GFX2([path,]"CRRTN")
Function:
Causes BASIC09 to send a carriage return to a
window. The cursor moves down one line and to the extreme
left of the window.
Parameters:
path The route to the window in which you want a
carriage return.
Examples:
RUN GFX2C"CRRTN")
9-67
BASIC09 Reference
CURDWN
Cursor down
Syntax: RUN GFX2([path,]"CURDWN")
Function: Moves the cursor down one text line. The X-coordinate, or column position, remains the same.
Parameters:
path The route to the window in which you want to
move the cursor.
Examples:
RUN GFX2("CURDWN")
9·68
Displaying Text and Graphics l 9
CURHOME
Cursor home
Syntax: RUN GFX2([path,]"CURHOME")
Function:
Moves the text cursor to the top left corner of the
screen.
Parameters:
path The route to the window where you want to
reset the cursor
Examples:
RUN GFX2("CURHOME")
9-69
BASIC09 Reference
CURLFTMove
cursor left
Syntax: RUN GFX2 ([path,]"C URLFT")
Function:
Moves the cursor one character to the left.
Parameters:
path The route to the window where you want to
move the cursor.
Examples:
RUN GFX2("CURLFT")
9-?0
Displaying Text and Graphics / 9
CUROFF
Turn off cursor
Syntax: RUN GFX2([path,]"CUROFF")
Function:
Makes the cursor invisible.
Parameters:
path The route to the window in which you want to
turn the cursor off.
Examples:
RUN GFX2("CUROFF")
9-71
BASIC09 Reference
CURON
Turn on cursor
Syntax: RUN GFX2([path,]"CURON")
Function: Makes the text cursor visible.
Parameters:
path The route to the window in which you want to
turn the cursor on.
Examples:
RUN GFX2C"CURON")
9-72
Displaying Text and Graphics / 9
CURRGTMove
cursor right
Syntax: RUN GFX2("[path,]CURRGT")
Function: Moves the cursor one character to the right.
Parameters:
path The route to the window in which you want to
move the cursor.
Examples:
RUN GFX2("CURRGT")
9-73
BASIC09 Reference
CURUP
Move cursor up
Syntax: RUN GFX2 ([path,]"C URUP")
Function:
Moves the cursor up one line.
Parameters:
path The route to the window in which you want to
move the cursor.
Examples:
RUN GFX2("CURUP")
9-74
Displaying Text and Graphics / 9
CURXY
Set cursor position
r~
Syntax:
RUN GFX2([path,]"CURXY",column,row)
Function:
Moves the cursor to the specified column and row
position. The column and row coordinates are relative to the
window's current character width and depth.
Parameters:
path The route to the window in which you want to
move the cursor.
column The column (horizontal) position for the
cursor.
row The row (vertical) position for the cursor.
Examples:
RUN
GFX2C"CURXY",10,10)
9-75
BASIC09 Reference
CWAREA
Change working area
Syntax:
RUN GFX2([path,]"CWAREA",xcorycorsizex,
sizey)
Function:
Restricts output in the window to the specified area.
The new area must be the same or smaller than the previous
working area. When a window's working area is changed,
OS-9 scales graphic and text coordinates and graphic images
to the new proportions. Text characters remain the same size.
Parameters:
path The route to the window in which you want to
change the working area.
xcor,ycor The beginning coordinates (the upper left cor
ner) for the new working area, relative to the
original window. The coordinates are based on
the character column and row size of the origi
nal window.
sizex Designates the number of columns in the new
working area.
sizey The number of lines available in the new
working area.
Examples:
RUN GFX2C"CWAREA",10,0,40,10)
9-76