comparison src/X_main.c @ 55:01ed2bc37eed

Radial gradient paint
author Thinker K.F. Li <thinker@branda.to>
date Sun, 10 Aug 2008 16:44:21 +0800
parents 1b6dbafdf906
children e444a8c01735
comparison
equal deleted inserted replaced
54:1b6dbafdf906 55:01ed2bc37eed
125 cairo_surface_t *tmpsuf; 125 cairo_surface_t *tmpsuf;
126 redraw_man_t rdman; 126 redraw_man_t rdman;
127 shape_t *path1, *path2, *rect; 127 shape_t *path1, *path2, *rect;
128 coord_t *coord1, *coord2, *coord3; 128 coord_t *coord1, *coord2, *coord3;
129 paint_t *fill1, *fill2, *fill3; 129 paint_t *fill1, *fill2, *fill3;
130 paint_t *text_fill;
131 grad_stop_t text_stops[2];
130 paint_t *stroke, *text_stroke; 132 paint_t *stroke, *text_stroke;
131 shape_t *text; 133 shape_t *text;
132 grad_stop_t fill3_stops[3]; 134 grad_stop_t fill3_stops[3];
133 cairo_font_face_t *face; 135 cairo_font_face_t *face;
134 struct timeval tv; 136 struct timeval tv;
153 text_stroke = paint_color_new(&rdman, 0.5, 0.5, 0.5, 1); 155 text_stroke = paint_color_new(&rdman, 0.5, 0.5, 0.5, 1);
154 156
155 face = cairo_get_font_face(tmpcr); 157 face = cairo_get_font_face(tmpcr);
156 text = sh_text_new("hello \xe6\xbc\xa2\xe5\xad\x97", 10, h / 4, 158 text = sh_text_new("hello \xe6\xbc\xa2\xe5\xad\x97", 10, h / 4,
157 36.0, face); 159 36.0, face);
160 grad_stop_init(text_stops, 0, 0.2, 0.9, 0.2, 1);
161 grad_stop_init(text_stops + 1, 1, 0.9, 0.2, 0.2, 0.1);
162 text_fill = paint_radial_new(&rdman, 100, h / 4, 70, 2, text_stops);
158 rdman_paint_stroke(&rdman, text_stroke, text); 163 rdman_paint_stroke(&rdman, text_stroke, text);
159 text->stroke_width = 0.5; 164 text->stroke_width = 0.5;
160 rdman_paint_fill(&rdman, fill1, text); 165 rdman_paint_fill(&rdman, text_fill, text);
161 rdman_add_shape(&rdman, text, coord3); 166 rdman_add_shape(&rdman, text, coord3);
162 167
163 path1 = 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 "); 168 path1 = 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 ");
164 rdman_paint_fill(&rdman, fill1, path1); 169 rdman_paint_fill(&rdman, fill1, path1);
165 rdman_paint_stroke(&rdman, stroke, path1); 170 rdman_paint_stroke(&rdman, stroke, path1);
235 240
236 fill1->free(fill1); 241 fill1->free(fill1);
237 fill2->free(fill2); 242 fill2->free(fill2);
238 stroke->free(stroke); 243 stroke->free(stroke);
239 text_stroke->free(text_stroke); 244 text_stroke->free(text_stroke);
245 text_fill->free(text_fill);
240 redraw_man_destroy(&rdman); 246 redraw_man_destroy(&rdman);
241 sh_path_free(path1); 247 sh_path_free(path1);
242 sh_path_free(path2); 248 sh_path_free(path2);
243 sh_rect_free(rect); 249 sh_rect_free(rect);
244 sh_text_free(text); 250 sh_text_free(text);