comparison src/X_main.c @ 18:0f3baa488a62

Support solid color paint for fill.
author Thinker K.F. Li <thinker@branda.to>
date Sat, 02 Aug 2008 14:45:42 +0800
parents e17e12b112c4
children cf6d65398619
comparison
equal deleted inserted replaced
17:41f0907b27ac 18:0f3baa488a62
6 #include <cairo-xlib.h> 6 #include <cairo-xlib.h>
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 #include "paint.h"
11 12
12 Display *display; 13 Display *display;
13 14
14 void draw_path(cairo_t *cr, int w, int h) { 15 void draw_path(cairo_t *cr, int w, int h) {
15 redraw_man_t rdman; 16 redraw_man_t rdman;
16 shape_t *path; 17 shape_t *path;
17 coord_t *coord; 18 coord_t *coord;
19 paint_t *fill;
18 int i; 20 int i;
19 21
20 redraw_man_init(&rdman, cr); 22 redraw_man_init(&rdman, cr);
21 coord = rdman.root_coord; 23 coord = rdman.root_coord;
22 24
25 fill = paint_color_new(&rdman, 1, 1, 0);
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 "); 26 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 ");
27 rdman_paint_fill(&rdman, fill, path);
24 coord->matrix[0] = 0.8; 28 coord->matrix[0] = 0.8;
25 coord->matrix[1] = 0; 29 coord->matrix[1] = 0;
26 coord->matrix[2] = 20; 30 coord->matrix[2] = 20;
27 coord->matrix[4] = 0.8; 31 coord->matrix[4] = 0.8;
28 coord->matrix[5] = 20; 32 coord->matrix[5] = 20;
31 35
32 rdman_redraw_all(&rdman); 36 rdman_redraw_all(&rdman);
33 37
34 XFlush(display); 38 XFlush(display);
35 39
36 for(i = 0; i < 10; i++) { 40 for(i = 0; i < 50; i++) {
37 usleep(50000); 41 usleep(20000);
38 coord->matrix[2] += 5; 42 coord->matrix[2] += 1;
39 coord->matrix[5] += 5; 43 coord->matrix[5] += 1;
44 paint_color_set(fill, 1, 1, (i/25) & 0x1);
40 rdman_coord_changed(&rdman, coord); 45 rdman_coord_changed(&rdman, coord);
41 rdman_redraw_changed(&rdman); 46 rdman_redraw_changed(&rdman);
42 XFlush(display); 47 XFlush(display);
43 } 48 }
44 49
50 for(i = 0; i < 5; i++) {
51 usleep(500000);
52 paint_color_set(fill, 1, i % 2, 0);
53 rdman_paint_changed(&rdman, fill);
54 rdman_redraw_changed(&rdman);
55 XFlush(display);
56 }
57
58 fill->free(fill);
45 redraw_man_destroy(&rdman); 59 redraw_man_destroy(&rdman);
46 sh_path_free(path); 60 sh_path_free(path);
47 } 61 }
48 62
49 void drawing(cairo_surface_t *surface, int w, int h) { 63 void drawing(cairo_surface_t *surface, int w, int h) {