Subsections

Coordinate system

Defined in coordinates.h and coordinates.c

There are two coordinate systems available in Tscope. You can use the standard computer coordinates, with the origin (0,0) in the upper left corner of the screen, with increasing coordinate values to the left of and below the origin. You can also use an Cartesian system, with the origin (0,0) in the center of the screen and increasing coordinate values to the left and above the origin, and decreasing (negative) values to the right and below the origin. Default is the Cartesian system.

Coordinates are given in pixels. Helper functions are available that transform percentages of the screen size into number of pixels.

The Cartesian system makes simple stimulus setups in the center of the screen simpler, but not really suitable for more complex operations like blitting, or for experienced graphics programmers. Switching between the systems can be done with a parameter function.

XMAX

Macro that contains the horizontal size of a screen quadrant in pixels. Its value is not defined before the graphics screen is opened.

YMAX

Macro that contains the vertical size of a screen quadrant in pixels. Its value is not defined before the graphics screen is opened.

SXMAX

Macro that contains the horizontal size of the screen in pixels. Its value is not defined before the graphics screen is opened.

SYMAX

Macro that contains the vertical size of the screen in pixels. Its value is not defined before the graphics screen is opened.

int ts_coordinates (int system);

Switches between the Cartesian and standard coordinate system. Predefined values are CARTESIAN and STANDARD. Default is CARTESIAN.

Returns the value of the previous setting.

int ax (float x);

Transforms percentages of the horizontal screen or screen quadrant size to absolute values (pixels). Its behavior depends on the coordinate system used.

With the Cartesian system x=0 refers to the center of the screen, x=1 refers the to right-hand side border and x=-1 refers to the left-hand side border.

With the standard system x=0 refers to the right-hand side border, x=1 refers to the left-hand side border.

It is possible to call this function as a parameter to a draw-function (e.g.: when using the Cartesian coordinate system, ts_putpixel (ax(.5), 0); writes a pixel eighty pixels to the right of the center in the case of a 320x240 sized screen, or 160 pixels to the right in the case of a 640x480 sized screen).

int ay (float y);

Like ax, but for horizontal coordinates.

int sx (float x);

Converts horizontal Cartesian coordinates to standard coordinates.

int sy (float x);

Converts vertical Cartesian coordinates to standard coordinates.

int cx (float x);

Converts horizontal standard coordinates to Cartesian coordinates.

int cy (float y);

Converts vertical standard coordinates to Cartesian coordinates.

void ts_agrid ();

Useful function when designing the graphical interface of your experiment. Draws a Cartesian/standard grid to the screen using absolute coordinates (pixels). This function is especially handy when you want to obtain absolute pixel sizes of all your stimuli (dependent of screen size).

void ts_rgrid ();

Useful function when designing the graphical interface of your experiment. Draws a Cartesian/standard grid to the screen using relative coordinates (percentages of screen/quadrant size). This function is especially handy when you want to obtain relative sizes of all your stimuli (independent of screen size).


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