53 json_type t = json_object_get_type(js);
54 if (t == json_type_string)
56 const char *s = json_object_get_string(js);
59 size_t len = strlen(s);
65 color.r = (float)r / 15;
66 color.g = (float)g / 15;
67 color.b = (float)b / 15;
76 color.r = (float)r / 15;
77 color.g = (float)g / 15;
78 color.b = (float)b / 15;
79 color.a = (float)a / 15;
86 color.r = (float)r / 255;
87 color.g = (float)g / 255;
88 color.b = (float)b / 255;
97 color.r = (float)r / 255;
98 color.g = (float)g / 255;
99 color.b = (float)b / 255;
100 color.a = (float)a / 255;
107 sscanf(s,
"%20g, %20g, %20g, %20g", &color.r, &color.g, &color.b, &color.a);
111 else if (t == json_type_array)
113 int len = json_object_array_length(js);
115 color.r = json_object_get_double(json_object_array_get_idx(js, 0));
117 color.g = json_object_get_double(json_object_array_get_idx(js, 1));
119 color.b = json_object_get_double(json_object_array_get_idx(js, 2));
121 color.a = json_object_get_double(json_object_array_get_idx(js, 3));
126 json_object *o = NULL;
128 if (json_object_object_get_ex(js,
"r", &o))
131 if (json_object_object_get_ex(js,
"g", &o))
134 if (json_object_object_get_ex(js,
"b", &o))
137 if (json_object_object_get_ex(js,
"a", &o))
181 th,td { text-align: right; }
182 td { font-weight: normal; }
183 .left { text-align: left; }
185 <table cellspacing=6>
187 <td
class=
'left'><span style=
'background-color:%s;'> </span></td>
195 <td width=40>%4.03f</td>
196 <td width=40>%4.03f</td>
197 <td width=40>%4.03f</td>
198 <td width=40>%4.03f</td>
209 <td
class=
'left' colspan=4> <code>%s</code></td>
217 VuoText hexWithOptionalAlpha = hex;
224 value.r, value.g, value.b, value.a,
267 if (saturation < 0.00001)
268 r = g = b = luminosity;
271 VuoReal hueWrapped = fmod(hue, 1);
272 float (^hue2rgb)(
float p,
float q,
float t) = ^(
float p,
float q,
float t) {
273 if (t < 0.f) t += 1.f;
274 if (t > 1.f) t -= 1.f;
275 if (t < 1.f/6.f)
return p + (q - p) * 6.f * t;
276 if (t < 1.f/2.f)
return q;
277 if (t < 2.f/3.f)
return p + (q - p) * (2.f/3.f - t) * 6.f;
283 float q = luminosity < 0.5f ? l * (1.f + s) : l + s - l * s;
284 float p = 2.f * l - q;
285 r = hue2rgb(p, q, hueWrapped + 1.f/3.f);
286 g = hue2rgb(p, q, hueWrapped);
287 b = hue2rgb(p, q, hueWrapped - 1.f/3.f);
305 float max = fmax(r, fmax(g, b));
306 float min = fmin(r, fmin(g, b));
307 *h = *s = *l = (max + min) / 2.f;
316 *s = *l > 0.5f ? d / (2.f - max - min) : d / (max + min);
318 *h = (g - b) / d + (g < b ? 6.f : 0.f);
320 *h = (b - r) / d + 2.f;
322 *h = (r - g) / d + 4.f;
396 if (type == VuoThresholdType_Rec601)
397 return c.r * .299 + c.g * .587 + c.b * .114;
398 else if (type == VuoThresholdType_Rec709)
400 pow(c.r, 2.2) * .2126
401 + pow(c.g, 2.2) * .7152
402 + pow(c.b, 2.2) * .0722,
404 else if (type == VuoThresholdType_Desaturate)
405 return (
MAX(c.r,
MAX(c.g, c.b)) +
MIN(c.r,
MIN(c.g, c.b))) / 2.;
406 else if (type == VuoThresholdType_RGBAverage)
407 return (c.r + c.g + c.b) / 3.;
408 else if (type == VuoThresholdType_RGBMaximum)
409 return MAX(c.r,
MAX(c.g, c.b));
410 else if (type == VuoThresholdType_RGBMinimum)
411 return MIN(c.r,
MIN(c.g, c.b));
412 else if (type == VuoThresholdType_Red)
414 else if (type == VuoThresholdType_Green)
416 else if (type == VuoThresholdType_Blue)