Mercurial > MadButterfly
comparison src/paint.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 | |
children | cf6d65398619 |
comparison
equal
deleted
inserted
replaced
17:41f0907b27ac | 18:0f3baa488a62 |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <cairo.h> | |
4 #include "paint.h" | |
5 | |
6 typedef struct _paint_color { | |
7 paint_t paint; | |
8 co_comp_t r, g, b; | |
9 redraw_man_t *rdman; | |
10 } paint_color_t; | |
11 | |
12 | |
13 static void paint_color_prepare(paint_t *paint, cairo_t *cr) { | |
14 paint_color_t *color = (paint_color_t *)paint; | |
15 | |
16 cairo_set_source_rgb(cr, color->r, color->g, color->b); | |
17 } | |
18 | |
19 static void paint_color_free(paint_t *paint) { | |
20 paint_color_t *color = (paint_color_t *)paint; | |
21 | |
22 shnode_list_free(color->rdman, paint->members); | |
23 free(paint); | |
24 } | |
25 | |
26 paint_t *paint_color_new(redraw_man_t *rdman, | |
27 co_comp_t r, co_comp_t g, co_comp_t b) { | |
28 paint_color_t *color; | |
29 | |
30 color = (paint_color_t *)malloc(sizeof(paint_color_t)); | |
31 if(color == NULL) | |
32 return NULL; | |
33 color->rdman = rdman; | |
34 color->r = r; | |
35 color->g = g; | |
36 color->b = b; | |
37 color->paint.prepare = paint_color_prepare; | |
38 color->paint.free = paint_color_free; | |
39 STAILQ_INIT(color->paint.members); | |
40 return (paint_t *)color; | |
41 } | |
42 | |
43 void paint_color_set(paint_t *paint, | |
44 co_comp_t r, co_comp_t g, co_comp_t b) { | |
45 paint_color_t *color = (paint_color_t *)paint; | |
46 | |
47 color->r = r; | |
48 color->g = g; | |
49 color->b = b; | |
50 } |