aest 0.1.0
Collection of C++ utility libraries
Loading...
Searching...
No Matches
aest::colors::ColorBase< Derived > Struct Template Referenceexport

Base class for color representations. More...

Public Member Functions

Observers
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.
Modifiers
constexpr Derived opacity (const float alpha) const
 Returns a new color with the same channels and the specified alpha value.

Public Attributes

friend Derived
 Lets the derived color reach the private constructor and channels.

Private Member Functions

constexpr ColorBase (const float alpha, const float channel1, const float channel2, const float channel3)
 Construct a color from raw channel values.

Private Attributes

float _a
 Alpha channel value in the 0-1 range.
float _ch1
 First channel value.
float _ch2
 Second channel value.
float _ch3
 Third channel value.

Friends

Identity operators
constexpr bool operator== (const Derived color1, const Derived color2)
 Compare two colors of same type by checking each channel for equality.

Detailed Description

template<typename Derived>
struct aest::colors::ColorBase< Derived >

Base class for color representations.

Template Parameters
DerivedThe derived color class

Definition at line 140 of file Color.cppm.

Constructor & Destructor Documentation

◆ ColorBase()

template<typename Derived>
aest::colors::ColorBase< Derived >::ColorBase ( const float alpha,
const float channel1,
const float channel2,
const float channel3 )
inlineexplicitconstexprprivate

Construct a color from raw channel values.

Parameters
[in]alphaAlpha channel value, clamped to the 0-1 range
[in]channel1First channel value, stored as is
[in]channel2Second channel value, stored as is
[in]channel3Third channel value, stored as is

Definition at line 158 of file Color.cppm.

Member Function Documentation

◆ alpha()

template<typename Derived>
float aest::colors::ColorBase< Derived >::alpha ( ) const
inlinenodiscardconstexprnoexcept

Get the alpha channel value in the 0-1 range.

Returns
The alpha channel value

Definition at line 175 of file Color.cppm.

◆ ch1()

template<typename Derived>
float aest::colors::ColorBase< Derived >::ch1 ( ) const
inlinenodiscardconstexprnoexcept

Get the first channel value.

Returns
The first channel value
Note
There are no guarantees on the value range. Refer to the derived class for more information.

Definition at line 183 of file Color.cppm.

◆ ch2()

template<typename Derived>
float aest::colors::ColorBase< Derived >::ch2 ( ) const
inlinenodiscardconstexprnoexcept

Get the second channel value.

Returns
The second channel value
Note
There are no guarantees on the value range. Refer to the derived class for more information.

Definition at line 191 of file Color.cppm.

◆ ch3()

template<typename Derived>
float aest::colors::ColorBase< Derived >::ch3 ( ) const
inlinenodiscardconstexprnoexcept

Get the third channel value.

Returns
The third channel value
Note
There are no guarantees on the value range. Refer to the derived class for more information.

Definition at line 199 of file Color.cppm.

◆ opacity()

template<typename Derived>
Derived aest::colors::ColorBase< Derived >::opacity ( const float alpha) const
inlinenodiscardconstexpr

Returns a new color with the same channels and the specified alpha value.

Parameters
[in]alphaThe new alpha value for the returned color, in the 0-1 range.
Returns
a new color with the desired opacity.

Definition at line 209 of file Color.cppm.

◆ operator==

template<typename Derived>
bool operator== ( const Derived color1,
const Derived color2 )
friend

Compare two colors of same type by checking each channel for equality.

Parameters
[in]color1First color
[in]color2Second color
Returns
true if all channels have the same value, false otherwise.

Definition at line 223 of file Color.cppm.

Member Data Documentation

◆ _a

template<typename Derived>
float aest::colors::ColorBase< Derived >::_a
private

Alpha channel value in the 0-1 range.

Definition at line 146 of file Color.cppm.

◆ _ch1

template<typename Derived>
float aest::colors::ColorBase< Derived >::_ch1
private

First channel value.

Definition at line 147 of file Color.cppm.

◆ _ch2

template<typename Derived>
float aest::colors::ColorBase< Derived >::_ch2
private

Second channel value.

Definition at line 148 of file Color.cppm.

◆ _ch3

template<typename Derived>
float aest::colors::ColorBase< Derived >::_ch3
private

Third channel value.

Definition at line 149 of file Color.cppm.

◆ Derived

template<typename Derived>
friend aest::colors::ColorBase< Derived >::Derived

Lets the derived color reach the private constructor and channels.

Definition at line 143 of file Color.cppm.


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