Tscope5
Main Page
Related Pages
Files
Examples
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;
ts5_install_display
();
ts5_get_display_size
(1, &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
ts5_set_drawing_thickness
(2);
double
i;
for
(i=0; i<(sqrt(w*w+h*h)); i+=6) {
ts5_set_drawing_target
(map1);
ts5_draw_circle
(0.0, 0.0, i);
ts5_set_drawing_target
(map2);
ts5_draw_circle
(0.0, 0.0, i+2.0);
ts5_set_drawing_target
(map3);
ts5_draw_circle
(0.0, 0.0, i+4.0);
}
// set the display as the drawing target
ts5_set_active_display
(1);
// alternate between the three bitmaps
for
(i=0; i<100; i++) {
ts5_clear_display
();
ts5_draw_bitmap
(map1, 0.0, 0.0);
ts5_flip_display
();
ts5_wait
(0.05);
ts5_clear_display
();
ts5_draw_bitmap
(map2, 0.0, 0.0);
ts5_flip_display
();
ts5_wait
(0.05);
ts5_clear_display
();
ts5_draw_bitmap
(map3, 0.0, 0.0);
ts5_flip_display
();
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
ts5_free_bitmap
(map1);
ts5_free_bitmap
(map2);
ts5_free_bitmap
(map3);
return
0;
}