| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT |
|
2
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
3
|
|
|
|
|
|
|
#include "perl.h" |
|
4
|
|
|
|
|
|
|
#include "XSUB.h" |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
/* Route fatal errors through Perl's croak() */ |
|
7
|
|
|
|
|
|
|
#define COLOURING_FATAL(msg) croak("%s", (msg)) |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#include "in.h" |
|
10
|
|
|
|
|
|
|
#include "in_ops.h" |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
MODULE = Colouring::In::XS PACKAGE = Colouring::In::XS |
|
13
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
|
14
|
|
|
|
|
|
|
FALLBACK: TRUE |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
void |
|
17
|
|
|
|
|
|
|
set_messages(...) |
|
18
|
|
|
|
|
|
|
CODE: |
|
19
|
1
|
|
|
|
|
|
AV * array = av_make(items, MARK+1); |
|
20
|
1
|
|
|
|
|
|
MESSAGES = (HV*)SvRV(av_pop(array)); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
SV * |
|
23
|
|
|
|
|
|
|
new(...) |
|
24
|
|
|
|
|
|
|
CODE: |
|
25
|
10026
|
|
|
|
|
|
SV * colour = ST(1); |
|
26
|
10026
|
100
|
|
|
|
|
SV * a = (items > 2) && SvOK(ST(2)) ? ST(2) : newSViv(1); |
|
|
|
100
|
|
|
|
|
|
|
27
|
10026
|
|
|
|
|
|
RETVAL = xs_new_color(ST(0), colour, a); |
|
28
|
|
|
|
|
|
|
OUTPUT: |
|
29
|
|
|
|
|
|
|
RETVAL |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
SV * |
|
32
|
|
|
|
|
|
|
rgb(self, red, green, blue, ...) |
|
33
|
|
|
|
|
|
|
SV * self |
|
34
|
|
|
|
|
|
|
SV * red |
|
35
|
|
|
|
|
|
|
SV * green |
|
36
|
|
|
|
|
|
|
SV * blue |
|
37
|
|
|
|
|
|
|
CODE: |
|
38
|
1
|
|
|
|
|
|
double r = xs_scaled(red, 255); |
|
39
|
1
|
|
|
|
|
|
double g = xs_scaled(green, 255); |
|
40
|
1
|
|
|
|
|
|
double b = xs_scaled(blue, 255); |
|
41
|
1
|
|
|
|
|
|
AV * colour = newAV(); |
|
42
|
1
|
50
|
|
|
|
|
double a = colouring_clamp(items > 4 ? SvNV(ST(4)) : 1, 1); |
|
43
|
1
|
|
|
|
|
|
av_push(colour, newSVnv(r)); |
|
44
|
1
|
|
|
|
|
|
av_push(colour, newSVnv(g)); |
|
45
|
1
|
|
|
|
|
|
av_push(colour, newSVnv(b)); |
|
46
|
1
|
|
|
|
|
|
RETVAL = xs_new_color(self, newRV_noinc((SV*)colour), newSVnv(a)); |
|
47
|
|
|
|
|
|
|
OUTPUT: |
|
48
|
|
|
|
|
|
|
RETVAL |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
SV * |
|
51
|
|
|
|
|
|
|
rgba(self, red, green, blue, ...) |
|
52
|
|
|
|
|
|
|
SV * self |
|
53
|
|
|
|
|
|
|
SV * red |
|
54
|
|
|
|
|
|
|
SV * green |
|
55
|
|
|
|
|
|
|
SV * blue |
|
56
|
|
|
|
|
|
|
CODE: |
|
57
|
0
|
|
|
|
|
|
double r = xs_scaled(red, 255); |
|
58
|
0
|
|
|
|
|
|
double g = xs_scaled(green, 255); |
|
59
|
0
|
|
|
|
|
|
double b = xs_scaled(blue, 255); |
|
60
|
0
|
|
|
|
|
|
AV * colour = newAV(); |
|
61
|
0
|
0
|
|
|
|
|
double a = colouring_clamp(items > 4 ? SvNV(ST(4)) : 1, 1); |
|
62
|
0
|
|
|
|
|
|
av_push(colour, newSVnv(r)); |
|
63
|
0
|
|
|
|
|
|
av_push(colour, newSVnv(g)); |
|
64
|
0
|
|
|
|
|
|
av_push(colour, newSVnv(b)); |
|
65
|
0
|
|
|
|
|
|
RETVAL = xs_new_color(self, newRV_noinc((SV*)colour), newSVnv(a)); |
|
66
|
|
|
|
|
|
|
OUTPUT: |
|
67
|
|
|
|
|
|
|
RETVAL |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
SV * |
|
70
|
|
|
|
|
|
|
hsl(self, h, s, l, ...) |
|
71
|
|
|
|
|
|
|
SV * self |
|
72
|
|
|
|
|
|
|
SV * h |
|
73
|
|
|
|
|
|
|
SV * s |
|
74
|
|
|
|
|
|
|
SV * l |
|
75
|
|
|
|
|
|
|
CODE: |
|
76
|
1
|
50
|
|
|
|
|
double a = colouring_clamp(items > 4 ? SvNV(ST(4)) : 1, 1); |
|
77
|
1
|
|
|
|
|
|
colouring_rgba_t c = colouring_hsl2rgb(SvNV(h), SvNV(s), SvNV(l), a); |
|
78
|
1
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(self, c); |
|
79
|
|
|
|
|
|
|
OUTPUT: |
|
80
|
|
|
|
|
|
|
RETVAL |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
SV * |
|
83
|
|
|
|
|
|
|
hsla(self, h, s, l, ...) |
|
84
|
|
|
|
|
|
|
SV * self |
|
85
|
|
|
|
|
|
|
SV * h |
|
86
|
|
|
|
|
|
|
SV * s |
|
87
|
|
|
|
|
|
|
SV * l |
|
88
|
|
|
|
|
|
|
CODE: |
|
89
|
0
|
0
|
|
|
|
|
double a = colouring_clamp(items > 4 ? SvNV(ST(4)) : 1, 1); |
|
90
|
0
|
|
|
|
|
|
colouring_rgba_t c = colouring_hsl2rgb(SvNV(h), SvNV(s), SvNV(l), a); |
|
91
|
0
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(self, c); |
|
92
|
|
|
|
|
|
|
OUTPUT: |
|
93
|
|
|
|
|
|
|
RETVAL |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
SV * |
|
96
|
|
|
|
|
|
|
toCSS(self, ...) |
|
97
|
|
|
|
|
|
|
SV * self |
|
98
|
|
|
|
|
|
|
CODE: |
|
99
|
0
|
0
|
|
|
|
|
int r = items > 1 ? SvIV(ST(1)) : 0; |
|
100
|
0
|
0
|
|
|
|
|
int s = items > 2 ? SvIV(ST(1)) : 0; |
|
101
|
0
|
|
|
|
|
|
colouring_rgba_t c = xs_extract_rgba(self); |
|
102
|
0
|
|
|
|
|
|
double alpha = colouring_round(c.a, r); |
|
103
|
0
|
0
|
|
|
|
|
if (alpha == 1) { |
|
104
|
|
|
|
|
|
|
char css[8]; |
|
105
|
0
|
|
|
|
|
|
colouring_fmt_hex(c, css, sizeof(css), s); |
|
106
|
0
|
|
|
|
|
|
RETVAL = newSVpvn(css, strlen(css)); |
|
107
|
|
|
|
|
|
|
} else { |
|
108
|
|
|
|
|
|
|
char css[32]; |
|
109
|
0
|
|
|
|
|
|
colouring_fmt_rgba(c, css, sizeof(css)); |
|
110
|
0
|
|
|
|
|
|
RETVAL = newSVpvn(css, strlen(css)); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
OVERLOAD: \"\" |
|
113
|
|
|
|
|
|
|
OUTPUT: |
|
114
|
|
|
|
|
|
|
RETVAL |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
SV * |
|
117
|
|
|
|
|
|
|
toTerm(self) |
|
118
|
|
|
|
|
|
|
SV * self |
|
119
|
|
|
|
|
|
|
CODE: |
|
120
|
|
|
|
|
|
|
char css[16]; |
|
121
|
0
|
|
|
|
|
|
colouring_rgba_t c = xs_extract_rgba(self); |
|
122
|
0
|
|
|
|
|
|
colouring_fmt_term(c, css, sizeof(css)); |
|
123
|
0
|
|
|
|
|
|
RETVAL = newSVpvn(css, strlen(css)); |
|
124
|
|
|
|
|
|
|
OUTPUT: |
|
125
|
|
|
|
|
|
|
RETVAL |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
SV * |
|
128
|
|
|
|
|
|
|
toOnTerm(self) |
|
129
|
|
|
|
|
|
|
SV * self |
|
130
|
|
|
|
|
|
|
CODE: |
|
131
|
|
|
|
|
|
|
char css[20]; |
|
132
|
0
|
|
|
|
|
|
colouring_rgba_t c = xs_extract_rgba(self); |
|
133
|
0
|
|
|
|
|
|
colouring_fmt_on_term(c, css, sizeof(css)); |
|
134
|
0
|
|
|
|
|
|
RETVAL = newSVpvn(css, strlen(css)); |
|
135
|
|
|
|
|
|
|
OUTPUT: |
|
136
|
|
|
|
|
|
|
RETVAL |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
SV * |
|
139
|
|
|
|
|
|
|
toRGB(self, ...) |
|
140
|
|
|
|
|
|
|
SV * self |
|
141
|
|
|
|
|
|
|
CODE: |
|
142
|
0
|
|
|
|
|
|
colouring_rgba_t c = xs_extract_rgba(self); |
|
143
|
0
|
|
|
|
|
|
SV * alpha_sv = *hv_fetch((HV*)SvRV(self), "alpha", 5, 0); |
|
144
|
0
|
0
|
|
|
|
|
if (numIs(alpha_sv) && SvIV(alpha_sv) != 1) { |
|
|
|
0
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
char css[32]; |
|
146
|
0
|
|
|
|
|
|
colouring_fmt_rgba(c, css, sizeof(css)); |
|
147
|
0
|
|
|
|
|
|
RETVAL = newSVpvn(css, strlen(css)); |
|
148
|
|
|
|
|
|
|
} else { |
|
149
|
|
|
|
|
|
|
char css[24]; |
|
150
|
0
|
|
|
|
|
|
colouring_fmt_rgb(c, css, sizeof(css)); |
|
151
|
0
|
|
|
|
|
|
RETVAL = newSVpvn(css, strlen(css)); |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
OUTPUT: |
|
154
|
|
|
|
|
|
|
RETVAL |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
SV * |
|
157
|
|
|
|
|
|
|
toRGBA(self, ...) |
|
158
|
|
|
|
|
|
|
SV * self |
|
159
|
|
|
|
|
|
|
CODE: |
|
160
|
|
|
|
|
|
|
char css[32]; |
|
161
|
0
|
|
|
|
|
|
colouring_rgba_t c = xs_extract_rgba(self); |
|
162
|
0
|
|
|
|
|
|
colouring_fmt_rgba(c, css, sizeof(css)); |
|
163
|
0
|
|
|
|
|
|
RETVAL = newSVpvn(css, strlen(css)); |
|
164
|
|
|
|
|
|
|
OUTPUT: |
|
165
|
|
|
|
|
|
|
RETVAL |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
SV * |
|
168
|
|
|
|
|
|
|
toHEX(self, ...) |
|
169
|
|
|
|
|
|
|
SV * self |
|
170
|
|
|
|
|
|
|
CODE: |
|
171
|
|
|
|
|
|
|
char css[8]; |
|
172
|
0
|
|
|
|
|
|
colouring_rgba_t c = xs_extract_rgba(self); |
|
173
|
0
|
0
|
|
|
|
|
int force_long = SvTRUE(ST(1)) && SvTYPE(ST(1)) == SVt_IV; |
|
|
|
0
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
colouring_fmt_hex(c, css, sizeof(css), force_long); |
|
175
|
0
|
|
|
|
|
|
RETVAL = newSVpvn(css, strlen(css)); |
|
176
|
|
|
|
|
|
|
OUTPUT: |
|
177
|
|
|
|
|
|
|
RETVAL |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
SV * |
|
180
|
|
|
|
|
|
|
toHSL(self) |
|
181
|
|
|
|
|
|
|
SV * self |
|
182
|
|
|
|
|
|
|
CODE: |
|
183
|
|
|
|
|
|
|
char css[30]; |
|
184
|
0
|
|
|
|
|
|
colouring_rgba_t c = xs_extract_rgba(self); |
|
185
|
0
|
|
|
|
|
|
colouring_hsl_t hsl = colouring_rgb2hsl(c.r, c.g, c.b, c.a); |
|
186
|
0
|
|
|
|
|
|
colouring_fmt_hsl(hsl, css, sizeof(css)); |
|
187
|
0
|
|
|
|
|
|
RETVAL = newSVpvn(css, strlen(css)); |
|
188
|
|
|
|
|
|
|
OUTPUT: |
|
189
|
|
|
|
|
|
|
RETVAL |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
SV * |
|
192
|
|
|
|
|
|
|
toHSV(self) |
|
193
|
|
|
|
|
|
|
SV * self |
|
194
|
|
|
|
|
|
|
CODE: |
|
195
|
|
|
|
|
|
|
char css[30]; |
|
196
|
0
|
|
|
|
|
|
colouring_rgba_t c = xs_extract_rgba(self); |
|
197
|
0
|
|
|
|
|
|
colouring_hsv_t hsv = colouring_rgb2hsv(c.r, c.g, c.b); |
|
198
|
0
|
|
|
|
|
|
colouring_fmt_hsv(hsv, css, sizeof(css)); |
|
199
|
0
|
|
|
|
|
|
RETVAL = newSVpvn(css, strlen(css)); |
|
200
|
|
|
|
|
|
|
OUTPUT: |
|
201
|
|
|
|
|
|
|
RETVAL |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
SV * |
|
204
|
|
|
|
|
|
|
lighten(colour, amt, ...) |
|
205
|
|
|
|
|
|
|
SV * colour |
|
206
|
|
|
|
|
|
|
SV * amt |
|
207
|
|
|
|
|
|
|
CODE: |
|
208
|
7
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
209
|
7
|
50
|
|
|
|
|
int relative = items > 2 && SvOK(ST(2)) && strcmp(SvPV_nolen(ST(2)), "relative") == 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
210
|
7
|
|
|
|
|
|
double amount = colouring_depercent(SvPV_nolen(amt)); |
|
211
|
|
|
|
|
|
|
colouring_rgba_t c; |
|
212
|
7
|
|
|
|
|
|
colour = xs_ensure_obj(class, colour); |
|
213
|
7
|
|
|
|
|
|
c = xs_extract_rgba(colour); |
|
214
|
7
|
|
|
|
|
|
c = colouring_lighten(c.r, c.g, c.b, c.a, amount, relative); |
|
215
|
7
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, c); |
|
216
|
|
|
|
|
|
|
OUTPUT: |
|
217
|
|
|
|
|
|
|
RETVAL |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
SV * |
|
220
|
|
|
|
|
|
|
darken(colour, amt, ...) |
|
221
|
|
|
|
|
|
|
SV * colour |
|
222
|
|
|
|
|
|
|
SV * amt |
|
223
|
|
|
|
|
|
|
CODE: |
|
224
|
8
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
225
|
8
|
50
|
|
|
|
|
int relative = items > 2 && SvOK(ST(2)) && strcmp(SvPV_nolen(ST(2)), "relative") == 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
226
|
8
|
|
|
|
|
|
double amount = colouring_depercent(SvPV_nolen(amt)); |
|
227
|
|
|
|
|
|
|
colouring_rgba_t c; |
|
228
|
8
|
|
|
|
|
|
colour = xs_ensure_obj(class, colour); |
|
229
|
8
|
|
|
|
|
|
c = xs_extract_rgba(colour); |
|
230
|
8
|
|
|
|
|
|
c = colouring_darken(c.r, c.g, c.b, c.a, amount, relative); |
|
231
|
8
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, c); |
|
232
|
|
|
|
|
|
|
OUTPUT: |
|
233
|
|
|
|
|
|
|
RETVAL |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
SV * |
|
236
|
|
|
|
|
|
|
fade(colour, amt, ...) |
|
237
|
|
|
|
|
|
|
SV * colour |
|
238
|
|
|
|
|
|
|
SV * amt |
|
239
|
|
|
|
|
|
|
CODE: |
|
240
|
12
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
241
|
12
|
|
|
|
|
|
double amount = colouring_depercent(SvPV_nolen(amt)); |
|
242
|
|
|
|
|
|
|
colouring_rgba_t c; |
|
243
|
12
|
|
|
|
|
|
colour = xs_ensure_obj(class, colour); |
|
244
|
12
|
|
|
|
|
|
c = xs_extract_rgba(colour); |
|
245
|
12
|
|
|
|
|
|
c = colouring_fade(c.r, c.g, c.b, c.a, amount); |
|
246
|
12
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, c); |
|
247
|
|
|
|
|
|
|
OUTPUT: |
|
248
|
|
|
|
|
|
|
RETVAL |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
SV * |
|
251
|
|
|
|
|
|
|
fadeout(colour, amt, ...) |
|
252
|
|
|
|
|
|
|
SV * colour |
|
253
|
|
|
|
|
|
|
SV * amt |
|
254
|
|
|
|
|
|
|
CODE: |
|
255
|
11
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
256
|
11
|
50
|
|
|
|
|
int relative = items > 2 && SvOK(ST(2)) && strcmp(SvPV_nolen(ST(2)), "relative") == 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
257
|
11
|
|
|
|
|
|
double amount = colouring_depercent(SvPV_nolen(amt)); |
|
258
|
|
|
|
|
|
|
colouring_rgba_t c; |
|
259
|
11
|
|
|
|
|
|
colour = xs_ensure_obj(class, colour); |
|
260
|
11
|
|
|
|
|
|
c = xs_extract_rgba(colour); |
|
261
|
11
|
|
|
|
|
|
c = colouring_fadeout(c.r, c.g, c.b, c.a, amount, relative); |
|
262
|
11
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, c); |
|
263
|
|
|
|
|
|
|
OUTPUT: |
|
264
|
|
|
|
|
|
|
RETVAL |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
SV * |
|
267
|
|
|
|
|
|
|
fadein(colour, amt, ...) |
|
268
|
|
|
|
|
|
|
SV * colour |
|
269
|
|
|
|
|
|
|
SV * amt |
|
270
|
|
|
|
|
|
|
CODE: |
|
271
|
11
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
272
|
11
|
50
|
|
|
|
|
int relative = items > 2 && SvOK(ST(2)) && strcmp(SvPV_nolen(ST(2)), "relative") == 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
273
|
11
|
|
|
|
|
|
double amount = colouring_depercent(SvPV_nolen(amt)); |
|
274
|
|
|
|
|
|
|
colouring_rgba_t c; |
|
275
|
11
|
|
|
|
|
|
colour = xs_ensure_obj(class, colour); |
|
276
|
11
|
|
|
|
|
|
c = xs_extract_rgba(colour); |
|
277
|
11
|
|
|
|
|
|
c = colouring_fadein(c.r, c.g, c.b, c.a, amount, relative); |
|
278
|
11
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, c); |
|
279
|
|
|
|
|
|
|
OUTPUT: |
|
280
|
|
|
|
|
|
|
RETVAL |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
SV * |
|
283
|
|
|
|
|
|
|
mix(colour1, colour2, ...) |
|
284
|
|
|
|
|
|
|
SV * colour1 |
|
285
|
|
|
|
|
|
|
SV * colour2 |
|
286
|
|
|
|
|
|
|
CODE: |
|
287
|
1
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
288
|
1
|
|
|
|
|
|
int weight = 50; |
|
289
|
|
|
|
|
|
|
colouring_rgba_t c1, c2, out; |
|
290
|
1
|
50
|
|
|
|
|
if (SvOK(ST(2)) && SvIV(ST(2)) != 0) { |
|
|
|
50
|
|
|
|
|
|
|
291
|
0
|
|
|
|
|
|
weight = SvIV(ST(2)); |
|
292
|
|
|
|
|
|
|
} |
|
293
|
1
|
|
|
|
|
|
colour1 = xs_ensure_obj(class, colour1); |
|
294
|
1
|
|
|
|
|
|
colour2 = xs_ensure_obj(class, colour2); |
|
295
|
1
|
|
|
|
|
|
c1 = xs_extract_rgba(colour1); |
|
296
|
1
|
|
|
|
|
|
c2 = xs_extract_rgba(colour2); |
|
297
|
1
|
|
|
|
|
|
out = colouring_mix(c1, c2, weight); |
|
298
|
1
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, out); |
|
299
|
|
|
|
|
|
|
OUTPUT: |
|
300
|
|
|
|
|
|
|
RETVAL |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
SV * |
|
303
|
|
|
|
|
|
|
tint(colour, ...) |
|
304
|
|
|
|
|
|
|
SV * colour |
|
305
|
|
|
|
|
|
|
CODE: |
|
306
|
1
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
307
|
1
|
|
|
|
|
|
int weight = 50; |
|
308
|
|
|
|
|
|
|
colouring_rgba_t c, out; |
|
309
|
1
|
50
|
|
|
|
|
if (SvOK(ST(2)) && SvIV(ST(2)) != 0) { |
|
|
|
50
|
|
|
|
|
|
|
310
|
0
|
|
|
|
|
|
weight = SvIV(ST(2)); |
|
311
|
|
|
|
|
|
|
} |
|
312
|
1
|
|
|
|
|
|
colour = xs_ensure_obj(class, colour); |
|
313
|
1
|
|
|
|
|
|
c = xs_extract_rgba(colour); |
|
314
|
1
|
|
|
|
|
|
out = colouring_tint(c, weight); |
|
315
|
1
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, out); |
|
316
|
|
|
|
|
|
|
OUTPUT: |
|
317
|
|
|
|
|
|
|
RETVAL |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
SV * |
|
320
|
|
|
|
|
|
|
shade(colour, ...) |
|
321
|
|
|
|
|
|
|
SV * colour |
|
322
|
|
|
|
|
|
|
CODE: |
|
323
|
1
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
324
|
1
|
|
|
|
|
|
int weight = 50; |
|
325
|
|
|
|
|
|
|
colouring_rgba_t c, out; |
|
326
|
1
|
50
|
|
|
|
|
if (SvOK(ST(2)) && SvIV(ST(2)) != 0) { |
|
|
|
50
|
|
|
|
|
|
|
327
|
0
|
|
|
|
|
|
weight = SvIV(ST(2)); |
|
328
|
|
|
|
|
|
|
} |
|
329
|
1
|
|
|
|
|
|
colour = xs_ensure_obj(class, colour); |
|
330
|
1
|
|
|
|
|
|
c = xs_extract_rgba(colour); |
|
331
|
1
|
|
|
|
|
|
out = colouring_shade(c, weight); |
|
332
|
1
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, out); |
|
333
|
|
|
|
|
|
|
OUTPUT: |
|
334
|
|
|
|
|
|
|
RETVAL |
|
335
|
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
SV * |
|
337
|
|
|
|
|
|
|
saturate(colour, amt, ...) |
|
338
|
|
|
|
|
|
|
SV * colour |
|
339
|
|
|
|
|
|
|
SV * amt |
|
340
|
|
|
|
|
|
|
CODE: |
|
341
|
1
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
342
|
1
|
50
|
|
|
|
|
int relative = items > 2 && SvOK(ST(2)) && strcmp(SvPV_nolen(ST(2)), "relative") == 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
343
|
1
|
|
|
|
|
|
double amount = colouring_depercent(SvPV_nolen(amt)); |
|
344
|
|
|
|
|
|
|
colouring_rgba_t c; |
|
345
|
1
|
|
|
|
|
|
colour = xs_ensure_obj(class, colour); |
|
346
|
1
|
|
|
|
|
|
c = xs_extract_rgba(colour); |
|
347
|
1
|
|
|
|
|
|
c = colouring_saturate(c.r, c.g, c.b, c.a, amount, relative); |
|
348
|
1
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, c); |
|
349
|
|
|
|
|
|
|
OUTPUT: |
|
350
|
|
|
|
|
|
|
RETVAL |
|
351
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
SV * |
|
353
|
|
|
|
|
|
|
desaturate(colour, amt, ...) |
|
354
|
|
|
|
|
|
|
SV * colour |
|
355
|
|
|
|
|
|
|
SV * amt |
|
356
|
|
|
|
|
|
|
CODE: |
|
357
|
2
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
358
|
2
|
50
|
|
|
|
|
int relative = items > 2 && SvOK(ST(2)) && strcmp(SvPV_nolen(ST(2)), "relative") == 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
359
|
2
|
|
|
|
|
|
double amount = colouring_depercent(SvPV_nolen(amt)); |
|
360
|
|
|
|
|
|
|
colouring_rgba_t c; |
|
361
|
2
|
|
|
|
|
|
colour = xs_ensure_obj(class, colour); |
|
362
|
2
|
|
|
|
|
|
c = xs_extract_rgba(colour); |
|
363
|
2
|
|
|
|
|
|
c = colouring_desaturate(c.r, c.g, c.b, c.a, amount, relative); |
|
364
|
2
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, c); |
|
365
|
|
|
|
|
|
|
OUTPUT: |
|
366
|
|
|
|
|
|
|
RETVAL |
|
367
|
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
SV * |
|
369
|
|
|
|
|
|
|
greyscale(colour) |
|
370
|
|
|
|
|
|
|
SV * colour |
|
371
|
|
|
|
|
|
|
CODE: |
|
372
|
1
|
|
|
|
|
|
SV * class = newSVpv("Colouring::In::XS", 17); |
|
373
|
|
|
|
|
|
|
colouring_rgba_t c; |
|
374
|
1
|
|
|
|
|
|
colour = xs_ensure_obj(class, colour); |
|
375
|
1
|
|
|
|
|
|
c = xs_extract_rgba(colour); |
|
376
|
1
|
|
|
|
|
|
c = colouring_greyscale(c.r, c.g, c.b, c.a); |
|
377
|
1
|
|
|
|
|
|
RETVAL = xs_rgba_to_obj(class, c); |
|
378
|
|
|
|
|
|
|
OUTPUT: |
|
379
|
|
|
|
|
|
|
RETVAL |
|
380
|
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
void |
|
382
|
|
|
|
|
|
|
colour(self) |
|
383
|
|
|
|
|
|
|
SV * self |
|
384
|
|
|
|
|
|
|
PPCODE: |
|
385
|
|
|
|
|
|
|
int i; |
|
386
|
10001
|
|
|
|
|
|
AV * colour = (AV*)SvRV(*hv_fetch((HV*)SvRV(self), "colour", 6, 0)); |
|
387
|
10001
|
|
|
|
|
|
int len = av_len(colour); |
|
388
|
10001
|
50
|
|
|
|
|
EXTEND(SP, len + 1); |
|
|
|
50
|
|
|
|
|
|
|
389
|
40004
|
100
|
|
|
|
|
for (i = 0; i <= len; i++) { |
|
390
|
30003
|
|
|
|
|
|
PUSHs(sv_2mortal(newSVsv(*av_fetch(colour, i, 0)))); |
|
391
|
|
|
|
|
|
|
} |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
SV * |
|
394
|
|
|
|
|
|
|
get_message(msg) |
|
395
|
|
|
|
|
|
|
SV * msg |
|
396
|
|
|
|
|
|
|
CODE: |
|
397
|
4
|
|
|
|
|
|
char * key = SvPV_nolen(msg); |
|
398
|
4
|
|
|
|
|
|
RETVAL = *hv_fetch(MESSAGES, key, strlen(key), 0); |
|
399
|
|
|
|
|
|
|
OUTPUT: |
|
400
|
|
|
|
|
|
|
RETVAL |
|
401
|
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
BOOT: |
|
403
|
18
|
|
|
|
|
|
colouring_register_ops(aTHX); |