The Most Useful of the Graphics Functions.

MakeWindow(w, h);

Create a new graphics window, w pixels wide and h pixels tall.

MakeWindow(w, h, x, y);

Same as above, but also specifying x,y co-ordinates of the top left corner.

CloseWindow();

Make the graphics window go away permanently.

SetCaption(string s);

Set the caption in the graphics window’s title bar.

MoveTo(x, y);

Move the imaginary pen to co-ordinates x,y without drawing a line.

DrawLineTo(x, y);

Draw a line from the pen’s current position to co-ordinates x,y, and leave the pen there ready for the next operation.

DrawPointAt(x, y);

Draw a single point at co-ordinates x,y. Remember that a single point isn’t necessarily a single pixel; the current pen width determines the diameter.

DrawPointHere();

Draw a single point at the pen’s current position.

DrawRectangleXYWH(x, y, w, h);

Draw the outline of a rectangle, x,y are the co-ordinates of the top left corner, it is w pixles wide and h pixels tall.

DrawRectangleXYXY(x1, y1, x2, y2);

Draw the outline of a rectangle, x1,y1 are the co-ordinates of the top left corner, and x2,y2 are the co-ordinates of the bottom right corner.

FillRectangleXYWH(x, y, w, h);

FillRectangleXYXY(x1, y1, x2, y2);

The same as the draw-rectangle functions, except that a solid coloured-in rectangle is drawn, not just the outline.

PenWidth(w);

Set the pen’s width (tip diameter).

PenColor(c);

PenColor(r1, g1, b1);

PenColor0255(r2, g2, b2);

Set the pen’s colour: c is a colour code; r1, g1, b1 are the red, green, blue components of the colour in the range 0.0 to 1.0; r2, g2, b2 are the same but as integers in the range 0 to 255.

There are ten predefined colour codes: PEN_BLACK, PEN_RED, PEN_GREEN, PEN_BLUE, PEN_YELLOW, PEN_MAGENTA, PEN_CYAN, PEN_ORANGE, PEN_PINK, and PEN_WHITE. For anything else, the functions EncodeColor(r1, g1, b1) and EncodeColor0255(r2, g2, b2) return a single representative int value.

WriteText(string s);

Draw the text string s in the graphics window, starting from the pen’s current position.

WriteTextf(string format, ...other parameters...);

For C programmers, this is identical to printf, except of course that it produces text in the graphics window. For non-C programmers, learn how printf works.

SetFontSize(int sz);

Changes the font to be used by WriteText and WriteTextf. The size parameter corresponds exactly to the sizes in standard windows applications, it is approximately the height in pixels of a capital letter.

SetFontAttributes(int at);

Changes the font to be used by WriteText and WriteTextf. The attribute parameter may be any combination of FONT_NORMAL, FONT_BOLD, FONT_ITALIC, FONT_UNDERLINE, and FONT_STRIKEOUT. These values are integers that may be added together to produce combined results, but not all options will be available for all fonts.

SetFontFace(int fa);

Changes the font to be used by WriteText and WriteTextf. The face parameter may be any one of FONT_ROMAN, FONT_FIXED, FONT_SANS_SERIF. These correspond to the default Times/Roman, Fixed-Width, and Dialogue fonts for the system.

SetFontFace(string fn);

Changes the font to be used by WriteText and WriteTextf. This gives more control if you know the exact name of the desired font. The fontname parameter should be the exact name of any font that is installed on the system, for example “Times New Roman”, “Comic Sans MS”, or “Symbol”.

SetFontFaceAttributesSize(string fn, int at, int sz);

Sets all three font parameters at once. Much more efficient, because the intermediate unused fonts do not have to be loaded.

GetNumberOfFonts()

Returns an int, being the number of fonts currently installed.

GetFontName(int n);

Returns a string, being the name of the nth of the currently installed fonts. N ranges from 0 to number_of_fonts-1.

MeasureText(String s, int w, int h);

Works out how much space would be required to draw the text in the currently selected font, and sets the w and h parameters (which must be int variables) to the width and height respectively, in pixels.

CaptureEvents(int codes);

Notifies the system that you would like to be informed whenever an event of the indicated kind occurs. The codes parameter may be any combination (formed by adding) of the following items: MOUSE_CLICK_L, MOUSE_CLICK_R, KEY_TYPED, WINDOW_RESIZED, TIMER_SIGNAL. There are many other kinds of events, see the full documentation for details. In particular, mouse events with CLICK replaced by PRESS or RELEASE also exist. When a requested event occurs, your program is not interrupted; it must explicitly ask for the next notification.

GetNextEvent(e, x, y, t, c);

All parameters must be int variables. If no event of a requested type has occurred since the last call of this function, the function returns zero. If a requested event has occurred, its details are stored in the five variable parameters, and 1 is returned. The notified event is deleted from the event queue. E is set to the event kind (e.g. MOUSE_CLICK_L), X and Y are set to event-dependent values. T is the time at which the event occurred, measured in milliseconds since the program started, and C is the Cause of the event: 0 means the user, 1 means it was program generated.

For mouse-related events, x and y are the relevant co-ordinates. For size related events, x and y are the width and height. For keyboard related events, x is the extended-ascii code for the character. See the full documentation for the extended ascii codes.

Pause(t);

Suspends program execution for t seconds (t is a floating point number, so it does not have to be a whole number of seconds). Typically, if GetNextEvent returns 0, a Pause of 1mS before calling it again gives the system a chance to do other things and continue to run smoothly.

StartSingleTimer(t);

Requests that a TIMER_SIGNAL event should be generated automatically t seconds into the future. T does not have to be a whole number.

StartRegularTimer(t);

Requests that a TIMER_SIGNAL event should be generated automatically t seconds into the future, and again every t seconds thereafter. T does not have to be a whole number.

The complete documentation also contains information on many other functions not listed here. In particular, the system gives support for Dialogues (pop-up informative windows) of various kinds, Menus, Creating, Reading, and Displaying image (.BMP) files, and multi-threaded processing.