User guide

96 CHAPTER 3. THE LIBRARY
fillrect(x0, y0, x1, y1) CIN:y, POS:y, NAT:y
This function dr aws the rectangle (x0, y0), (x 1, y0), ((x1, y1), (x1, y0) filled with
plotcolour. plotx and ploty are set to x1 and y1, respectively.
fillrndrect(x0, y0, x1, y1, radius) CIN:y, POS:y, NAT:y
This function draws the rectangle (x0, y0), (x1, y0), ((x1, y1), (x1, y0) with rounded
corners of given r adi u s filled with plotcolour. If radius is less than or equal to zero
the corners are square, and if radius is greater than half the shorter side length it is
reduced to this value. plotx and ploty are set to x1 and y1, respectively.
drawcircle(x, y, radius) CIN:y, POS:y, NAT:y
This function draws the outline of the circle centred at (x, y) with given radius. Its
colour is plotcolour. plotx and ploty are set to x and y, resp e ct i vely.
fillcircle(x, y, radius) CIN:y, POS:y, NAT:y
This function draws a filled circle centred at (x, y) with given radius. Its colour i s
plotcolour. plotx and ploty are set to x and y, respectively.
wrgraph(filename) CIN:y, POS:y, NAT:y
This function writes the canvas to the given file in .pbm format. The image is
(currently) scaled to 15x25cms.
3.9 The SD L Graphi cs Libra r y
The SDL Graphics Library is available for many platforms including Linux, Windows
as OSX. It allows the user to create a window on the screen and repeatedly draw
simple images allowing primitive interac ti ve games to be implemented. It provides a
good interface with devi c e s such as the keyboard, the mouse and joysticks. In due
course this inte r fac e will include facilities for generating sound.
To include these features in cintsys it is necessary t o install the SDL librari es
on you machine and then build cintsys using a Makefile such as MakefileSDL,
MakefileRaspiSDL or MakefileVCSDL.
The SDL li b rar y uses the sys(Sys
sdl,...) functions. There is a header file
(g/sdl.h) declaring t he various const ants and globals available in the SDL li b r ary, and
g/sdl.b contains the definitions of several functions providing the interface to SDL.
The constant g
sdlbase is set in libhdr to be the first global used in the SDL library.
It can be overridden by re-defining g
sdlbase after GETting libhdr.
A program wishing to use the SDL l i br ar y should start with the foll owing lines.
GET "libhdr"
MANIFEST { g_sdlbase=nnn } // Only used if the default setting of 450 in
// libhdr is not suitable.
GET "sdl.h"
GET "sdl.b" // Insert the library source code
.