45#ifndef UFO_VISION_COLOR_RGB_HPP
46#define UFO_VISION_COLOR_RGB_HPP
49#include <ufo/vision/color/flags.hpp>
73template <
class T =
float, ColorFlags Flags = ColorFlags::None>
74 requires(std::integral<T> || std::floating_point<T>)
86 requires(std::integral<T> || std::floating_point<T>)
120 Rgb const&
b)
noexcept =
default;
131 requires(std::integral<T> || std::floating_point<T>)
173 Rgb const&
b)
noexcept =
default;
185 requires(std::integral<T> || std::floating_point<T>)
224 Rgb const&
b)
noexcept =
default;
236 requires(std::integral<T> || std::floating_point<T>)
283 Rgb const&
b)
noexcept =
default;
292template <
class T, ColorFlags Flags>
295 if constexpr (
weightset(Flags) && std::floating_point<T>) {
296 return color.red /
static_cast<T
>(color.weight);
308template <
class T, ColorFlags Flags>
311 if constexpr (
weightset(Flags) && std::floating_point<T>) {
312 return color.green /
static_cast<T
>(color.weight);
324template <
class T, ColorFlags Flags>
327 if constexpr (
weightset(Flags) && std::floating_point<T>) {
328 return color.blue /
static_cast<T
>(color.weight);
380template <
class T, ColorFlags Flags>
383 out <<
"Red: " << +c.red <<
" Green: " << +c.green <<
" Blue: " << +c.blue;
385 out <<
" Alpha: " << +c.alpha;
388 out <<
" Weight: " << c.weight;
401template <
class T, ufo::ColorFlags Flags>
402struct std::formatter<
ufo::Rgb<T, Flags>> {
403 constexpr auto parse(std::format_parse_context& ctx) {
return ctx.begin(); }
407 auto out = std::format_to(ctx.out(),
"Red: {} Green: {} Blue: {}", +c.red, +c.green,
410 out = std::format_to(out,
" Alpha: {}", +c.alpha);
413 out = std::format_to(out,
" Weight: {}", c.weight);
consteval bool alphaset(ColorFlags flags) noexcept
Returns true if the Alpha flag is set.
consteval bool weightset(ColorFlags flags) noexcept
Returns true if the Weight flag is set.
All vision-related classes and functions.
constexpr T b(Lab< T, Flags > color) noexcept
Returns the un-weighted blue–yellow axis value.
constexpr T green(Lrgb< T, Flags > color) noexcept
Returns the un-weighted green channel value.
constexpr T a(Lab< T, Flags > color) noexcept
Returns the un-weighted green–red axis value.
constexpr T blue(Lrgb< T, Flags > color) noexcept
Returns the un-weighted blue channel value.
constexpr T red(Lrgb< T, Flags > color) noexcept
Returns the un-weighted red channel value.
friend constexpr bool operator==(Rgb const &a, Rgb const &b) noexcept=default
Returns true if a and b are equal.
float weight
Accumulation weight (positive).
T green
Green channel (possibly pre-multiplied by weight).
T alpha
Alpha channel (possibly pre-multiplied by weight).
friend constexpr bool operator==(Rgb const &a, Rgb const &b) noexcept=default
Returns true if a and b are equal.
T blue
Blue channel (possibly pre-multiplied by weight).
T red
Red channel (possibly pre-multiplied by weight).
friend constexpr bool operator==(Rgb const &a, Rgb const &b) noexcept=default
Returns true if a and b are equal.
T blue
Blue channel (possibly pre-multiplied by weight).
T green
Green channel (possibly pre-multiplied by weight).
T red
Red channel (possibly pre-multiplied by weight).
friend constexpr bool operator==(Rgb const &a, Rgb const &b) noexcept=default
Returns true if a and b are equal.
float weight
Accumulation weight (positive).
Gamma-encoded sRGB color.