Tscope5
graphics04.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// graphics04.c
// - Illustration of the relative coordinate scale and display coordinate system.
// - Set/get the display size and position.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
int main()
{
ts5_set_coordinate_scale(TS5_RELATIVE_COORDINATES);
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
// make a bitmap half that size
TS5_BITMAP *map = ts5_alloc_bitmap(0.5, 0.5);
// 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(0.5, 0.35, "display adapter size: %5.2f x %5.2f", aw, ah);
ts5_printf(0.5, 0.45, "display size: %5.2f x %5.2f", dw, dh);
ts5_printf(0.5, 0.55, "display position: %5.2f x %5.2f", dx, dy);
ts5_printf(0.5, 0.65, "bitmap size: %5.2f x %5.2f", bw, bh);
// draw the bitmap on the display
ts5_draw_bitmap(map, 0.25, 0.25);
// draw instructions to move the display
ts5_printf(0.5, 0.80, "please drag the display to a new position");
// wait for a click
// print the new display position
// draw a dot on the centre of the display adapter
ts5_printf(0.5, 0.85, "new display position: %5.2f x %5.2f", dx, dy);
ts5_set_fill_mode(TS5_FILL_ON);
ts5_draw_circle(1-dx*2.0, 1-dy*2.0, 0.0025);
// wait for a click
// free the bitmap
return 0;
}