comparison src/X_main.c @ 12:79e9edf4c00a

Add redraw manager
author Thinker K.F. Li <thinker@branda.to>
date Mon, 28 Jul 2008 17:45:36 +0800
parents 128af06c876c
children ed55009d96d3
comparison
equal deleted inserted replaced
11:128af06c876c 12:79e9edf4c00a
5 #include <cairo.h> 5 #include <cairo.h>
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 11
11 void draw_path(cairo_t *cr, int w, int h) { 12 void draw_path(cairo_t *cr, int w, int h) {
13 redraw_man_t rdman;
12 shape_t *path; 14 shape_t *path;
13 coord_t coord; 15 coord_t *coord;
16
17 redraw_man_init(&rdman);
18 coord = rdman.root_coord;
14 19
15 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 "); 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 ");
16 memset(coord.aggr_matrix, 0, sizeof(co_aix) * 6); 21 coord->aggr_matrix[0] = 0.8;
17 coord.aggr_matrix[0] = 0.8; 22 coord->aggr_matrix[1] = 0;
18 coord.aggr_matrix[1] = 0; 23 coord->aggr_matrix[2] = 20;
19 coord.aggr_matrix[2] = 20; 24 coord->aggr_matrix[4] = 0.8;
20 coord.aggr_matrix[4] = 0.8; 25 coord->aggr_matrix[5] = 20;
21 coord.aggr_matrix[5] = 20; 26 rdman_add_shape(&rdman, (shape_t *)path, coord);
22 sh_path_transform(path, &coord); 27 sh_path_transform(path);
23 sh_path_draw(path, cr); 28 sh_path_draw(path, cr);
24 } 29 }
25 30
26 void drawing(cairo_surface_t *surface, int w, int h) { 31 void drawing(cairo_surface_t *surface, int w, int h) {
27 cairo_t *cr; 32 cairo_t *cr;
31 cairo_paint(cr); 36 cairo_paint(cr);
32 cairo_set_source_rgb(cr, 0.9, 0.1, 0.1); 37 cairo_set_source_rgb(cr, 0.9, 0.1, 0.1);
33 draw_path(cr, w, h); 38 draw_path(cr, w, h);
34 cairo_set_source_rgb(cr, 0.5, 0.9, 0.8); 39 cairo_set_source_rgb(cr, 0.5, 0.9, 0.8);
35 cairo_move_to(cr, 10, h / 2); 40 cairo_move_to(cr, 10, h / 2);
36 cairo_set_font_size(cr, 48.0); 41 cairo_set_font_size(cr, 36.0);
37 cairo_text_path(cr, "hello \xe4\xb8\xad\xe6\x96\x87"); 42 cairo_text_path(cr, "hello \xe6\xbc\xa2\xe5\xad\x97");
38 cairo_set_line_width(cr, 2); 43 cairo_set_line_width(cr, 2);
39 cairo_stroke(cr); 44 cairo_stroke(cr);
40 } 45 }
41 46
42 int 47 int