Krita Source Code Documentation
Loading...
Searching...
No Matches
HSLType Struct Reference

#include <KoColorSpaceMaths.h>

Static Public Member Functions

template<class TReal >
static TReal getLightness (TReal r, TReal g, TReal b)
 
template<class TReal >
static TReal getSaturation (TReal r, TReal g, TReal b)
 

Static Public Attributes

static constexpr bool lightnessIsAverage = true
 

Detailed Description

Definition at line 944 of file KoColorSpaceMaths.h.

Member Function Documentation

◆ getLightness()

template<class TReal >
static TReal HSLType::getLightness ( TReal r,
TReal g,
TReal b )
inlinestatic

Definition at line 947 of file KoColorSpaceMaths.h.

947 {
948 TReal max = Arithmetic::max(r, g, b);
949 TReal min = Arithmetic::min(r, g, b);
950 return (max + min) * TReal(0.5);
951 }
T max(T a, T b, T c)
T min(T a, T b, T c)
constexpr std::enable_if< sizeof...(values)==0, size_t >::type max()

References Arithmetic::max(), and Arithmetic::min().

◆ getSaturation()

template<class TReal >
static TReal HSLType::getSaturation ( TReal r,
TReal g,
TReal b )
inlinestatic

Definition at line 954 of file KoColorSpaceMaths.h.

954 {
955 TReal max = Arithmetic::max(r, g, b);
956 TReal min = Arithmetic::min(r, g, b);
957 TReal chroma = max - min;
958 TReal light = (max + min) * TReal(0.5);
959 TReal div = TReal(1.0) - std::abs(TReal(2.0)*light - TReal(1.0));
960
961 if(div > std::numeric_limits<TReal>::epsilon())
962 return chroma / div;
963
964 return TReal(0.0);
965 }
KoColorSpaceMathsTraits< T >::compositetype div(T a, T b)

References Arithmetic::max(), and Arithmetic::min().

Member Data Documentation

◆ lightnessIsAverage

constexpr bool HSLType::lightnessIsAverage = true
staticconstexpr

Definition at line 967 of file KoColorSpaceMaths.h.


The documentation for this struct was generated from the following file: