10 return (c < 0.0) ? 0.0 : c * (1.0 / 12.92);
13 return pow((c + 0.055) * (1.0 / 1.055), 2.4);
20 return (c < 0.0) ? 0.0 : c * 12.92;
23 return 1.055 *
pow(c, 1.0 / 2.4) - 0.055;
43 if (alpha != 1.0 && alpha != 0.0) {
63 if (
y != 0.0 &&
Y != 0.0) {
64 Z = ((1.0 -
x -
y) /
y) *
Y;
70 return color(
X,
Y,
Z);
75 return color(3.240479 *
x + -1.537150 *
y + -0.498535 *
z,
76 -0.969256 *
x + 1.875991 *
y + 0.041556 *
z,
77 0.055648 *
x + -0.204043 *
y + 1.057311 *
z);
82 float cmax, cmin, h, s,
v, cdelta;
85 cmax =
max(rgb[0],
max(rgb[1], rgb[2]));
86 cmin =
min(rgb[0],
min(rgb[1], rgb[2]));
103 c = (color(cmax, cmax, cmax) - rgb) / cdelta;
105 if (rgb[0] == cmax) {
108 else if (rgb[1] == cmax) {
109 h = 2.0 + c[0] - c[2];
112 h = 4.0 + c[1] - c[0];
122 return color(h, s,
v);
127 float i, f, p, q, t, h, s,
v;
135 rgb = color(
v,
v,
v);
145 rgb = color(f, f, f);
147 q =
v * (1.0 - (s * f));
148 t =
v * (1.0 - (s * (1.0 - f)));
151 rgb = color(
v, t, p);
154 rgb = color(q,
v, p);
157 rgb = color(p,
v, t);
160 rgb = color(p, q,
v);
163 rgb = color(t, p,
v);
166 rgb = color(
v, p, q);
175 float cmax, cmin, h, s,
l;
177 cmax =
max(rgb[0],
max(rgb[1], rgb[2]));
178 cmin =
min(rgb[0],
min(rgb[1], rgb[2]));
179 l =
min(1.0, (cmax + cmin) / 2.0);
185 float cdelta = cmax - cmin;
186 s =
l > 0.5 ? cdelta / (2.0 - cmax - cmin) : cdelta / (cmax + cmin);
187 if (cmax == rgb[0]) {
188 h = (rgb[1] - rgb[2]) / cdelta + (rgb[1] < rgb[2] ? 6.0 : 0.0);
190 else if (cmax == rgb[1]) {
191 h = (rgb[2] - rgb[0]) / cdelta + 2.0;
194 h = (rgb[0] - rgb[1]) / cdelta + 4.0;
199 return color(h, s,
l);
204 float nr, ng, nb, chroma, h, s,
l;
210 nr =
abs(h * 6.0 - 3.0) - 1.0;
211 ng = 2.0 -
abs(h * 6.0 - 2.0);
212 nb = 2.0 -
abs(h * 6.0 - 4.0);
214 nr =
clamp(nr, 0.0, 1.0);
215 nb =
clamp(nb, 0.0, 1.0);
216 ng =
clamp(ng, 0.0, 1.0);
218 chroma = (1.0 -
abs(2.0 *
l - 1.0)) * s;
220 return color((nr - 0.5) * chroma +
l, (ng - 0.5) * chroma +
l, (nb - 0.5) * chroma +
l);
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
constexpr T clamp(T, U, U) RET
float color_scene_linear_to_srgb(float c)
color hsl_to_rgb(color hsl)
color hsv_to_rgb(color hsv)
float color_srgb_to_scene_linear(float c)
color rgb_to_hsl(color rgb)
color color_unpremultiply(color c, float alpha)
color xyY_to_xyz(float x, float y, float Y)
color xyz_to_rgb(float x, float y, float z)
color rgb_to_hsv(color rgb)