45#ifndef UFO_VISION_COLOR_LCH_HPP
46#define UFO_VISION_COLOR_LCH_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 Lch const&
b)
noexcept =
default;
132 requires(std::integral<T> || std::floating_point<T>)
174 Lch const&
b)
noexcept =
default;
186 requires(std::integral<T> || std::floating_point<T>)
225 Lch const&
b)
noexcept =
default;
237 requires(std::integral<T> || std::floating_point<T>)
284 Lch 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.chroma /
static_cast<T
>(color.weight);
325template <
class T, ColorFlags Flags>
328 if constexpr (
weightset(Flags) && std::floating_point<T>) {
329 return color.hue /
static_cast<T
>(color.weight);
381template <
class T, ColorFlags Flags>
384 out <<
"Lightness: " << c.lightness <<
" Chroma: " << c.chroma <<
" Hue: " << c.hue;
386 out <<
" Alpha: " << +c.alpha;
389 out <<
" Weight: " << c.weight;
402template <
class T, ufo::ColorFlags Flags>
403struct std::formatter<
ufo::Lch<T, Flags>> {
404 constexpr auto parse(std::format_parse_context& ctx) {
return ctx.begin(); }
408 auto out = std::format_to(ctx.out(),
"Lightness: {} Chroma: {} Hue: {}", c.lightness,
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 chroma(Lch< T, Flags > color) noexcept
Returns the un-weighted chroma 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.
constexpr T hue(Lch< T, Flags > color) noexcept
Returns the un-weighted hue angle value.
friend constexpr bool operator==(Lch const &a, Lch const &b) noexcept=default
Returns true if a and b are equal.
T lightness
Lightness channel.
T hue
Hue angle in degrees.
friend constexpr bool operator==(Lch const &a, Lch const &b) noexcept=default
Returns true if a and b are equal.
T hue
Hue angle (possibly pre-multiplied by weight).
T chroma
Chroma (possibly pre-multiplied by weight).
float weight
Accumulation weight (positive).
T lightness
Lightness channel (possibly pre-multiplied by weight).
friend constexpr bool operator==(Lch const &a, Lch const &b) noexcept=default
Returns true if a and b are equal.
T hue
Hue angle in degrees.
T lightness
Lightness channel.
T chroma
Chroma (possibly pre-multiplied by weight).
friend constexpr bool operator==(Lch const &a, Lch const &b) noexcept=default
Returns true if a and b are equal.
T hue
Hue angle (possibly pre-multiplied by weight).
T lightness
Lightness channel (possibly pre-multiplied by weight).
float weight
Accumulation weight (positive).