Mercurial > MadButterfly
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/paint.c Sat Aug 02 14:45:42 2008 +0800 @@ -0,0 +1,50 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cairo.h> +#include "paint.h" + +typedef struct _paint_color { + paint_t paint; + co_comp_t r, g, b; + redraw_man_t *rdman; +} paint_color_t; + + +static void paint_color_prepare(paint_t *paint, cairo_t *cr) { + paint_color_t *color = (paint_color_t *)paint; + + cairo_set_source_rgb(cr, color->r, color->g, color->b); +} + +static void paint_color_free(paint_t *paint) { + paint_color_t *color = (paint_color_t *)paint; + + shnode_list_free(color->rdman, paint->members); + free(paint); +} + +paint_t *paint_color_new(redraw_man_t *rdman, + co_comp_t r, co_comp_t g, co_comp_t b) { + paint_color_t *color; + + color = (paint_color_t *)malloc(sizeof(paint_color_t)); + if(color == NULL) + return NULL; + color->rdman = rdman; + color->r = r; + color->g = g; + color->b = b; + color->paint.prepare = paint_color_prepare; + color->paint.free = paint_color_free; + STAILQ_INIT(color->paint.members); + return (paint_t *)color; +} + +void paint_color_set(paint_t *paint, + co_comp_t r, co_comp_t g, co_comp_t b) { + paint_color_t *color = (paint_color_t *)paint; + + color->r = r; + color->g = g; + color->b = b; +}