aest 0.1.0
Collection of C++ utility libraries
Loading...
Searching...
No Matches
aest::colors::BasicHSL< RGB > Class Template Referencefinalexport

A color as hue, saturation and lightness, over the encoded RGB space RGB. More...

Inheritance diagram for aest::colors::BasicHSL< RGB >:
aest::colors::ColorBase< BasicHSL< RGB > >

Public Member Functions

constexpr BasicHSL ()
 Default constructor initializes the color to opaque black (0, 0, 0, 1).
constexpr BasicHSL (const float h, const float s, const float l, const float a=1.0f)
 Construct a color from floating-point HSLA values.
Color Channels
constexpr float hue () const noexcept
 Get the hue value in the 0-360 range.
constexpr float saturation () const noexcept
 Get the saturation value in the 0-1 range.
constexpr float lightness () const noexcept
 Get the lightness value in the 0-1 range.
Public Member Functions inherited from aest::colors::ColorBase< BasicHSL< RGB > >
constexpr float alpha () const noexcept
 Get the alpha channel value in the 0-1 range.
constexpr float ch1 () const noexcept
 Get the first channel value.
constexpr float ch2 () const noexcept
 Get the second channel value.
constexpr float ch3 () const noexcept
 Get the third channel value.
constexpr BasicHSL< RGB > opacity (const float alpha) const
 Returns a new color with the same channels and the specified alpha value.

Static Public Attributes

static constexpr std::string_view TYPE
 Color space name, used by the std::formatter specialization.

Static Private Attributes

static constexpr std::string_view MODEL = "HSL"
 Name of the model, the whole space name over SRGB.
static constexpr auto QUALIFIED_CHARS
 The space name over another RGB space, HSL< + RGB::TYPE + >.

Additional Inherited Members

Public Attributes inherited from aest::colors::ColorBase< BasicHSL< RGB > >
friend Derived
 Lets the derived color reach the private constructor and channels.

Detailed Description

template<BoundedRGBSpace RGB>
class aest::colors::BasicHSL< RGB >

A color as hue, saturation and lightness, over the encoded RGB space RGB.

HSL rearranges the channels of RGB, so it covers the same gamut: over DisplayP3 it reaches the P3 colors that HSL over SRGB clips. The hue is wrapped to the [0, 360) range; saturation and lightness are clamped to the 0-1 range. Convert to any other space with convert().

Template Parameters
RGBThe encoded RGB space, such as SRGB: its channels must be in the 0-1 range, so linear spaces are rejected.
See also
CSS Color 4

Definition at line 32 of file Cylindrical.cppm.

Constructor & Destructor Documentation

◆ BasicHSL() [1/2]

template<BoundedRGBSpace RGB>
aest::colors::BasicHSL< RGB >::BasicHSL ( )
inlineconstexpr

Default constructor initializes the color to opaque black (0, 0, 0, 1).

Definition at line 48 of file Cylindrical.cppm.

◆ BasicHSL() [2/2]

template<BoundedRGBSpace RGB>
aest::colors::BasicHSL< RGB >::BasicHSL ( const float h,
const float s,
const float l,
const float a = 1.0f )
inlineconstexpr

Construct a color from floating-point HSLA values.

Parameters
[in]hHue in degrees, wrapped to the 0-360 range
[in]sSaturation value
[in]lLightness value
[in]aAlpha channel value (default 1.0)
Precondition
Every channel is finite: NaN and infinities are undefined behavior.

Definition at line 60 of file Cylindrical.cppm.

Member Function Documentation

◆ hue()

template<BoundedRGBSpace RGB>
float aest::colors::BasicHSL< RGB >::hue ( ) const
inlinenodiscardconstexprnoexcept

Get the hue value in the 0-360 range.

Returns
The color hue

Definition at line 70 of file Cylindrical.cppm.

◆ lightness()

template<BoundedRGBSpace RGB>
float aest::colors::BasicHSL< RGB >::lightness ( ) const
inlinenodiscardconstexprnoexcept

Get the lightness value in the 0-1 range.

Returns
The color lightness

Definition at line 82 of file Cylindrical.cppm.

◆ saturation()

template<BoundedRGBSpace RGB>
float aest::colors::BasicHSL< RGB >::saturation ( ) const
inlinenodiscardconstexprnoexcept

Get the saturation value in the 0-1 range.

Returns
The color saturation

Definition at line 76 of file Cylindrical.cppm.

Member Data Documentation

◆ MODEL

template<BoundedRGBSpace RGB>
std::string_view aest::colors::BasicHSL< RGB >::MODEL = "HSL"
staticconstexprprivate

Name of the model, the whole space name over SRGB.

Definition at line 35 of file Cylindrical.cppm.

◆ QUALIFIED_CHARS

template<BoundedRGBSpace RGB>
auto aest::colors::BasicHSL< RGB >::QUALIFIED_CHARS
staticconstexprprivate
Initial value:
=
join_names<MODEL.size() + RGB::TYPE.size() + 2>({MODEL, "<", RGB::TYPE, ">"})
constexpr std::array< char, Size > join_names(const std::initializer_list< std::string_view > parts)
Concatenate names into a character array, for a color space name built at compile time.
Definition Color.cppm:100
static constexpr std::string_view MODEL
Name of the model, the whole space name over SRGB.

The space name over another RGB space, HSL< + RGB::TYPE + >.

Definition at line 38 of file Cylindrical.cppm.

◆ TYPE

template<BoundedRGBSpace RGB>
std::string_view aest::colors::BasicHSL< RGB >::TYPE
staticconstexpr
Initial value:
=
std::same_as<RGB, SRGB> ? MODEL
: std::string_view{QUALIFIED_CHARS.data(), QUALIFIED_CHARS.size()}
static constexpr auto QUALIFIED_CHARS
The space name over another RGB space, HSL< + RGB::TYPE + >.

Color space name, used by the std::formatter specialization.

Definition at line 43 of file Cylindrical.cppm.


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