Mercurial > MadButterfly
annotate src/paint.c @ 1472:7cb7abb5063b
Refactory drawing functions into classes for state and transition
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 24 Apr 2011 15:13:41 +0800 |
parents | 7bd6c0e88ec8 |
children |
rev | line source |
---|---|
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- |
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 #include <stdio.h> |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 #include <stdlib.h> |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
5 #include "mb_graph_engine.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
|
6 #include "mb_paint.h" |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 |
55 | 8 #define ASSERT(x) |
9 | |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
10 /*! \brief Solid color paint. |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
11 */ |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
12 typedef struct _paint_color { |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
13 paint_t paint; |
21 | 14 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
|
15 } paint_color_t; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
16 |
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
|
17 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
|
18 |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 |
881
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
20 static void paint_color_prepare(paint_t *paint, mbe_t *cr, shape_t *sh) { |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
21 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
|
22 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
23 mbe_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
|
24 } |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
25 |
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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 } |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
31 |
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
|
32 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
|
33 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
|
34 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
|
35 paint_color_t *color; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 |
146
e96a584487af
Use elmpool to manage paint_color_t objects.
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
37 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
|
38 if(color == NULL) |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 return NULL; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 color->r = r; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 color->g = g; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 color->b = b; |
21 | 43 color->a = a; |
356
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
44 paint_init(&color->paint, MBP_COLOR, |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
45 paint_color_prepare, paint_color_free); |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
46 return (paint_t *)color; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
47 } |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
48 |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
49 void paint_color_set(paint_t *paint, |
21 | 50 co_comp_t r, co_comp_t g, |
51 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
|
52 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
|
53 |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
54 color->r = r; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
55 color->g = g; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
56 color->b = b; |
21 | 57 color->a = a; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
58 } |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
59 |
52
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
60 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
|
61 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
|
62 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
|
63 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
|
64 |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
65 *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
|
66 *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
|
67 *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
|
68 *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
|
69 } |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
70 |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
71 /*! \brief Linear gradient. |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
72 */ |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
73 typedef struct _paint_linear { |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
74 paint_t paint; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
75 co_aix x1, y1; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
76 co_aix x2, y2; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
77 int n_stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
78 grad_stop_t *stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
79 int flags; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
80 mbe_pattern_t *ptn; |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
81 } paint_linear_t; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
82 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
83 #define LIF_DIRTY 0x1 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
84 |
867
4f8d53be9488
Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
85 int _paint_linear_size = sizeof(paint_linear_t); |
4f8d53be9488
Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
86 |
881
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
87 static void paint_linear_prepare(paint_t *paint, mbe_t *cr, shape_t *sh) { |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
88 paint_linear_t *linear = (paint_linear_t *)paint; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
89 mbe_pattern_t *ptn; |
881
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
90 co_aix x1, y1; |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
91 co_aix x2, y2; |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
92 co_aix *mtx; |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
93 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
94 ptn = linear->ptn; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
95 if(linear->flags & LIF_DIRTY) { |
881
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
96 mtx = sh_get_aggr_matrix(sh); |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
97 x1 = linear->x1; |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
98 y1 = linear->y1; |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
99 matrix_trans_pos(mtx, &x1, &y1); |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
100 x2 = linear->x2; |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
101 y2 = linear->y2; |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
102 matrix_trans_pos(mtx, &x2, &y2); |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
103 |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
104 if(ptn) |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
105 mbe_pattern_destroy(ptn); |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
106 linear->flags &= ~LIF_DIRTY; |
881
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
107 ptn = mbe_pattern_create_linear(x1, y1, x2, y2, |
480
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
108 linear->stops, linear->n_stops); |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
109 ASSERT(ptn != NULL); |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
110 linear->ptn = ptn; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
111 } |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
112 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
113 mbe_set_source(cr, ptn); |
23
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 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
|
117 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
|
118 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
119 if(linear->ptn) |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
120 mbe_pattern_destroy(linear->ptn); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
121 paint_destroy(paint); |
868
f41ac71266bc
Remove rdman pointer from structure of paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
867
diff
changeset
|
122 elmpool_elm_free(rdman->paint_linear_pool, linear); |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
123 } |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
124 |
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
|
125 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
|
126 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
|
127 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
|
128 paint_linear_t *linear; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
129 |
867
4f8d53be9488
Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
130 linear = (paint_linear_t *)elmpool_elm_alloc(rdman->paint_linear_pool); |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
131 if(linear == NULL) |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
132 return NULL; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
133 |
356
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
134 paint_init(&linear->paint, MBP_LINEAR, |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
135 paint_linear_prepare, paint_linear_free); |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
136 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
137 linear->x1 = x1; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
138 linear->y1 = y1; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
139 linear->x2 = x2; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
140 linear->y2 = y2; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
141 linear->n_stops = 0; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
142 linear->stops = NULL; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
143 linear->flags = LIF_DIRTY; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
144 linear->ptn = NULL; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
145 |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
146 return (paint_t *)linear; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
147 } |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
148 |
58 | 149 /*! \brief Setup color stop for a linear radient paint. |
150 * | |
151 * stops should be managed by users of the function. It should be | |
152 * available before the paint being freed or changed to another | |
153 * array of stops. | |
154 */ | |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
155 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
|
156 int n_stops, |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
157 grad_stop_t *stops) { |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
158 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
|
159 grad_stop_t *old_stops; |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
160 |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
161 old_stops = linear->stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
162 linear->n_stops = n_stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
163 linear->stops = stops; |
55 | 164 linear->flags |= LIF_DIRTY; |
165 | |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
166 return old_stops; |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
167 } |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
21
diff
changeset
|
168 |
55 | 169 /*! \brief Radial gradient. |
170 * | |
171 * NOTE: The only supported gradient unit is userSpaceOnUse. | |
172 */ | |
173 typedef struct _paint_radial { | |
174 paint_t paint; | |
175 co_aix cx, cy; | |
176 co_aix r; | |
177 int n_stops; | |
178 grad_stop_t *stops; | |
179 int flags; | |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
180 mbe_pattern_t *ptn; |
55 | 181 } paint_radial_t; |
182 | |
183 #define RDF_DIRTY 0x1 | |
184 | |
1087
cd34de1a6960
Fix issue of incorrect color for color paint.
Thinker K.F. Li <thinker@codemud.net>
parents:
1083
diff
changeset
|
185 #define pnt_radial_clear_flags(radial, _flags) \ |
cd34de1a6960
Fix issue of incorrect color for color paint.
Thinker K.F. Li <thinker@codemud.net>
parents:
1083
diff
changeset
|
186 do { \ |
cd34de1a6960
Fix issue of incorrect color for color paint.
Thinker K.F. Li <thinker@codemud.net>
parents:
1083
diff
changeset
|
187 (radial)->flags &= ~(_flags); \ |
cd34de1a6960
Fix issue of incorrect color for color paint.
Thinker K.F. Li <thinker@codemud.net>
parents:
1083
diff
changeset
|
188 } while(0) |
cd34de1a6960
Fix issue of incorrect color for color paint.
Thinker K.F. Li <thinker@codemud.net>
parents:
1083
diff
changeset
|
189 |
867
4f8d53be9488
Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
190 int _paint_radial_size = sizeof(paint_radial_t); |
4f8d53be9488
Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
191 |
881
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
192 static void paint_radial_prepare(paint_t *paint, mbe_t *cr, shape_t *sh) { |
55 | 193 paint_radial_t *radial = (paint_radial_t *)paint; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
194 mbe_pattern_t *ptn; |
881
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
195 co_aix cx, cy; |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
196 co_aix *mtx; |
55 | 197 |
198 if(radial->flags & RDF_DIRTY) { | |
881
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
199 mtx = sh_get_aggr_matrix(sh); |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
200 cx = radial->cx; |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
201 cy = radial->cy; |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
202 matrix_trans_pos(mtx, &cx, &cy); |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
203 |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
204 ptn = mbe_pattern_create_radial(cx, cy, 0, |
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
205 cx, cy, |
480
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
206 radial->r, |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
207 radial->stops, |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
208 radial->n_stops); |
55 | 209 ASSERT(ptn != NULL); |
1083
555d89e704c0
Check if the pattern is NULL for free it for a radial paint
Thinker K.F. Li <thinker@codemud.net>
parents:
1067
diff
changeset
|
210 if(radial->ptn) |
555d89e704c0
Check if the pattern is NULL for free it for a radial paint
Thinker K.F. Li <thinker@codemud.net>
parents:
1067
diff
changeset
|
211 mbe_pattern_destroy(radial->ptn); |
55 | 212 radial->ptn = ptn; |
1087
cd34de1a6960
Fix issue of incorrect color for color paint.
Thinker K.F. Li <thinker@codemud.net>
parents:
1083
diff
changeset
|
213 |
cd34de1a6960
Fix issue of incorrect color for color paint.
Thinker K.F. Li <thinker@codemud.net>
parents:
1083
diff
changeset
|
214 pnt_radial_clear_flags(radial, RDF_DIRTY); |
55 | 215 } |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
216 mbe_set_source(cr, radial->ptn); |
55 | 217 } |
218 | |
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
|
219 static void paint_radial_free(redraw_man_t *rdman, paint_t *paint) { |
55 | 220 paint_radial_t *radial = (paint_radial_t *)paint; |
221 | |
222 if(radial->ptn) | |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
223 mbe_pattern_destroy(radial->ptn); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
224 paint_destroy(paint); |
868
f41ac71266bc
Remove rdman pointer from structure of paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
867
diff
changeset
|
225 elmpool_elm_free(rdman->paint_radial_pool, radial); |
55 | 226 } |
227 | |
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
|
228 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
|
229 co_aix cx, co_aix cy, co_aix r) { |
55 | 230 paint_radial_t *radial; |
231 | |
867
4f8d53be9488
Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
232 radial = elmpool_elm_alloc(rdman->paint_radial_pool); |
55 | 233 if(radial == NULL) |
234 return NULL; | |
235 | |
356
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
236 paint_init(&radial->paint, MBP_RADIAL, |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
237 paint_radial_prepare, paint_radial_free); |
55 | 238 radial->cx = cx; |
239 radial->cy = cy; | |
240 radial->r = r; | |
56
e444a8c01735
Change interface of paint_radial_new()
Thinker K.F. Li <thinker@branda.to>
parents:
55
diff
changeset
|
241 radial->n_stops = 0; |
e444a8c01735
Change interface of paint_radial_new()
Thinker K.F. Li <thinker@branda.to>
parents:
55
diff
changeset
|
242 radial->stops = NULL; |
55 | 243 radial->flags = RDF_DIRTY; |
244 radial->ptn = NULL; | |
245 | |
246 return (paint_t *)radial; | |
247 } | |
248 | |
58 | 249 /*! \brief Setup color stop for a radial radient paint. |
250 * | |
251 * stops should be managed by users of the function. It should be | |
252 * available before the paint being freed or changed to another | |
253 * array of stops. | |
254 */ | |
55 | 255 grad_stop_t *paint_radial_stops(paint_t *paint, |
256 int n_stops, | |
257 grad_stop_t *stops) { | |
258 paint_radial_t *radial = (paint_radial_t *)paint; | |
259 grad_stop_t *old_stops; | |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
260 |
55 | 261 old_stops = radial->stops; |
262 radial->n_stops = n_stops; | |
263 radial->stops = stops; | |
264 radial->flags |= RDF_DIRTY; | |
265 | |
266 return old_stops; | |
267 } | |
268 | |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
269 |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
270 /*! \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
|
271 * |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
272 * 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
|
273 */ |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
274 typedef struct _paint_image { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
275 paint_t paint; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
276 mb_img_data_t *img; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
277 mbe_pattern_t *ptn; |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
278 } paint_image_t; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
279 |
867
4f8d53be9488
Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
280 int _paint_image_size = sizeof(paint_image_t); |
4f8d53be9488
Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
281 |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
282 static |
881
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
868
diff
changeset
|
283 void paint_image_prepare(paint_t *paint, mbe_t *cr, shape_t *sh) { |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
284 paint_image_t *paint_img = (paint_image_t *)paint; |
1433
7bd6c0e88ec8
Fix issue of showing image incorrectly.
Thinker K.F. Li <thinker@codemud.net>
parents:
1096
diff
changeset
|
285 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
286 mbe_set_source(cr, paint_img->ptn); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
287 } |
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 static |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
290 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
|
291 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
|
292 mb_img_data_t *img_data; |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
293 |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
294 img_data = paint_img->img; |
356
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
295 MB_IMG_DATA_FREE(img_data); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
296 paint_destroy(&paint_img->paint); |
1433
7bd6c0e88ec8
Fix issue of showing image incorrectly.
Thinker K.F. Li <thinker@codemud.net>
parents:
1096
diff
changeset
|
297 mbe_pattern_destroy(paint_img->ptn); |
868
f41ac71266bc
Remove rdman pointer from structure of paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
867
diff
changeset
|
298 elmpool_elm_free(rdman->paint_image_pool, paint_img); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
299 } |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
300 |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
301 /*! \brief Create an image painter. |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
302 * |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
303 * Create a painter that fill/stroke shapes with an image. |
348
04d22dc38bc0
Change declaration of sh_image_set_img_data().
Thinker K.F. Li <thinker@branda.to>
parents:
268
diff
changeset
|
304 * |
356
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
305 * \param img is image data return by image load. |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
306 * Owner-ship of img is transfered. |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
307 */ |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
308 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
|
309 mb_img_data_t *img) { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
310 paint_image_t *paint; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
311 |
867
4f8d53be9488
Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
312 paint = elmpool_elm_alloc(rdman->paint_image_pool); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
313 if(paint == NULL) |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
314 return NULL; |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
315 |
356
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
316 paint_init(&paint->paint, MBP_IMAGE, |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
317 paint_image_prepare, paint_image_free); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
318 paint->img = img; |
1096
c18ad321844d
Create a pattern, for an image paint, from image directly.
Thinker K.F. Li <thinker@codemud.net>
parents:
1087
diff
changeset
|
319 paint->ptn = mbe_pattern_create_image(img); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
320 if(paint->ptn == NULL) { |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
321 paint_destroy(&paint->paint); |
867
4f8d53be9488
Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
322 elmpool_elm_free(rdman->paint_image_pool, paint); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
323 return NULL; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
324 } |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
325 |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
326 return (paint_t *)paint; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
327 } |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
328 |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
329 /*! \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
|
330 * |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
331 * 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
|
332 * 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
|
333 * 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
|
334 */ |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
335 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
|
336 paint_image_t *img_paint = (paint_image_t *)paint; |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
337 |
473
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
450
diff
changeset
|
338 mbe_pattern_set_matrix(img_paint->ptn, matrix); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
339 } |
356
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
340 |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
341 void paint_image_get_size(paint_t *paint, int *w, int *h) { |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
342 paint_image_t *ipaint = (paint_image_t *)paint; |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
343 |
356
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
344 ASSERT(paint->pnt_type == MBP_IMAGE); |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
345 *w = ipaint->img->w; |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
346 *h = ipaint->img->h; |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
348
diff
changeset
|
347 } |