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])
|
|
35 define([REF_STOPS],)
|
|
36 define([ADD_PATH],)
|
|
37 define([ADD_RECT])
|
|
38 define([ADD_COORD])
|
|
39 define([FILL_SHAPE])
|
|
40 define([STROKE_SHAPE])
|
|
41 define([FILL_SHAPE_WITH_PAINT])
|
|
42 define([STROKE_SHAPE_WITH_PAINT])
|
63
|
43 divert[]])
|
|
44
|
|
45 define([S_ADD_LINEAR_PAINT],[
|
|
46 obj->$1 = mb_linear_new(rdman, $2, $3, $4, $5);
|
64
|
47 ifelse(COUNT($6),0,,[dnl
|
|
48 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops);
|
|
49 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops);
|
|
50 paint_linear_stops(obj->$1, n_$1_stops, stops);
|
|
51 ])dnl
|
63
|
52 ])
|
64
|
53
|
63
|
54 define([S_ADD_RADIAL_PAINT],[
|
|
55 obj->$1 = mb_radial_new(rdman, $2, $3, $4);
|
64
|
56 ifelse(COUNT($5),0,,[
|
|
57 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops);
|
|
58 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops);
|
|
59 paint_radial_stops(obj->$1, n_$1_stops, stops);
|
|
60 ])dnl
|
63
|
61 ])
|
|
62
|
64
|
63 define([S_COLOR_STOP],[])
|
|
64 define([S_REF_STOPS],[dnl
|
|
65 [ stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$2_stops);
|
|
66 memcpy(stops, $2_stops, sizeof(grad_stop_t) * n_$2_stops);
|
|
67 paint_radial_stops(obj->$1, n_$2_stops, stops);
|
|
68 ]])
|
|
69
|
|
70 define([S_ADD_RECT],[[
|
|
71 obj->$1 = sh_rect_new($2, $3, $4, $5, 0, 0);
|
|
72 rdman_add_shape(rdman, obj->$1, obj->$6);
|
|
73 ]])
|
|
74
|
|
75 define([S_ADD_PATH],[[
|
|
76 obj->$1 = sh_path_new("$2");
|
|
77 rdman_add_shape(rdman, obj->$1, obj->$3);
|
|
78 ]])
|
|
79
|
|
80 define([S_ADD_COORD],[[
|
|
81 obj->$1 = (coord_t *)malloc(sizeof(coord_t));
|
|
82 coord_init(obj->$1, obj->$2);
|
|
83 ]])
|
|
84
|
|
85 define([S_FILL_SHAPE_WITH_PAINT],[dnl
|
|
86 [ rdman_paint_fill(rdman, obj->$2, obj->$1);
|
|
87 ]])
|
|
88
|
|
89 define([S_STROKE_SHAPE_WITH_PAINT],[dnl
|
|
90 [ rdman_paint_stroke(rdman, obj->$2, obj->$1);
|
|
91 ]])
|
|
92
|
|
93 define([S_FILL_SHAPE],[dnl
|
|
94 [ obj->$1_fill = paint_color_new(rdman, $2, $3, $4, $5);
|
|
95 rdman_paint_fill(rdman, obj->$1_fill, obj->$1);
|
|
96 ]])
|
|
97
|
|
98 define([S_STROKE_SHAPE],[dnl
|
|
99 [ obj->$1_stroke = paint_color_new(rdman, $2, $3, $4, $5);
|
|
100 rdman_paint_stroke(rdman, obj->$1_stroke, obj->$1);
|
|
101 ]])
|
|
102
|
63
|
103 define([SETUP_VARS],[divert([-1])
|
64
|
104 define([SIMPORT],[IMPORT(]QUOTE($[]1)[,[S_])])
|
|
105 SIMPORT([ADD_LINEAR_PAINT])
|
|
106 SIMPORT([ADD_RADIAL_PAINT])
|
|
107 SIMPORT([COLOR_STOP])
|
|
108 SIMPORT([REF_STOPS])
|
|
109 SIMPORT([ADD_PATH],)
|
|
110 SIMPORT([ADD_RECT])
|
|
111 SIMPORT([ADD_COORD])
|
|
112 SIMPORT([FILL_SHAPE])
|
|
113 SIMPORT([STROKE_SHAPE])
|
|
114 SIMPORT([FILL_SHAPE_WITH_PAINT])
|
|
115 SIMPORT([STROKE_SHAPE_WITH_PAINT])
|
63
|
116 divert[]])
|
|
117
|
|
118 define([MADBUTTERFLY],[dnl
|
|
119 [#include <stdio.h>
|
|
120 #include "mb_types.h"
|
|
121 #include "redraw_man.h"
|
|
122 #include "shapes.h"
|
|
123 #include "paint.h"
|
|
124 #include "$1.h"
|
|
125
|
|
126 $1_t *$1_new(redraw_mant_t *rdman) {
|
64
|
127 $1_t *obj;
|
|
128 grad_stop_t *stops = NULL;]DECLARE_VARS
|
63
|
129 $2[]dnl
|
|
130 [
|
|
131 obj = ($1_t *)malloc(sizeof($1_t));
|
|
132 if(obj == NULL) return NULL;
|
|
133 ]SETUP_VARS
|
64
|
134 obj->root_coord = rdman->root_coord;
|
63
|
135 $2
|
|
136 [ return obj;
|
|
137 }]
|
|
138 ])
|
|
139 divert[]dnl
|