10 template<ColorFormat Format>
110 std::clamp(this->red, 0.0f, 1.0f),
111 std::clamp(this->green, 0.0f, 1.0f),
112 std::clamp(this->blue, 0.0f, 1.0f),
119 ice::f32 const L = 0.4122214708f * this->red + 0.5363325363f * this->green + 0.0514459929f * this->blue;
120 ice::f32 const M = 0.2119034982f * this->red + 0.6806995451f * this->green + 0.1073969566f * this->blue;
121 ice::f32 const S = 0.0883024619f * this->red + 0.2817188376f * this->green + 0.6299787005f * this->blue;
127 ice::f32 const oklab_lightness = 0.2104542553f * l3r + 0.7936177850f * m3r - 0.0040720468f * s3r;
128 ice::f32 const oklab_a = 1.9779984951f * l3r - 2.4285922050f * m3r + 0.4505937099f * s3r;
129 ice::f32 const oklab_b = 0.0259040371f * l3r + 0.7827717662f * m3r - 0.8086757660f * s3r;
131 return { oklab_lightness, oklab_a, oklab_b, this->alpha };
144 return { r, g, b, this->alpha };
151 ice::u8(clipped.red * 255.f + 0.5f),
152 ice::u8(clipped.green * 255.f + 0.5f),
153 ice::u8(clipped.blue * 255.f + 0.5f),
154 ice::u8(clipped.alpha * 255.f + 0.5f),
167 return { r, g, b, this->alpha };
193 ice::f32 const L_clipped = L0 * (1.f - t) + t * L;
199 return { L_clipped, C_clipped * a_, C_clipped * b_, this->alpha };
205 ice::f32 const l2 = (this->lightness * 1.0f) + (this->a * 0.3963377774f) + (this->b * 0.2158037573f);
206 ice::f32 const m2 = (this->lightness * 1.0f) + (this->a * -0.1055613458f) + (this->b * -0.0638541728f);
207 ice::f32 const s2 = (this->lightness * 1.0f) + (this->a * -0.0894841775f) + (this->b * -1.291485548f);
214 ice::f32 const r_lin = (+4.0767416621f * l3) - (3.3077115913f * m3) + (0.2309699292f * s3);
215 ice::f32 const g_lin = (-1.2684380046f * l3) + (2.6097574011f * m3) - (0.3413193965f * s3);
216 ice::f32 const b_lin = (-0.0041960863f * l3) - (0.7034186147f * m3) + (1.7076147010f * s3);
219 return { r_lin, g_lin, b_lin, this->alpha };
224 ice::f32 const oklch_lightness = this->lightness;
227 ice::f32 const oklch_h = oklch_ht < 0.0f ? oklch_ht + 360.f : oklch_ht;
296 ice::f32 const L_clipped = L0 * (1.f - t) + t * L;
303 return { L_clipped, C_clipped, this->hue, this->alpha };
314 ice::f32 const oklab_lightness = this->lightness;
317 return { oklab_lightness, oklab_a, oklab_b, this->alpha };
Definition hashmap_details.hxx:13
constexpr auto find_cusp(ice::f32 a, ice::f32 b) noexcept -> ice::detail::OkLCH_HueCusp
Finds L_cusp and C_cusp for a given 'a' and 'b' values of OKLAB color.
Definition color_details.hxx:168
constexpr auto find_cusp_ch(ice::f32 chroma, ice::rad hue) noexcept -> ice::detail::OkLCH_HueCusp
Finds L_cusp and C_cusp for a given 'a' and 'b' values of OKLAB color.
Definition color_details.hxx:186
constexpr auto linear_to_srgb(ice::f32 x) noexcept -> ice::f32
Definition color_details.hxx:29
constexpr auto srgb_to_linear(ice::f32 x) noexcept -> ice::f32
Definition color_details.hxx:45
constexpr auto find_gamut_intersection(ice::detail::OkLCH_HueCusp cusp, ice::f32 L1, ice::f32 C1, ice::f32 L0) noexcept -> ice::f32
Definition color_details.hxx:234
rad32 rad
Definition angles.hxx:170
constexpr auto max(arr_t< Size, T > left, arr_t< Size, U > right) noexcept -> arr_t< Size, T >
Definition array_operations.hxx:49
auto atan2(f32 x, f32 y) noexcept -> f32
Definition common.hxx:230
constexpr auto cbrt(f32 val) noexcept -> f32
Definition common.hxx:68
constexpr auto sgn(f32 val) noexcept -> f32
Definition common.hxx:53
constexpr auto sin(rad radians) noexcept -> f32
Definition common.hxx:156
static constexpr ice::f32 f32_eps
Definition constants.hxx:10
constexpr auto cos(rad radians) noexcept -> f32
Definition common.hxx:186
constexpr auto sqrt(f32 val) noexcept -> f32
Definition common.hxx:93
constexpr auto abs(f32 val) noexcept -> f32
Definition common.hxx:58
constexpr auto radians(deg degrees) noexcept -> rad
Definition common.hxx:33
constexpr auto clamp(f32 val, f32 min, f32 max) noexcept -> f32
Definition common.hxx:28
SPDX-License-Identifier: MIT.
Definition array.hxx:12
ColorFormat
Definition color_enums.hxx:18
@ LinearRGBu8
Definition color_enums.hxx:27
@ OkLAB
Definition color_enums.hxx:21
@ OkLCHu8
Definition color_enums.hxx:26
@ StandardRGB
Definition color_enums.hxx:23
@ LinearRGB
Definition color_enums.hxx:22
@ OkLCH
Definition color_enums.hxx:20
ColorSpace
Definition color_enums.hxx:11
@ SRGB
Definition color_enums.hxx:12
std::uint16_t u16
Definition types.hxx:25
std::uint32_t u32
Definition types.hxx:26
float f32
Definition types.hxx:16
std::uint8_t u8
Definition types.hxx:24
Definition color_data.hxx:11
Holds information where the 'lightness' and 'chroma' are at the highest point of the OkLCH color curv...
Definition color_details.hxx:19
constexpr auto to_rad32(this deg32 self) noexcept -> rad32
Definition angles.hxx:108