Vuo
2.0.0
type
VuoColor.h
Go to the documentation of this file.
1
10
#pragma once
11
12
#include "
VuoBoolean.h
"
13
#include "
VuoReal.h
"
14
#include "
VuoText.h
"
15
16
#ifdef __cplusplus
17
extern
"C"
{
18
#endif
19
21
typedef
const
struct
VuoList_VuoColor_struct
{
void
*l; } *
VuoList_VuoColor
;
22
#define VuoList_VuoColor_TYPE_DEFINED
23
40
typedef
struct
41
{
42
float
r,g,b,a;
43
}
VuoColor
;
44
45
VuoColor
VuoColor_makeFromJson
(
struct
json_object
* js);
46
struct
json_object
*
VuoColor_getJson
(
const
VuoColor
value);
47
char
*
VuoColor_getShortSummary
(
const
VuoColor
value);
48
char
*
VuoColor_getSummary
(
const
VuoColor
value);
49
50
#define VuoColor_SUPPORTS_COMPARISON
51
bool
VuoColor_areEqual
(
const
VuoColor
a,
const
VuoColor
b);
52
bool
VuoColor_isLessThan
(
const
VuoColor
a,
const
VuoColor
b);
53
54
bool
VuoColor_areEqualWithinTolerance
(
const
VuoColor
a,
const
VuoColor
b,
const
float
tolerance);
55
63
static
inline
VuoColor
VuoColor_makeWithRGBA
(
VuoReal
r,
VuoReal
g,
VuoReal
b,
VuoReal
a)
__attribute__
((
const
));
64
static
inline
VuoColor
VuoColor_makeWithRGBA
(
VuoReal
r,
VuoReal
g,
VuoReal
b,
VuoReal
a)
65
{
66
VuoColor
c = {(float)r,(
float
)g,(float)b,(
float
)a};
67
return
c;
68
}
69
77
static
inline
void
VuoColor_getRGBA
(
VuoColor
color,
VuoReal
*r,
VuoReal
*g,
VuoReal
*b,
VuoReal
*a)
78
{
79
*r = color.r;
80
*g = color.g;
81
*b = color.b;
82
*a = color.a;
83
}
84
88
static
inline
VuoColor
VuoColor_premultiply
(
VuoColor
c)
__attribute__
((
const
));
89
static
inline
VuoColor
VuoColor_premultiply
(
VuoColor
c)
90
{
91
return
(
VuoColor
){ c.r*c.a, c.g*c.a, c.b*c.a, c.a };
92
}
93
94
VuoColor
VuoColor_makeWithHSLA
(
VuoReal
hue,
VuoReal
saturation,
VuoReal
luminosity,
VuoReal
alpha);
95
void
VuoColor_getHSLA
(
VuoColor
color,
VuoReal
*h,
VuoReal
*s,
VuoReal
*l,
VuoReal
*a);
96
VuoReal
VuoColor_getLightness
(
VuoColor
color);
97
98
VuoColor
VuoColor_makeWithCMYKA
(
VuoReal
c,
VuoReal
m,
VuoReal
y,
VuoReal
k,
VuoReal
a);
99
void
VuoColor_getCMYKA
(
VuoColor
color,
VuoReal
*c,
VuoReal
*m,
VuoReal
*y,
VuoReal
*k,
VuoReal
*a);
100
101
VuoText
VuoColor_getHex
(
VuoColor
color,
VuoBoolean
includeAlpha);
102
103
VuoColor
VuoColor_average
(
VuoList_VuoColor
colors);
104
109
static
inline
bool
VuoColor_isOpaque
(
VuoColor
color)
110
{
111
return
color.a >= 1.;
112
}
113
114
bool
VuoColor_areAllOpaque
(
VuoList_VuoColor
colors);
115
116
VuoReal
VuoColor_brightness
(
VuoColor
color, int32_t
/*VuoThresholdType*/
type);
117
121
static
inline
VuoColor
VuoColor_lerp
(
VuoColor
a,
VuoColor
b,
float
t)
__attribute__
((
const
));
122
static
inline
VuoColor
VuoColor_lerp
(
VuoColor
a,
VuoColor
b,
float
t)
123
{
124
// Premultiply, then mix, then unpremultiply.
125
VuoColor
ap =
VuoColor_makeWithRGBA
(a.r*a.a, a.g*a.a, a.b*a.a, a.a);
126
VuoColor
bp =
VuoColor_makeWithRGBA
(b.r*b.a, b.g*b.a, b.b*b.a, b.a);
127
128
VuoColor
mixed =
VuoColor_makeWithRGBA
(
129
ap.r*(1-t) + bp.r*t,
130
ap.g*(1-t) + bp.g*t,
131
ap.b*(1-t) + bp.b*t,
132
ap.a*(1-t) + bp.a*t);
133
134
float
alpha =
VuoReal_makeNonzero
(mixed.a);
135
return
VuoColor_makeWithRGBA
(mixed.r/alpha, mixed.g/alpha, mixed.b/alpha, mixed.a);
136
}
137
139
142
VuoColor
VuoColor_makeFromString
(
const
char
*str);
143
char
*
VuoColor_getString
(
const
VuoColor
value);
144
void
VuoColor_retain
(
VuoColor
value);
145
void
VuoColor_release
(
VuoColor
value);
147
152
#ifdef __cplusplus
153
}
154
#endif
Generated on Wed Feb 26 2020 23:19:44 for Vuo by
1.8.17