HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
color_space.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
11#include "../geometry/geometry.hpp"
12#include "../macros.hpp"
13#include <compare>
14
15hi_export_module(hikogui.color.color_space);
16
17hi_export namespace hi {
18inline namespace v1 {
19
35[[nodiscard]] constexpr matrix3
36color_primaries_to_RGBtoXYZ(float wx, float wy, float rx, float ry, float gx, float gy, float bx, float by) noexcept
37{
38 auto const w = vector3{wx, wy, 1.0f - wx - wy};
39 auto const r = vector3{rx, ry, 1.0f - rx - ry};
40 auto const g = vector3{gx, gy, 1.0f - gx - gy};
41 auto const b = vector3{bx, by, 1.0f - bx - by};
42
43 // Calculate white point's tristimulus values from coordinates
44 auto const W = vector3{1.0f * (w.x() / w.y()), 1.0f, 1.0f * (w.z() / w.y())};
45
46 // C is the chromaticity matrix.
47 auto const C = matrix3{r, g, b};
48
49 // solve tristimulus sums.
50 auto const S = scale3{~C * W};
51
52 return C * S;
53}
54
55}} // namespace hi::inline v1
constexpr matrix3 color_primaries_to_RGBtoXYZ(float wx, float wy, float rx, float ry, float gx, float gy, float bx, float by) noexcept
Create a color space conversion matrix.
Definition color_space.hpp:36
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
A 2D or 3D homogenius matrix for transforming homogenious vectors and points.
Definition matrix3.hpp:36
Definition scale3.hpp:19
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector3.hpp:26