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/module.hpp"
12#include "../macros.hpp"
13
14namespace hi {
15inline namespace v1 {
16
32[[nodiscard]] constexpr matrix3
33color_primaries_to_RGBtoXYZ(float wx, float wy, float rx, float ry, float gx, float gy, float bx, float by) noexcept
34{
35 hilet w = vector3{wx, wy, 1.0f - wx - wy};
36 hilet r = vector3{rx, ry, 1.0f - rx - ry};
37 hilet g = vector3{gx, gy, 1.0f - gx - gy};
38 hilet b = vector3{bx, by, 1.0f - bx - by};
39
40 // Calculate white point's tristimulus values from coordinates
41 hilet W = vector3{1.0f * (w.x() / w.y()), 1.0f, 1.0f * (w.z() / w.y())};
42
43 // C is the chromaticity matrix.
44 hilet C = matrix3{r, g, b};
45
46 // solve tristimulus sums.
47 hilet S = scale3{~C * W};
48
49 return C * S;
50}
51
52}} // 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:33
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
A 2D or 3D homogenius matrix for transforming homogenious vectors and points.
Definition matrix3.hpp:30
Definition scale3.hpp:14
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector3.hpp:20