The Complete STOS Reference

 pre-release 0.2 Edited By Dr Phibes

Index

STOS Manual 6: GRAPHICS FUNCTIONS

General 
Drawing 
Line Types 
Filled Shapes 
Fill Types
Special Effects 
The Writing Modes 
Polymarkers 
Multi-Mode Graphics
 

General

CLS

Clears the whole screen at high speed

INK

Selects the colour of the pen. Note that colour 2 flashes

COLOUR index,$RGB

Assign a colour to an index. Index is the number of the colour to be changed.

c=COLOUR(index)

index is the colour number whose shade you want returned in c PALETTE list Installs a whole new palette from list. This list can contain anything up to the number of colours available in the current graphics mode with each colour value separated by a comma.

Drawing

PLOT x,y[,c]

Plots a point at x,y in the colour c.If c is not given then the current value of INK will be used.

c=POINT(x,y)

Returns the colour of the point x,y

DRAW x,y TO x2,y2

Draws a line between x,y and x2,y2.

DRAW TO x3,y3

Draws a line from the last line drawn to x3,y3. The above line drawing commands only draw using a solid line style.

BOX x,y TO x2,y2

Draws a hollow box on the screen.

RBOX

As for Box except that the corners of the box are rounded.

POLYLINE x,y TO x2,y2 TO xn,yn....

Multiple line drawing. line type can be set using SET LINE.

ARC x,y,r,s,e

Draws an arc whose centre is at x,y with a radius of r. The arc should start at the angle s and end at the angle e. Angles are measured in units of 1/10 of a degree, and can therefore range from 0 to 3600. A start angle of 0 would position the start at three o'clock and increasing this would rotate the start position in an anti-clockwise position.

EARC x,y,r1,r2,s,e

as ARC except the radius is split into two components, r1 is the horizontal part and r2 the vertical part.

Line Types

SET LINE mask,thickness,start,end

mask is the 16 bit bitmap for the line and bits with a 1 are represented on the screen in the ink colour,bits with a zero are set to the background colour thickness can range from 1 (thin) to 40 (thick) start,end refer to the end styles to be used.0=square:1=arrow:2=round.

Filled Shapes

PAINT x,y

Contour fill allows you to fill any hollow areas on the ST's screen with a solid colour or a fill pattern using the SET PAINT command.

BAR x,y TO x2,y2

Draws a filled bar using the current ink colour.

RBAR

As BAR, but with rounded corners.

POLYGON

As for POLYLINE except that the shape is filled with the current INK and the pattern with SET PAINT.

CIRCLE x,y,r

Draws a filled circle at x,y with a radius of r. It also uses the current INK and SET PAINT.

PIE x,y,r,s,e

Draws a segment of a filled circle at x,y with a radius, r, starting at s and ending at e. Also uses the current INK with the SET PAINT. ELLIPSE x,y,r1,r2 The ellipse function draws a filled ellipse in much the same way as CIRCLE draws a filled circle with r1 and r2 as it radii.

EPIE

This function corresponds directly to the EARC instruction and draws a solid elliptical pie chart.

Fill Types

There are 36 different fill styles. These patterns are grouped into four distinct types: Solid,Dotted,Lined and user defined.

SET PAINT type,pattern,border

type can range from 0 to 4 =0 Surface is not filled at all., =1 Surface is filled with current INK colour.(solid), =2 Surface is filled with one of 24 dotted patterns, =3 Surface is filled with one of 12 line patterns, =4 Surface is filled with a user defined pattern (See SET PATTERN) The fill pattern is specified using a number, which can range from 1 and 24 or 1 and 12 depending on whether DOTTED or LINED type has been selected. In neither of these fill patterns has been chosen pattern should be set to 1. border has just two possible values: 0 and 1. A border of 1 is used to indicate that the filled surface should be enclosed in a line of the current INK colour.

SET PATTERN

address Patterns can be stored either in a memory bank, a string or an array of integers and the variable address should be set up to point to the address of the data for the pattern.eg PATTERN VARPTR(P$). Each pattern is 16X16 points in size and takes up 16 two byte words of memory for each colour plane.A sprite can be used as a fill pattern in the following way: LOAD "PATTERN.MBK" Then all you need to do is work out the address of this data for use by SET PATTERN. The sprites should be 16X16 bits in size.

Special Effects

FLASH index,"colour,delay)(colour,delay)(colour,delay)..."

index is the number of the colour which is to be animated. delay is set in units of a 50th of a second. colour is stored in the standard RGB format. A maximum of 16 changes are allowed in one FLASH instruction.

FLASH OFF

turns off all flash instructions.

SHIFT delay[,start]

Allows you to produce startling effects by rotating the entire palette of 512 colours into the 16 colour indices using interrupts. If a starting value is not included in the instruction, then the rotation will begin from colour number 1 delay is the delay between each rotation in 50th's of a second. start enables you to change only the colours with indices greater than an initial value.

The Writing Modes

The format of the writing mode command is GR WRITING mode where mode can take the values from 1 to 4. mode=1 Replacement mode:This is the default mode. Any existing graphics on the screen will be completely replaced by anything you draw over them. mode=2 Transparent mode:This mode only sets the parts of the drawing which need to be set to a specific colour. This means that any points in the new drawing which have a colour of 0, are assumed to be transparent and are therefore omitted. mode=3 Xor mode:xor combines your new graphics on the screen with those already on the screen, using the logical xor operation.

mode=4 Inverse transparent mode:This mode only plots the points of the new picture with a colour of 0. All other point of the new picture are ignored.

Polymarkers

A polymarker is a list of objects such as crosses,diamonds and squares that can be plotted as easily as a single point.

POLYMARK x,y;x2,y2;x3,y3;......

x,y etc. are a list of coordinates used to print markers on the screen. Note that all polymarkers are drawn in the current INK colour. The marker type is assumed to be a " . " by default, and can be changed using SET MARK.

SET MARK type,size

This allows you to choose the marker used by POLYMARK from a selection of six different marker types. Each polymarker can be drawn in eight sizes, ranging in 11 point increments from 6 to 83 pixels wide. Here is a table which illustrates the various possibilities:
type    marker used
1       Point " . " Note this marker is only available in one size.
2       Plus sign " + "
3       Star " * "
4       Square
5       Diagonal cross
6       Diamond

Multi-Mode Graphics

MODE n

n can be 0 (low resolution) or 1 (medium resolution). This command will generate an error if it is used whilst a MONO monitor is being used.

DIVX and DIVY

These two system variables enable programs to be written that will work correctly in any of the three resolutions. All you have to do is assume the x and y sizes of the screen are 640 and 400 as in high resolution and then divide all x coordinates by DIVX and all y coordinates by DIVY.

CLIP x,y TO x2,y2

The clip instruction will restrict all graphical output to the rectangle specified by x,y and x2,y2. Any graphic output that would appear outside this area is not drawn, only the parts of a function which appear inside the defined rectangle will appear.

CLIP OFF

turns the above clipping action off.