comparison src/X_main.c @ 23:56f592f56ff7

Fix bug and add linear gradient paint. - fix the bug that forget to clear n_dirty_geos in rdman_redraw_all().
author Thinker K.F. Li <thinker@branda.to>
date Sat, 02 Aug 2008 23:10:42 +0800
parents 8fcf2d878ecd
children e598bc809c0f
comparison
equal deleted inserted replaced
22:8fcf2d878ecd 23:56f592f56ff7
12 12
13 Display *display; 13 Display *display;
14 14
15 void draw_path(cairo_t *cr, int w, int h) { 15 void draw_path(cairo_t *cr, int w, int h) {
16 redraw_man_t rdman; 16 redraw_man_t rdman;
17 shape_t *path1, *path2; 17 shape_t *path1, *path2, *path3;
18 coord_t *coord1, *coord2; 18 coord_t *coord1, *coord2;
19 paint_t *fill1, *fill2; 19 paint_t *fill1, *fill2, *fill3;
20 paint_t *stroke; 20 paint_t *stroke;
21 grad_stop_t fill3_stops[3];
21 int i; 22 int i;
22 23
23 redraw_man_init(&rdman, cr); 24 redraw_man_init(&rdman, cr);
24 coord1 = rdman_coord_new(&rdman, rdman.root_coord); 25 coord1 = rdman_coord_new(&rdman, rdman.root_coord);
25 coord2 = rdman_coord_new(&rdman, rdman.root_coord); 26 coord2 = rdman_coord_new(&rdman, rdman.root_coord);
45 coord2->matrix[5] = 20; 46 coord2->matrix[5] = 20;
46 rdman_coord_changed(&rdman, coord1); 47 rdman_coord_changed(&rdman, coord1);
47 rdman_coord_changed(&rdman, coord2); 48 rdman_coord_changed(&rdman, coord2);
48 rdman_add_shape(&rdman, (shape_t *)path1, coord1); 49 rdman_add_shape(&rdman, (shape_t *)path1, coord1);
49 rdman_add_shape(&rdman, (shape_t *)path2, coord2); 50 rdman_add_shape(&rdman, (shape_t *)path2, coord2);
51
52
53 fill3 = paint_linear_new(&rdman, 50, 50, 150, 150);
54 grad_stop_init(fill3_stops, 0, 1, 0, 0, 0.5);
55 grad_stop_init(fill3_stops + 1, 0.5, 0, 1, 0, 0.5);
56 grad_stop_init(fill3_stops + 2, 1, 0, 0, 1, 0.5);
57 paint_linear_stops(fill3, 3, fill3_stops);
58 path3 = sh_path_new("M 50,50 L 50,150 L 150,150 L 150,50 z");
59 rdman_paint_fill(&rdman, fill3, path3);
60 rdman_add_shape(&rdman, (shape_t *)path3, rdman.root_coord);
50 61
51 rdman_redraw_all(&rdman); 62 rdman_redraw_all(&rdman);
52 63
53 XFlush(display); 64 XFlush(display);
54 65