24 #define ROUND(x) ((int) ((x) + 0.5))
25 #define SIGN(x) ((x)>0?1:(-1))
26 #define SQR(x) ((x)*(x))
28 #define MAX3(a, b, c) ((a)>(b)?MAX((a),(c)):MAX((b),(c)))
29 #define MIN3(a, b, c) ((a)<(b)?MIN((a),(c)):MIN((b),(c)))
33 typedef struct {
int x,
y, w, h; }
Rect;
41 if (x < r->x) { r->
w += r->
x-x; r->
x = x; }
else
42 if (x >= r->
x+r->
w) { r->
w = x - r->
x + 1; }
44 if (y < r->y) { r->
h += r->
y-y; r->
y = y; }
else
45 if (y >= r->
y+r->
h) { r->
h = y - r->
y + 1; }
56 uint32_t rand1 = g_rand_int(rng);
57 uint32_t rand2 = g_rand_int(rng);
58 sum += rand1 & 0x7FFF;
59 sum += (rand1 >> 16) & 0x7FFF;
60 sum += rand2 & 0x7FFF;
61 sum += (rand2 >> 16) & 0x7FFF;
62 return sum * 5.28596089837e-5 - 3.46410161514;
70 float max, min, delta;
80 r = CLAMP(r, 0.0, 1.0);
81 g = CLAMP(g, 0.0, 1.0);
82 b = CLAMP(b, 0.0, 1.0);
102 h = 2.0 + (b - r) / delta;
106 h = 4.0 + (r - g) / delta;
137 s = CLAMP(s, 0.0, 1.0);
138 v = CLAMP(v, 0.0, 1.0);
160 q = v * (1.0 - (s * f));
161 t = v * (1.0 - (s * (1.0 - f)));
207 gdouble max, min, delta;
219 r = CLAMP(r, 0.0, 1.0);
220 g = CLAMP(g, 0.0, 1.0);
221 b = CLAMP(b, 0.0, 1.0);
226 l = (max + min) / 2.0;
236 s = (max - min) / (max + min);
238 s = (max - min) / (2.0 - max - min);
251 h = 2.0 + (b - r) / delta;
255 h = 4.0 + (r - g) / delta;
282 val = n1 + (n2 - n1) * hue;
286 val = n1 + (n2 - n1) * (4.0 - hue);
312 s = CLAMP(s, 0.0, 1.0);
313 l = CLAMP(l, 0.0, 1.0);