Tscope5
graphics03.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// graphics03.c
// - Illustration of the display coordinate system.
// - Set/get the display size and position.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
int main()
{
ts5_set_coordinate_system(TS5_DISPLAY_COORDINATES);
// get the size of the first display adapter
double aw, ah;
// open a display half the size of the display adapter
ts5_set_display_size(aw/2.0, ah/2.0);
ts5_set_display_position(aw/4.0, ah/4.0);
// make a bitmap half that size
TS5_BITMAP *map = ts5_alloc_bitmap(aw/4.0, ah/4.0);
// use the query functions to get
// - the display size
// - the display position
// - the bitmap size
double dw, dh;
double dx, dy;
double bw, bh;
ts5_get_display_size(1, &dw, &dh);
ts5_get_bitmap_size(map, &bw, &bh);
// clear the bitmap to white
// print the display size, position etc. on the bitmap
ts5_printf(bw/2.0, bh/2.0 - 60, "display adapter size: %5.2f x %5.2f", aw, ah);
ts5_printf(bw/2.0, bh/2.0 - 20.0, "display size: %5.2f x %5.2f", dw, dh);
ts5_printf(bw/2.0, bh/2.0 + 20.0, "display position: %5.2f x %5.2f", dx, dy);
ts5_printf(bw/2.0, bh/2.0 + 60.0, "bitmap size: %5.2f x %5.2f", bw, bh);
// draw the bitmap on the display
ts5_draw_bitmap(map, dw/4.0, dh/4.0);
// draw instructions to move the display
ts5_printf(dw/2.0, dh-80.0, "please drag the display to a new position");
// wait for a click
ts5_draw_mouse_button(dw-50.0, dh-50.0);
// print the new display position
// draw a dot on the centre of the display adapter
ts5_printf(dw/2.0, dh-40.0, "new display position: %5.2f x %5.2f", dx, dy);
ts5_set_fill_mode(TS5_FILL_ON);
ts5_draw_circle(dw-dx, dh-dy, 5);
// wait for a click
ts5_draw_mouse_button(dw-50.0,dh-50.0);
// free the bitmap
return 0;
}