
First Steps in Programming RISC OS Computers
A RISCWorld reprint of the updated second edition
Appendix 3 :
Graphics commands such as MOVE, DRAW, RECTANGLE etc. are actually special types of PLOT command. The PLOT keyword is followed by three numbers. The first is the action code and the other two are the x and y coordinates.
The action code is formed by adding two numbers together. The first of these refers to the type of object being produced, e.g. drawing a line, filling a triangle etc. and the second one refers to the way in which the object is put on the screen:
Code  Action 
0  Solid line with both end points 
8  Solid line without final end point 
16  Dotted line with both end points 
24  Dotted line without final end point 
32  Solid line without starting point 
40  Solid line without either end point 
48  Dotted line without starting point, continuing pattern 
56  Dotted line without either end point, continuing pattern 
64  Plot a single point 
72  Draw a line to left and right of point until a nonbackground colour is reached 
80  Fill a triangle, using given and previous two sets of coordinates 
88  Draw a line to the right of the point until the background colour is reached 
96  Draw a filled rectangle 
104  Draw a line to left and right of point until the foreground colour is reached 
112  Draw and fill a parallelogram 
120  Draw a line to the right of the point until a nonforeground colour is reached 
128  Flood fill around the point until a nonbackground colour is reached 
136  Flood fill around the point until the foreground colour is reached 
144  Draw a circle 
152  Draw and fill a circle 
160  Draw a circular arc 
168  Draw a segment 
176  Draw a sector 
184  Move or copy a rectangular portion of the screen 
192  Draw an ellipse 
200  Draw and fill an ellipse 
208  Used with fonts 
216  Reserved for future use 
224  Reserved for future use 
232  Plot a sprite 
240  Used by user programs 
248  Used by user programs 
The second number is added to the first one and describes how the object is plotted on the screen. These numbers are not used for moving or copying rectangles (action codes 184  191):
Code  Effect 
0  Move graphics cursor relative to the last point 
1  Plot relative to the last point using the graphics foreground colour 
2  Plot relative to the last point using the inverse of the graphics foreground colour 
3  Plot relative to the last point using the graphics background colour 
4  Move graphics cursor to the coordinates given 
5  Plot at the coordinates given using the graphics foreground colour 
6  Plot at the coordinates given using the inverse of the graphics foreground colour 
7  Plot at the coordinates given using the graphics background colour 
PLOT action codes 184  191, which move and copy rectangular portions of the screen, are slightly different:
Code  Action 
184  Move graphics cursor relative to the last point 
185  Move a rectangle relative to the last point 
186  Copy a rectangle relative to the last point 
187  Copy a rectangle relative to the last point 
188  Move graphics cursor to the coordinates given 
189  Move a rectangle to the coordinates given 
190  Copy a rectangle to the coordinates given 
191  Copy a rectangle to the coordinates given 
The PLOT command only includes one set of coordinates but a shape has several points which all need to be specified. This is done by 'visiting' one or two points with the graphics cursor and specifying a further one in the PLOT command:
 To draw a line, MOVE to one end and PLOT 5, specifying the other end.
 A triangle is filled by a MOVE to two points and PLOT 85, specifying the third.
 A rectangle is filled by a MOVE to one corner and PLOT 101, specifying the opposite corner.
 A parallelogram is filled by a MOVE to two adjacent corners and PLOT 117, specifying the corner opposite the first one visited.
 A circle is drawn or filled by a MOVE to its centre and PLOT 149 or 157, specifying a point on the circle.
 An arc, segment or sector is drawn by a MOVE to the centre of its circle, another MOVE to the clockwise end and PLOT 165, 173 or 181, specifying the anticlockwise end.
 An ellipse is drawn or filled by a MOVE to its centre followed by a MOVE to where the ellipse passes above or below the centre and PLOT 197 or 205, specifying the highest or lowest point of the ellipse.
Martyn Fox
