Tscope5
bitmaps05.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// bitmaps05.c
// - Illustration of the bitmap drawing functions.
// - Draw circles on three memory bitmaps.
// - Cycle between the bitmaps to create an illusion of movement.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
#include <math.h>
int main()
{
// open a display
double w, h;
// create three memory bitmaps
TS5_BITMAP *map1 = ts5_alloc_bitmap(w, h);
TS5_BITMAP *map2 = ts5_alloc_bitmap(w, h);
TS5_BITMAP *map3 = ts5_alloc_bitmap(w, h);
// draw concentric circles on each bitmap
// 'start' diameter differs between the three bitmaps
double i;
for (i=0; i<(sqrt(w*w+h*h)); i+=6) {
ts5_draw_circle(0.0, 0.0, i);
ts5_draw_circle(0.0, 0.0, i+2.0);
ts5_draw_circle(0.0, 0.0, i+4.0);
}
// set the display as the drawing target
// alternate between the three bitmaps
for (i=0; i<100; i++) {
ts5_draw_bitmap(map1, 0.0, 0.0);
ts5_wait(0.05);
ts5_draw_bitmap(map2, 0.0, 0.0);
ts5_wait(0.05);
ts5_draw_bitmap(map3, 0.0, 0.0);
ts5_wait(0.05);
}
// wait for a click
ts5_draw_mouse_button(w/2.0-50.0, -h/2.0+50.0);
// free the bitmaps
return 0;
}