comparison src/X_main.c @ 16:e17e12b112c4

A simple animation using rdman_redraw_changed().
author Thinker K.F. Li <thinker@branda.to>
date Fri, 01 Aug 2008 18:20:28 +0800
parents c2ce186a5c37
children 0f3baa488a62
comparison
equal deleted inserted replaced
15:c2ce186a5c37 16:e17e12b112c4
7 7
8 #include <string.h> 8 #include <string.h>
9 #include "shapes.h" 9 #include "shapes.h"
10 #include "redraw_man.h" 10 #include "redraw_man.h"
11 11
12 Display *display;
13
12 void draw_path(cairo_t *cr, int w, int h) { 14 void draw_path(cairo_t *cr, int w, int h) {
13 redraw_man_t rdman; 15 redraw_man_t rdman;
14 shape_t *path; 16 shape_t *path;
15 coord_t *coord; 17 coord_t *coord;
18 int i;
16 19
17 redraw_man_init(&rdman, cr); 20 redraw_man_init(&rdman, cr);
18 coord = rdman.root_coord; 21 coord = rdman.root_coord;
19 22
20 path = sh_path_new("M 22,89.36218 C -34,-0.63782 39,-9.637817 82,12.36218 C 125,34.36218 142,136.36218 142,136.36218 C 100.66667,125.36218 74.26756,123.42795 22,89.36218 z "); 23 path = sh_path_new("M 22,89.36218 C -34,-0.63782 39,-9.637817 82,12.36218 C 125,34.36218 142,136.36218 142,136.36218 C 100.66667,125.36218 74.26756,123.42795 22,89.36218 z ");
21 coord->aggr_matrix[0] = 0.8; 24 coord->matrix[0] = 0.8;
22 coord->aggr_matrix[1] = 0; 25 coord->matrix[1] = 0;
23 coord->aggr_matrix[2] = 20; 26 coord->matrix[2] = 20;
24 coord->aggr_matrix[4] = 0.8; 27 coord->matrix[4] = 0.8;
25 coord->aggr_matrix[5] = 20; 28 coord->matrix[5] = 20;
26 rdman_coord_changed(&rdman, coord); 29 rdman_coord_changed(&rdman, coord);
27 rdman_add_shape(&rdman, (shape_t *)path, coord); 30 rdman_add_shape(&rdman, (shape_t *)path, coord);
28 31
29 rdman_redraw_all(&rdman); 32 rdman_redraw_all(&rdman);
33
34 XFlush(display);
35
36 for(i = 0; i < 10; i++) {
37 usleep(50000);
38 coord->matrix[2] += 5;
39 coord->matrix[5] += 5;
40 rdman_coord_changed(&rdman, coord);
41 rdman_redraw_changed(&rdman);
42 XFlush(display);
43 }
30 44
31 redraw_man_destroy(&rdman); 45 redraw_man_destroy(&rdman);
32 sh_path_free(path); 46 sh_path_free(path);
33 } 47 }
34 48
48 cairo_stroke(cr); 62 cairo_stroke(cr);
49 } 63 }
50 64
51 int 65 int
52 main(int argc, char * const argv[]) { 66 main(int argc, char * const argv[]) {
53 Display *display;
54 Window root; 67 Window root;
55 Visual *visual; 68 Visual *visual;
56 int screen; 69 int screen;
57 XSetWindowAttributes wattr; 70 XSetWindowAttributes wattr;
58 Window win; 71 Window win;