Mercurial > MadButterfly
annotate src/paint.c @ 320:6e164a9dd46c
Fix the Makefile to generate files correctly.
The filebrowser is not working yet.
author | wycc |
---|---|
date | Thu, 05 Mar 2009 08:19:43 +0800 |
parents | 43900cae1d49 |
children | 04d22dc38bc0 |
rev | line source |
---|---|
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #include <stdio.h> |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 #include <stdlib.h> |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 #include <cairo.h> |
186
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
4 #include "mb_paint.h" |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 |
55 | 6 #define ASSERT(x) |
7 | |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
8 /*! \brief Solid color paint. |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
9 */ |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
10 typedef struct _paint_color { |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 paint_t paint; |
21 | 12 co_comp_t r, g, b, a; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
13 } paint_color_t; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 |
147
995ee8fd5f1a
Use local static variable to hold position array to reduce using malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
146
diff
changeset
|
15 int _paint_color_size = sizeof(paint_color_t); |
146
e96a584487af
Use elmpool to manage paint_color_t objects.
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
16 |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
17 |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
18 static void paint_color_prepare(paint_t *paint, cairo_t *cr) { |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 paint_color_t *color = (paint_color_t *)paint; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 |
21 | 21 cairo_set_source_rgba(cr, color->r, color->g, color->b, color->a); |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
22 } |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
23 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
24 static void paint_color_free(redraw_man_t *rdman, paint_t *paint) { |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
25 shnode_list_free(rdman, paint->members); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
26 paint_destroy(paint); |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
27 elmpool_elm_free(rdman->paint_color_pool, paint); |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
28 } |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
29 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
30 paint_t *rdman_paint_color_new(redraw_man_t *rdman, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
31 co_comp_t r, co_comp_t g, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
32 co_comp_t b, co_comp_t a) { |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
33 paint_color_t *color; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
34 |
146
e96a584487af
Use elmpool to manage paint_color_t objects.
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
35 color = (paint_color_t *)elmpool_elm_alloc(rdman->paint_color_pool); |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 if(color == NULL) |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
37 return NULL; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
38 color->r = r; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 color->g = g; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 color->b = b; |
21 | 41 color->a = a; |
19 | 42 paint_init(&color->paint, paint_color_prepare, paint_color_free); |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
43 return (paint_t *)color; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
44 } |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
45 |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
46 void paint_color_set(paint_t *paint, |
21 | 47 co_comp_t r, co_comp_t g, |
48 co_comp_t b, co_comp_t a) { | |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
49 paint_color_t *color = (paint_color_t *)paint; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
50 |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
51 color->r = r; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
52 color->g = g; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
53 color->b = b; |
21 | 54 color->a = a; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
55 } |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
56 |
52
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
57 void paint_color_get(paint_t *paint, |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
58 co_comp_t *r, co_comp_t *g, |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
59 co_comp_t *b, co_comp_t *a) { |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
60 paint_color_t *color = (paint_color_t *)paint; |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
61 |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
62 *r = color->r; |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
63 *g = color->g; |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
64 *b = color->b; |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
65 *a = color->a; |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
66 } |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
67 |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
68 /*! \brief Linear gradient. |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
69 */ |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
70 typedef struct _paint_linear { |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
71 paint_t paint; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
72 co_aix x1, y1; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
73 co_aix x2, y2; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
74 int n_stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
75 grad_stop_t *stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
76 int flags; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
77 cairo_pattern_t *ptn; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
78 } paint_linear_t; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
79 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
80 #define LIF_DIRTY 0x1 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
81 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
82 static void paint_linear_prepare(paint_t *paint, cairo_t *cr) { |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
83 paint_linear_t *linear = (paint_linear_t *)paint; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
84 cairo_pattern_t *ptn; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
85 grad_stop_t *stop; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
86 int i; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
87 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
88 ptn = linear->ptn; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
89 if(linear->flags & LIF_DIRTY) { |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
90 if(ptn) |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
91 cairo_pattern_destroy(ptn); |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
92 linear->flags &= ~LIF_DIRTY; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
93 ptn = cairo_pattern_create_linear(linear->x1, linear->y1, |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
94 linear->x2, linear->y2); |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
95 for(i = 0; i < linear->n_stops; i++) { |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
96 stop = &linear->stops[i]; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
97 cairo_pattern_add_color_stop_rgba(ptn, stop->offset, |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
98 stop->r, stop->g, stop->b, |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
99 stop->a); |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
100 } |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
101 linear->ptn = ptn; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
102 } |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
103 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
104 cairo_set_source(cr, ptn); |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
105 } |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
106 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
107 static void paint_linear_free(redraw_man_t *rdman, paint_t *paint) { |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
108 paint_linear_t *linear = (paint_linear_t *)paint; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
109 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
110 if(linear->ptn) |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
111 cairo_pattern_destroy(linear->ptn); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
112 paint_destroy(paint); |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
113 free(paint); |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
114 } |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
115 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
116 paint_t *rdman_paint_linear_new(redraw_man_t *rdman, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
117 co_aix x1, co_aix y1, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
118 co_aix x2, co_aix y2) { |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
119 paint_linear_t *linear; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
120 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
121 linear = (paint_linear_t *)malloc(sizeof(paint_linear_t)); |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
122 if(linear == NULL) |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
123 return NULL; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
124 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
125 paint_init(&linear->paint, paint_linear_prepare, paint_linear_free); |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
126 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
127 linear->x1 = x1; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
128 linear->y1 = y1; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
129 linear->x2 = x2; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
130 linear->y2 = y2; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
131 linear->n_stops = 0; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
132 linear->stops = NULL; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
133 linear->flags = LIF_DIRTY; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
134 linear->ptn = NULL; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
135 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
136 return (paint_t *)linear; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
137 } |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
138 |
58 | 139 /*! \brief Setup color stop for a linear radient paint. |
140 * | |
141 * stops should be managed by users of the function. It should be | |
142 * available before the paint being freed or changed to another | |
143 * array of stops. | |
144 */ | |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
145 grad_stop_t *paint_linear_stops(paint_t *paint, |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
146 int n_stops, |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
147 grad_stop_t *stops) { |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
148 paint_linear_t *linear = (paint_linear_t *)paint; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
149 grad_stop_t *old_stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
150 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
151 old_stops = linear->stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
152 linear->n_stops = n_stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
153 linear->stops = stops; |
55 | 154 linear->flags |= LIF_DIRTY; |
155 | |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
156 return old_stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
157 } |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
158 |
55 | 159 /*! \brief Radial gradient. |
160 * | |
161 * NOTE: The only supported gradient unit is userSpaceOnUse. | |
162 */ | |
163 typedef struct _paint_radial { | |
164 paint_t paint; | |
165 co_aix cx, cy; | |
166 co_aix r; | |
167 int n_stops; | |
168 grad_stop_t *stops; | |
169 int flags; | |
170 cairo_pattern_t *ptn; | |
171 } paint_radial_t; | |
172 | |
173 #define RDF_DIRTY 0x1 | |
174 | |
175 static void paint_radial_prepare(paint_t *paint, cairo_t *cr) { | |
176 paint_radial_t *radial = (paint_radial_t *)paint; | |
177 cairo_pattern_t *ptn; | |
178 grad_stop_t *stop; | |
179 int i; | |
180 | |
181 if(radial->flags & RDF_DIRTY) { | |
182 ptn = cairo_pattern_create_radial(radial->cx, radial->cy, 0, | |
183 radial->cx, radial->cy, | |
184 radial->r); | |
185 ASSERT(ptn != NULL); | |
186 stop = radial->stops; | |
187 for(i = 0; i < radial->n_stops; i++, stop++) { | |
188 cairo_pattern_add_color_stop_rgba(ptn, stop->offset, | |
189 stop->r, stop->g, | |
190 stop->b, stop->a); | |
191 } | |
192 cairo_pattern_destroy(radial->ptn); | |
193 radial->ptn = ptn; | |
194 } | |
195 cairo_set_source(cr, radial->ptn); | |
196 } | |
197 | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
198 static void paint_radial_free(redraw_man_t *rdman, paint_t *paint) { |
55 | 199 paint_radial_t *radial = (paint_radial_t *)paint; |
200 | |
201 if(radial->ptn) | |
202 cairo_pattern_destroy(radial->ptn); | |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
203 paint_destroy(paint); |
55 | 204 free(paint); |
205 } | |
206 | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
207 paint_t *rdman_paint_radial_new(redraw_man_t *rdman, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
208 co_aix cx, co_aix cy, co_aix r) { |
55 | 209 paint_radial_t *radial; |
210 | |
211 radial = O_ALLOC(paint_radial_t); | |
212 if(radial == NULL) | |
213 return NULL; | |
214 | |
215 paint_init(&radial->paint, paint_radial_prepare, paint_radial_free); | |
216 radial->cx = cx; | |
217 radial->cy = cy; | |
218 radial->r = r; | |
56
e444a8c01735
Change interface of paint_radial_new()
Thinker K.F. Li <thinker@branda.to>
parents:
55
diff
changeset
|
219 radial->n_stops = 0; |
e444a8c01735
Change interface of paint_radial_new()
Thinker K.F. Li <thinker@branda.to>
parents:
55
diff
changeset
|
220 radial->stops = NULL; |
55 | 221 radial->flags = RDF_DIRTY; |
222 radial->ptn = NULL; | |
223 | |
224 return (paint_t *)radial; | |
225 } | |
226 | |
58 | 227 /*! \brief Setup color stop for a radial radient paint. |
228 * | |
229 * stops should be managed by users of the function. It should be | |
230 * available before the paint being freed or changed to another | |
231 * array of stops. | |
232 */ | |
55 | 233 grad_stop_t *paint_radial_stops(paint_t *paint, |
234 int n_stops, | |
235 grad_stop_t *stops) { | |
236 paint_radial_t *radial = (paint_radial_t *)paint; | |
237 grad_stop_t *old_stops; | |
238 | |
239 old_stops = radial->stops; | |
240 radial->n_stops = n_stops; | |
241 radial->stops = stops; | |
242 radial->flags |= RDF_DIRTY; | |
243 | |
244 return old_stops; | |
245 } | |
246 | |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
247 |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
248 /*! \brief Using an image as a paint. |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
249 * |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
250 * This type of paints fill/stroke shapes with an image. |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
251 */ |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
252 typedef struct _paint_image { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
253 paint_t paint; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
254 mb_img_data_t *img; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
255 cairo_surface_t *surf; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
256 cairo_pattern_t *ptn; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
257 } paint_image_t; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
258 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
259 static |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
260 void paint_image_prepare(paint_t *paint, cairo_t *cr) { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
261 paint_image_t *paint_img = (paint_image_t *)paint; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
262 mb_img_data_t *img_data; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
263 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
264 img_data = paint_img->img; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
265 cairo_set_source(cr, paint_img->ptn); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
266 } |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
267 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
268 static |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
269 void paint_image_free(redraw_man_t *rdman, paint_t *paint) { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
270 paint_image_t *paint_img = (paint_image_t *)paint; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
271 mb_img_data_t *img_data; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
272 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
273 cairo_surface_destroy(paint_img->surf); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
274 img_data = paint_img->img; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
275 MB_IMG_DATA_FREE(img_data); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
276 paint_destroy(&paint_img->paint); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
277 free(paint); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
278 } |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
279 |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
280 /*! \brief Create an image painter. |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
281 * |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
282 * Create a painter that fill/stroke shapes with an image. |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
283 */ |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
284 paint_t *rdman_paint_image_new(redraw_man_t *rdman, |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
285 mb_img_data_t *img) { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
286 paint_image_t *paint; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
287 int fmt; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
288 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
289 switch(img->fmt) { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
290 case MB_IFMT_ARGB32: |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
291 fmt = CAIRO_FORMAT_ARGB32; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
292 break; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
293 case MB_IFMT_RGB24: |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
294 fmt = CAIRO_FORMAT_RGB24; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
295 break; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
296 case MB_IFMT_A8: |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
297 fmt = CAIRO_FORMAT_A8; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
298 break; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
299 case MB_IFMT_A1: |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
300 fmt = CAIRO_FORMAT_A1; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
301 break; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
302 default: |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
303 return NULL; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
304 } |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
305 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
306 paint = O_ALLOC(paint_image_t); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
307 if(paint == NULL) |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
308 return NULL; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
309 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
310 paint_init(&paint->paint, paint_image_prepare, paint_image_free); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
311 paint->img = img; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
312 paint->surf = cairo_image_surface_create_for_data(img->content, |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
313 fmt, |
268
43900cae1d49
Support resizing for image.
Thinker K.F. Li <thinker@branda.to>
parents:
265
diff
changeset
|
314 img->w, |
43900cae1d49
Support resizing for image.
Thinker K.F. Li <thinker@branda.to>
parents:
265
diff
changeset
|
315 img->h, |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
316 img->stride); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
317 if(paint->surf == NULL) { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
318 paint_destroy(&paint->paint); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
319 free(paint); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
320 return NULL; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
321 } |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
322 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
323 paint->ptn = cairo_pattern_create_for_surface(paint->surf); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
324 if(paint->ptn == NULL) { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
325 paint_destroy(&paint->paint); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
326 cairo_surface_destroy(paint->surf); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
327 free(paint); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
328 return NULL; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
329 } |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
330 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
331 return (paint_t *)paint; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
332 } |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
333 |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
334 /*! \brief Setting transformation from user space to image space. |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
335 * |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
336 * This transformation matrix maps points drawed in user space to |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
337 * corresponding points in image space. It is used to resample |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
338 * the image to generate pixels of result image. |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
339 */ |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
340 void paint_image_set_matrix(paint_t *paint, co_aix matrix[6]) { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
341 paint_image_t *img_paint = (paint_image_t *)paint; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
342 cairo_matrix_t cmatrix; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
343 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
344 cmatrix.xx = matrix[0]; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
345 cmatrix.xy = matrix[1]; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
346 cmatrix.x0 = matrix[2]; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
347 cmatrix.yx = matrix[3]; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
348 cmatrix.yy = matrix[4]; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
349 cmatrix.y0 = matrix[5]; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
350 cairo_pattern_set_matrix(img_paint->ptn, &cmatrix); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
351 } |