Vuo
2.4.4
Loading...
Searching...
No Matches
type
VuoColor.h
Go to the documentation of this file.
1
10
#ifndef VuoColor_h
11
#define VuoColor_h
12
13
#include "
VuoBoolean.h
"
14
#include "
VuoReal.h
"
15
#include "
VuoText.h
"
16
17
#ifdef __cplusplus
18
extern
"C"
{
19
#endif
20
36
typedef
struct
37
{
38
float
r,g,b,a;
39
}
VuoColor
;
40
41
#define VuoColor_SUPPORTS_COMPARISON
42
#include "
VuoList_VuoColor.h
"
43
44
VuoColor
VuoColor_makeFromJson
(
struct
json_object * js);
45
struct
json_object *
VuoColor_getJson
(
const
VuoColor
value);
46
char
*
VuoColor_getShortSummary
(
const
VuoColor
value);
47
char
*
VuoColor_getSummary
(
const
VuoColor
value);
48
49
bool
VuoColor_areEqual
(
const
VuoColor
a,
const
VuoColor
b);
50
bool
VuoColor_isLessThan
(
const
VuoColor
a,
const
VuoColor
b);
51
52
bool
VuoColor_areEqualWithinTolerance
(
const
VuoColor
a,
const
VuoColor
b,
const
float
tolerance);
53
61
static
inline
VuoColor
VuoColor_makeWithRGBA
(
VuoReal
r,
VuoReal
g,
VuoReal
b,
VuoReal
a) __attribute__((
const
));
62
static
inline
VuoColor
VuoColor_makeWithRGBA
(
VuoReal
r,
VuoReal
g,
VuoReal
b,
VuoReal
a)
63
{
64
VuoColor
c = {(float)r,(
float
)g,(float)b,(
float
)a};
65
return
c;
66
}
67
75
static
inline
void
VuoColor_getRGBA
(
VuoColor
color,
VuoReal
*r,
VuoReal
*g,
VuoReal
*b,
VuoReal
*a)
76
{
77
*r = color.r;
78
*g = color.g;
79
*b = color.b;
80
*a = color.a;
81
}
82
86
static
inline
VuoColor
VuoColor_premultiply
(
VuoColor
c) __attribute__((
const
));
87
static
inline
VuoColor
VuoColor_premultiply
(
VuoColor
c)
88
{
89
return
(
VuoColor
){ c.r*c.a, c.g*c.a, c.b*c.a, c.a };
90
}
91
92
VuoColor
VuoColor_makeWithHSLA
(
VuoReal
hue,
VuoReal
saturation,
VuoReal
luminosity,
VuoReal
alpha);
93
void
VuoColor_getHSLA
(
VuoColor
color,
VuoReal
*h,
VuoReal
*s,
VuoReal
*l,
VuoReal
*a);
94
VuoReal
VuoColor_getLightness
(
VuoColor
color);
95
96
VuoText
VuoColor_getHex
(
VuoColor
color,
VuoBoolean
includeAlpha);
97
98
VuoColor
VuoColor_average
(
VuoList_VuoColor
colors);
99
104
static
inline
bool
VuoColor_isOpaque
(
VuoColor
color)
105
{
106
return
color.a >= 1.;
107
}
108
109
bool
VuoColor_areAllOpaque
(
VuoList_VuoColor
colors);
110
111
VuoReal
VuoColor_brightness
(
VuoColor
color, int32_t
/*VuoThresholdType*/
type);
112
116
static
inline
VuoColor
VuoColor_lerp
(
VuoColor
a,
VuoColor
b,
float
t) __attribute__((
const
));
117
static
inline
VuoColor
VuoColor_lerp
(
VuoColor
a,
VuoColor
b,
float
t)
118
{
119
// Premultiply, then mix, then unpremultiply.
120
VuoColor
ap =
VuoColor_makeWithRGBA
(a.r*a.a, a.g*a.a, a.b*a.a, a.a);
121
VuoColor
bp =
VuoColor_makeWithRGBA
(b.r*b.a, b.g*b.a, b.b*b.a, b.a);
122
123
VuoColor
mixed =
VuoColor_makeWithRGBA
(
124
ap.r*(1-t) + bp.r*t,
125
ap.g*(1-t) + bp.g*t,
126
ap.b*(1-t) + bp.b*t,
127
ap.a*(1-t) + bp.a*t);
128
129
float
alpha =
VuoReal_makeNonzero
(mixed.a);
130
return
VuoColor_makeWithRGBA
(mixed.r/alpha, mixed.g/alpha, mixed.b/alpha, mixed.a);
131
}
132
134
137
char
*
VuoColor_getString
(
const
VuoColor
value);
138
void
VuoColor_retain
(
VuoColor
value);
139
void
VuoColor_release
(
VuoColor
value);
141
146
#ifdef __cplusplus
147
}
148
#endif
149
150
#endif
Generated on Thu Nov 9 2023 16:59:30 for Vuo by
1.9.8