Subsections

Graphics parameters

Defined in graphics.h and graphics.c

This part contains functions to change the graphics parameters of the text output and drawing functions. By default, text appears in a terminal font, and circles, ellipses etc. are not filled. All drawing is done in white against a black background. The text and drawing functions do not have arguments to alter the graphics parameters. This is done with the parameter functions below. They all change one parameter, e.g. the foreground color. Once a parameter value is changed, the given value is used for all further drawing until it is changed again.

The parameter functions all have the previous parameter setting as return value. This can be useful when you want to change some parameters in one part of a program, do some drawing and set the previous parameters again, without causing undesired parameter changes to other parts of the program.

int ts_bgcolor (int color);

Sets the background color. Default is black. Once a color is set, it remains active until another color is set. When this function is called, both the screen and double buffer are cleared to match the new background color.

Tscope represents colors as integer values. You can use predefined color values (see appendix) or you can compute a color value based on RGB triplets with ts_makecolor.

Returns the previous background color value.

Possible colors can be found in the appendix of the reference manual, or can be made by yourself through ts_makecolor.

int ts_fgcolor (int color);

Changes the drawing color of all subsequent drawing operations. The default color is white. Once a color is set, it remains active until another color is set.

Tscope represents colors as integer values. You can use predefined color values (see appendix) or you can compute a color value based on RGB triplets with ts_makecolor.

Returns the previous drawing color value.

int ts_textmode (int color);

Sets the background color of text. Default is transparent (predefined as TRANS). Once a color is set, it remains active until another color is set.

Tscope represents colors as integer values. You can use predefined color values (see appendix) or you can compute a color value based on RGB triplets with ts_makecolor.

Returns the previous text background color value.

int ts_makecolor (int r, int g, int b);

Computes a color value based on an RGB triplet. r, g and b are from the range [0,255].

It is possible to call this function as a parameter to the functions ts_bgcolor, ts_fgcolor or ts_textmode (e.g. ts_fgcolor (ts_makecolor (255,0,0)); changes the drawing color to red).

int ts_makehsvcolor(float h, float s, float v);

Computes a color value based on an HSV (hue, saturation, value) triplet. Hue is between 0 and 360, saturation and value between 0 and 1.

This function can be used as an alternative to ts_makecolor.

int ts_fill (int mode);

This function can be used to set the fill-mode for future drawing operations. When set to ON, circles and rectangles, etc. are filled. Only contours are drawn when set to OFF. Default is OFF.

Returns the previous fill-mode.

int ts_font (int type, int size, int style);

Sets the font used for future text output operations. Three fonts are available: ARIAL, COURIER and TIMES. They all come in 16 sizes: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48 and 72 pixels. Four styles are possible: regular (REG), and bold (BOLD), italics (IT), or bold italics (BOLDIT).

Default a terminal-like font is used. The other fonts are provided in separate data files and are loaded the first time they are used. This takes some time (not exactly much, but enough to mess up the timing of a response), so make sure all used fonts are loaded before the first trial starts.

The font data files are provided in /usr/local/fonts. Tscope will search for the font files in the program's working directory, the fonts subdirectory of this directory and in /usr/local/fonts.

Returns the number of the previous font.

int ts_setfont (int fontno);

Sets the font based on the return value of a previous call to ts_font. Can be useful if one part of a program changes the font and wants to switch to the previous font again, without explicitly knowing what the previous font was.

ts_setfont(0) switches back to the default terminal font.

Returns the number of the previous font.

int ts_loadfont (char *fontfile);

Sets a font from a custom font file. It will search for the font file in the program's working directory, the fonts subdirectory of this directory and in /usr/local/fonts.

The Tscope FAQ explains how to make a custom font file.

Returns the number of the previous font.


top
Persoonlijke pagina Universiteit GentTscope
Allegro | Cygwin | Gcc
© See license.html for copyright information