Mercurial > MadButterfly
annotate tools/mb_c_source.m4 @ 159:b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
- Life-cycle of shapes and paints are managed by rdman.
- Add redraw_man_t::free_objs to collect objects their freeing are
postonsed.
Know Issue:
- Bullet of tank are not removed from screen when it is go out the range
of the map.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 05 Oct 2008 23:32:58 +0800 |
parents | 6ce68c1f7405 |
children | 530bb7728546 |
rev | line source |
---|---|
63 | 1 changequote(`[', `]')dnl |
2 include([foreach.m4])dnl | |
3 divert([-1]) | |
4 | |
64 | 5 define([UNQUOTE], [$*]) |
6 | |
7 define([QUOTE], [[[$*]]]) | |
63 | 8 |
64 | 9 define([COUNT],[ifelse([$*],[],0,[$#])]) |
63 | 10 |
64 | 11 define([IMPORT],[define([$1],[$2$1(]$[]@[)])]) |
63 | 12 |
64 | 13 define([D_COLOR_STOP],[ |
14 {$6,$2,$3,$4,$5}]) | |
63 | 15 |
16 define([D_ADD_LINEAR_PAINT],[dnl | |
64 | 17 ifelse(COUNT($6),0,,[dnl |
18 static const int n_$1_stops = COUNT($6); | |
19 static const grad_stop_t $1_stops[[]] = {UNQUOTE($6)}; | |
63 | 20 ])dnl |
21 ]) | |
22 | |
23 define([D_ADD_RADIAL_PAINT],[dnl | |
64 | 24 ifelse(COUNT($5),0,,[dnl |
25 static const int n_$1_stops = COUNT($5); | |
26 static const grad_stop_t $1_stops[[]] = {UNQUOTE($5)}; | |
63 | 27 ])dnl |
28 ]) | |
29 | |
30 define([DECLARE_VARS], [divert([-1]) | |
64 | 31 define([DIMPORT],[IMPORT(]QUOTE($[]1)[,[D_])]) |
32 DIMPORT([ADD_LINEAR_PAINT]) | |
33 DIMPORT([ADD_RADIAL_PAINT]) | |
34 DIMPORT([COLOR_STOP]) | |
78 | 35 define([REF_STOPS_RADIAL]) |
36 define([REF_STOPS_LINEAR]) | |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
69
diff
changeset
|
37 define([ADD_PATH]) |
64 | 38 define([ADD_RECT]) |
39 define([ADD_COORD]) | |
83 | 40 define([ADD_TEXT],) |
64 | 41 define([FILL_SHAPE]) |
42 define([STROKE_SHAPE]) | |
43 define([FILL_SHAPE_WITH_PAINT]) | |
44 define([STROKE_SHAPE_WITH_PAINT]) | |
80
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
45 define([STROKE_WIDTH]) |
81 | 46 define([GROUP_HIDE],) |
47 define([RECT_HIDE],) | |
48 define([PATH_HIDE],) | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
49 define([COORD_TRANSLATE],) |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
50 define([COORD_MATRIX],) |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
51 define([SHAPE_TRANSLATE],) |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
52 define([SHAPE_MATRIX],) |
63 | 53 divert[]]) |
54 | |
55 define([S_ADD_LINEAR_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
|
56 obj->$1 = rdman_paint_linear_new(rdman, $2, $3, $4, $5); |
64 | 57 ifelse(COUNT($6),0,,[dnl |
58 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops); | |
59 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops); | |
60 paint_linear_stops(obj->$1, n_$1_stops, stops); | |
61 ])dnl | |
63 | 62 ]) |
64 | 63 |
63 | 64 define([S_ADD_RADIAL_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
|
65 obj->$1 = rdman_paint_radial_new(rdman, $2, $3, $4); |
64 | 66 ifelse(COUNT($5),0,,[ |
67 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops); | |
68 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops); | |
69 paint_radial_stops(obj->$1, n_$1_stops, stops); | |
70 ])dnl | |
63 | 71 ]) |
72 | |
64 | 73 define([S_COLOR_STOP],[]) |
78 | 74 |
75 define([S_REF_STOPS_RADIAL],[dnl | |
64 | 76 [ stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$2_stops); |
77 memcpy(stops, $2_stops, sizeof(grad_stop_t) * n_$2_stops); | |
78 paint_radial_stops(obj->$1, n_$2_stops, stops); | |
79 ]]) | |
80 | |
78 | 81 define([S_REF_STOPS_LINEAR],[dnl |
82 [ stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$2_stops); | |
83 memcpy(stops, $2_stops, sizeof(grad_stop_t) * n_$2_stops); | |
84 paint_linear_stops(obj->$1, n_$2_stops, stops); | |
85 ]]) | |
86 | |
64 | 87 define([S_ADD_RECT],[[ |
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
|
88 obj->$1 = rdman_shape_rect_new(rdman, $2, $3, $4, $5, $6, $7); |
80
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
89 rdman_add_shape(rdman, obj->$1, obj->$8); |
64 | 90 ]]) |
91 | |
92 define([S_ADD_PATH],[[ | |
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
|
93 obj->$1 = rdman_shape_path_new(rdman, "$2"); |
64 | 94 rdman_add_shape(rdman, obj->$1, obj->$3); |
95 ]]) | |
96 | |
97 define([S_ADD_COORD],[[ | |
66
309f1eefbec0
create new coords from redraw_man
Thinker K.F. Li <thinker@branda.to>
parents:
64
diff
changeset
|
98 obj->$1 = rdman_coord_new(rdman, obj->$2); |
64 | 99 ]]) |
100 | |
83 | 101 define([S_ADD_TEXT],[[ |
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
|
102 obj->$1 = rdman_shape_text_new(rdman, "$2", $3, $4, $5, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
103 cairo_get_font_face(rdman->cr)); |
83 | 104 rdman_add_shape(rdman, obj->$1, obj->$6); |
105 ]]) | |
106 | |
64 | 107 define([S_FILL_SHAPE_WITH_PAINT],[dnl |
108 [ rdman_paint_fill(rdman, obj->$2, obj->$1); | |
109 ]]) | |
110 | |
111 define([S_STROKE_SHAPE_WITH_PAINT],[dnl | |
112 [ rdman_paint_stroke(rdman, obj->$2, obj->$1); | |
113 ]]) | |
114 | |
115 define([S_FILL_SHAPE],[dnl | |
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 [ obj->$1_fill = rdman_paint_color_new(rdman, $2, $3, $4, $5); |
64 | 117 rdman_paint_fill(rdman, obj->$1_fill, obj->$1); |
118 ]]) | |
119 | |
120 define([S_STROKE_SHAPE],[dnl | |
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
|
121 [ obj->$1_stroke = rdman_paint_color_new(rdman, $2, $3, $4, $5); |
64 | 122 rdman_paint_stroke(rdman, obj->$1_stroke, obj->$1); |
123 ]]) | |
124 | |
80
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
125 define([S_STROKE_WIDTH],[dnl |
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
126 [ obj->$1->stroke_width = $2; |
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
127 ]]) |
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
128 |
81 | 129 define([S_GROUP_HIDE],[dnl |
130 [ coord_hide(obj->$1); | |
131 ]]) | |
132 | |
133 define([S_RECT_HIDE],[dnl | |
134 [ sh_hide(obj->$1); | |
135 ]]) | |
136 | |
137 define([S_PATH_HIDE],[dnl | |
138 [ sh_hide(obj->$1); | |
139 ]]) | |
140 | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
141 define([S_COORD_TRANSLATE],[dnl |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
142 [ memset(obj->$1->matrix, 0, sizeof(obj->$1->matrix)); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
143 obj->$1->matrix[0] = 1; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
144 obj->$1->matrix[2] = $2; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
145 obj->$1->matrix[4] = 1; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
146 obj->$1->matrix[5] = $3; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
147 rdman_coord_changed(rdman, obj->$1); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
148 ]]) |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
149 |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
150 define([S_COORD_MATRIX],[dnl |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
151 [ obj->$1->matrix[0] = $2; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
152 obj->$1->matrix[3] = $3; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
153 obj->$1->matrix[1] = $4; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
154 obj->$1->matrix[4] = $5; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
155 obj->$1->matrix[2] = $6; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
156 obj->$1->matrix[5] = $7; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
157 rdman_coord_changed(rdman, obj->$1); |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
158 ]]) |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
159 |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
160 define([S_SHAPE_TRANSLATE],[dnl |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
161 [ memset(obj->$1->matrix, 0, sizeof(obj->$1->matrix)); |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
162 obj->$1->matrix[0] = 1; |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
163 obj->$1->matrix[2] = $2; |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
164 obj->$1->matrix[4] = 1; |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
165 obj->$1->matrix[5] = $3; |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
166 rdman_coord_changed(rdman, obj->$1); |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
167 ]]) |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
168 |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
169 define([S_SHAPE_MATRIX],[dnl |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
170 [ obj->$1->matrix[0] = $2; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
171 obj->$1->matrix[3] = $3; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
172 obj->$1->matrix[1] = $4; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
173 obj->$1->matrix[4] = $5; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
174 obj->$1->matrix[2] = $6; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
175 obj->$1->matrix[5] = $7; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
176 rdman_coord_changed(rdman, obj->$1); |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
177 ]]) |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
178 |
63 | 179 define([SETUP_VARS],[divert([-1]) |
64 | 180 define([SIMPORT],[IMPORT(]QUOTE($[]1)[,[S_])]) |
181 SIMPORT([ADD_LINEAR_PAINT]) | |
182 SIMPORT([ADD_RADIAL_PAINT]) | |
183 SIMPORT([COLOR_STOP]) | |
78 | 184 SIMPORT([REF_STOPS_RADIAL]) |
185 SIMPORT([REF_STOPS_LINEAR]) | |
64 | 186 SIMPORT([ADD_PATH],) |
187 SIMPORT([ADD_RECT]) | |
188 SIMPORT([ADD_COORD]) | |
83 | 189 SIMPORT([ADD_TEXT]) |
64 | 190 SIMPORT([FILL_SHAPE]) |
191 SIMPORT([STROKE_SHAPE]) | |
192 SIMPORT([FILL_SHAPE_WITH_PAINT]) | |
193 SIMPORT([STROKE_SHAPE_WITH_PAINT]) | |
81 | 194 SIMPORT([STROKE_WIDTH]) |
195 SIMPORT([GROUP_HIDE]) | |
196 SIMPORT([RECT_HIDE]) | |
197 SIMPORT([PATH_HIDE]) | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
198 SIMPORT([COORD_TRANSLATE]) |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
199 SIMPORT([COORD_MATRIX]) |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
200 SIMPORT([SHAPE_TRANSLATE]) |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
201 SIMPORT([SHAPE_MATRIX]) |
63 | 202 divert[]]) |
203 | |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
204 define([F_ADD_LINEAR_PAINT],[[ |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
205 stops = paint_linear_stops(obj->$1, 0, NULL); |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
206 free(stops); |
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 rdman_paint_free(rdman, obj->$1); |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
208 ]]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
209 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
210 define([F_ADD_RADIAL_PAINT],[[ |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
211 stops = paint_radial_stops(obj->$1, 0, NULL); |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
212 free(stops); |
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
|
213 rdman_paint_free(rdman, obj->$1); |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
214 ]]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
215 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
216 define([F_ADD_PATH],[[ |
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
|
217 rdman_shape_free(rdman, obj->$1); |
83 | 218 ]]) |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
219 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
220 define([F_ADD_RECT],[[ |
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
|
221 rdman_shape_free(rdman, obj->$1); |
83 | 222 ]]) |
223 | |
224 define([F_ADD_TEXT],[[ | |
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
|
225 rdman_shape_free(rdman, obj->$1); |
83 | 226 ]]) |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
227 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
228 define([F_FILL_SHAPE],[[ |
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
|
229 rdman_paint_free(rdman, obj->$1_fill); |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
230 ]]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
231 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
232 define([F_STROKE_SHAPE],[[ |
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
|
233 rdman_paint_free(rdman, obj->$1_stroke); |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
234 ]]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
235 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
236 define([CLEAR_VARS],[divert([-1]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
237 define([FIMPORT],[IMPORT(]QUOTE($[]1)[,[F_])]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
238 FIMPORT([ADD_LINEAR_PAINT]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
239 FIMPORT([ADD_RADIAL_PAINT]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
240 define([COLOR_STOP]) |
78 | 241 define([REF_STOPS_RADIAL]) |
242 define([REF_STOPS_LINEAR]) | |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
243 FIMPORT([ADD_PATH],) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
244 FIMPORT([ADD_RECT]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
245 define([ADD_COORD]) |
83 | 246 FIMPORT([ADD_TEXT]) |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
247 FIMPORT([FILL_SHAPE]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
248 FIMPORT([STROKE_SHAPE]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
249 define([FILL_SHAPE_WITH_PAINT]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
250 define([STROKE_SHAPE_WITH_PAINT]) |
80
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
251 define([STROKE_WIDTH]) |
81 | 252 define([GROUP_HIDE],) |
253 define([RECT_HIDE],) | |
254 define([PATH_HIDE],) | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
255 define([COORD_TRANSLATE],) |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
256 define([COORD_MATRIX],) |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
257 define([SHAPE_TRANSLATE],) |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
258 define([SHAPE_MATRIX],) |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
259 divert[]]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
260 |
154 | 261 define([REVERSE_VARS],[divert([-1]) |
262 define([__REV_VAR],[]) | |
263 define([PUSH_REV], [ | |
264 pushdef([__REV_VAR]) | |
265 define([__REV_VAR], ]QUOTE(QUOTE($[]1))[)]) | |
266 define([POP_ALL_REV], [dnl | |
267 ifelse(__REV_VAR, [], ,[UNQUOTE(__REV_VAR)[]dnl | |
268 popdef([__REV_VAR])[]POP_ALL_REV[]])]) | |
269 define([RIMPORT], [ | |
270 define(]QUOTE($[]1)[, | |
271 [PUSH_REV(]]QUOTE(QUOTE($[]1))[[(]QUOTE($[]@)[))]) | |
272 ]) | |
273 RIMPORT([ADD_LINEAR_PAINT]) | |
274 RIMPORT([ADD_RADIAL_PAINT]) | |
275 RIMPORT([COLOR_STOP]) | |
276 RIMPORT([REF_STOPS_RADIAL]) | |
277 RIMPORT([REF_STOPS_LINEAR]) | |
278 RIMPORT([ADD_PATH]) | |
279 RIMPORT([ADD_RECT]) | |
280 RIMPORT([ADD_COORD]) | |
281 RIMPORT([ADD_TEXT]) | |
282 RIMPORT([FILL_SHAPE]) | |
283 RIMPORT([STROKE_SHAPE]) | |
284 RIMPORT([FILL_SHAPE_WITH_PAINT]) | |
285 RIMPORT([STROKE_SHAPE_WITH_PAINT]) | |
286 RIMPORT([STROKE_WIDTH]) | |
287 RIMPORT([GROUP_HIDE]) | |
288 RIMPORT([RECT_HIDE]) | |
289 RIMPORT([PATH_HIDE]) | |
290 RIMPORT([COORD_TRANSLATE]) | |
291 RIMPORT([COORD_MATRIX]) | |
292 RIMPORT([SHAPE_TRANSLATE]) | |
293 RIMPORT([SHAPE_MATRIX]) | |
294 divert[]dnl | |
295 ]) | |
296 | |
63 | 297 define([MADBUTTERFLY],[dnl |
298 [#include <stdio.h> | |
69
a6150b4e0667
Fix bug of newing linear & radial paints
Thinker K.F. Li <thinker@branda.to>
parents:
68
diff
changeset
|
299 #include <stdlib.h> |
a6150b4e0667
Fix bug of newing linear & radial paints
Thinker K.F. Li <thinker@branda.to>
parents:
68
diff
changeset
|
300 #include <string.h> |
108 | 301 #include "mb/mb_types.h" |
302 #include "mb/redraw_man.h" | |
303 #include "mb/shapes.h" | |
304 #include "mb/paint.h" | |
63 | 305 #include "$1.h" |
306 | |
130
3a4d6179e6a9
change mb_c_source.m4 and mb_c_header.m4 to specify parent for SVG object
Thinker K.F. Li <thinker@branda.to>
parents:
113
diff
changeset
|
307 $1_t *$1_new(redraw_man_t *rdman, coord_t *parent_coord) { |
64 | 308 $1_t *obj; |
309 grad_stop_t *stops = NULL;]DECLARE_VARS | |
63 | 310 $2[]dnl |
311 [ | |
312 obj = ($1_t *)malloc(sizeof($1_t)); | |
313 if(obj == NULL) return NULL; | |
154 | 314 obj->rdman = rdman; |
63 | 315 ]SETUP_VARS |
130
3a4d6179e6a9
change mb_c_source.m4 and mb_c_header.m4 to specify parent for SVG object
Thinker K.F. Li <thinker@branda.to>
parents:
113
diff
changeset
|
316 obj->root_coord = rdman_coord_new(rdman, parent_coord); |
63 | 317 $2 |
318 [ return obj; | |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
319 } |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
320 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
321 void $1_free($1_t *obj) { |
68 | 322 grad_stop_t *stops = NULL; |
154 | 323 redraw_man_t *rdman; |
324 | |
325 rdman = obj->rdman; | |
326 ]REVERSE_VARS[]dnl | |
327 divert([-1])dnl | |
328 $2[]dnl | |
329 divert[]dnl | |
330 CLEAR_VARS[]dnl | |
331 POP_ALL_REV[ | |
332 rdman_coord_subtree_free(rdman, obj->root_coord); | |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
333 free(obj); |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
334 } |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
335 ]dnl |
63 | 336 ]) |
337 divert[]dnl |