45#ifndef UFO_VISION_COLOR_LAB_HPP
46#define UFO_VISION_COLOR_LAB_HPP
49#include <ufo/vision/color/flags.hpp>
75template <
class T =
float, ColorFlags Flags = ColorFlags::None>
76 requires(std::integral<T> || std::floating_point<T>)
87 requires(std::integral<T> || std::floating_point<T>)
121 Lab const&
b)
noexcept =
default;
132 requires(std::integral<T> || std::floating_point<T>)
174 Lab const&
b)
noexcept =
default;
186 requires(std::integral<T> || std::floating_point<T>)
225 Lab const&
b)
noexcept =
default;
237 requires(std::integral<T> || std::floating_point<T>)
284 Lab const&
b)
noexcept =
default;
293template <
class T, ColorFlags Flags>
296 if constexpr (
weightset(Flags) && std::floating_point<T>) {
297 return color.lightness /
static_cast<T
>(color.weight);
299 return color.lightness;
309template <
class T, ColorFlags Flags>
312 if constexpr (
weightset(Flags) && std::floating_point<T>) {
313 return color.a /
static_cast<T
>(color.weight);
325template <
class T, ColorFlags Flags>
328 if constexpr (
weightset(Flags) && std::floating_point<T>) {
329 return color.b /
static_cast<T
>(color.weight);
381template <
class T, ColorFlags Flags>
384 out <<
"Lightness: " << c.lightness <<
" a: " << c.a <<
" b: " << c.b;
386 out <<
" Alpha: " << +c.alpha;
389 out <<
" Weight: " << c.weight;
402template <
class T, ufo::ColorFlags Flags>
403struct std::formatter<
ufo::Lab<T, Flags>> {
404 constexpr auto parse(std::format_parse_context& ctx) {
return ctx.begin(); }
409 std::format_to(ctx.out(),
"Lightness: {} a: {} b: {}", c.lightness, c.a, c.b);
411 out = std::format_to(out,
" Alpha: {}", +c.alpha);
414 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 a(Lab< T, Flags > color) noexcept
Returns the un-weighted green–red axis value.
constexpr T lightness(Lab< T, Flags > color) noexcept
Returns the un-weighted lightness value.
friend constexpr bool operator==(Lab const &a, Lab const &b) noexcept=default
Returns true if a and b are equal.
T lightness
Lightness channel.
T b
Blue–yellow axis (possibly pre-multiplied by weight).
friend constexpr bool operator==(Lab const &a, Lab const &b) noexcept=default
Returns true if a and b are equal.
T lightness
Lightness channel (possibly pre-multiplied by weight).
float weight
Accumulation weight (positive).
T a
Green–red axis (possibly pre-multiplied by weight).
friend constexpr bool operator==(Lab const &a, Lab const &b) noexcept=default
Returns true if a and b are equal.
T lightness
Lightness channel.
friend constexpr bool operator==(Lab const &a, Lab const &b) noexcept=default
Returns true if a and b are equal.
T lightness
Lightness channel (possibly pre-multiplied by weight).
T b
Blue–yellow axis (possibly pre-multiplied by weight).
T a
Green–red axis (possibly pre-multiplied by weight).
float weight
Accumulation weight (positive).