11#include "../utility/module.hpp"
12#include "../geometry/module.hpp"
20hi_warning_ignore_msvc(26426);
22namespace hi {
inline namespace v1 {
28 matrix3{0.41239080f, 0.35758434f, 0.18048079f, 0.21263901f, 0.71516868f, 0.07219232f, 0.01933082f, 0.11919478f, 0.95053215f};
55 return 1.055f *
std::pow(u, 0.416f) - 0.055f;
70 return std::pow((u + 0.055f) / 1.055f, 2.4f);
76[[nodiscard]]
inline auto sRGB_linear16_to_gamma8_table_generator() noexcept
80 for (
int i = 0; i != 65536; ++i) {
81 r[i] = narrow_cast<uint8_t>(
88[[nodiscard]]
inline auto sRGB_gamma8_to_linear16_table_generator() noexcept
92 for (
int i = 0; i != 256; ++i) {
99inline auto sRGB_linear16_to_gamma8_table = sRGB_linear16_to_gamma8_table_generator();
100inline auto sRGB_gamma8_to_linear16_table = sRGB_gamma8_to_linear16_table_generator();
114 return detail::sRGB_linear16_to_gamma8_table[u.get()];
127 return detail::sRGB_gamma8_to_linear16_table[u];
140 std::floating_point
auto r,
141 std::floating_point
auto g,
142 std::floating_point
auto b,
143 std::floating_point
auto a)
noexcept
158 std::integral
auto r,
159 std::integral
auto g,
160 std::integral
auto b,
161 std::integral
auto a)
noexcept
167 return color_from_sRGB(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
174 if (tmp.starts_with(
"#")) {
177 if (tmp.size() != 6 && tmp.size() != 8) {
178 throw parse_error(std::format(
"Expecting 6 or 8 hex-digit sRGB color string, got {}.", str));
180 if (tmp.size() == 6) {
184 hilet packed = from_string<uint32_t>(tmp, 16);
186 hilet r = truncate<uint8_t>(packed >> 24);
187 hilet g = truncate<uint8_t>(packed >> 16);
188 hilet b = truncate<uint8_t>(packed >> 8);
189 hilet a = truncate<uint8_t>(packed);
#define hi_axiom_bounds(x,...)
Specify an axiom that the value is within bounds.
Definition assert.hpp:264
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
constexpr matrix3 XYZ_to_sRGB
Matrix to convert XYZ to sRGB.
Definition sRGB.hpp:33
float16 sRGB_gamma8_to_linear16(uint8_t u) noexcept
sRGB gamma to linear float-16 transfer function.
Definition sRGB.hpp:125
uint8_t sRGB_linear16_to_gamma8(float16 u) noexcept
sRGB linear float-16 to gamma transfer function.
Definition sRGB.hpp:112
color color_from_sRGB(std::floating_point auto r, std::floating_point auto g, std::floating_point auto b, std::floating_point auto a) noexcept
Convert gama corrected sRGB color to the linear color.
Definition sRGB.hpp:139
float sRGB_linear_to_gamma(float u) noexcept
sRGB linear to gamma transfer function.
Definition sRGB.hpp:50
constexpr matrix3 sRGB_to_XYZ
Matrix to convert sRGB to XYZ.
Definition sRGB.hpp:27
float sRGB_gamma_to_linear(float u) noexcept
sRGB gamma to linear transfer function.
Definition sRGB.hpp:65
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
This is a RGBA floating point color.
Definition color.hpp:44
A 2D or 3D homogenius matrix for transforming homogenious vectors and points.
Definition matrix.hpp:33