CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Math::TColor< T > Class Template Reference

#include <CeresEngine/Math/Color.hpp>

Public Member Functions

constexpr TColor (T value=0.0) noexcept
 
constexpr TColor (T value, T alpha) noexcept
 
constexpr TColor (T red, T green, T blue, T alpha=1.0) noexcept
 
constexpr TColor (const TColor &) noexcept=default
 
constexpr TColoroperator= (const TColor &) noexcept=default
 
template<typename U >
constexpr TColor (const TColor< U > &other) noexcept
 
constexpr TColor changeRed (T red) const
 Sets the red channel of a color to a new value.
 
constexpr TColor changeGreen (T green) const
 Sets the green channel of a color to a new value.
 
constexpr TColor changeBlue (T blue) const
 Sets the blue channel of a color to a new value.
 
constexpr TColor changeAlpha (T alpha) const
 Sets the alpha channel of a color to a new value.
 
constexpr TColor toHSL () const
 
TColor toRGB () const
 
constexpr TColor darken (T amount) const
 Makes the color darker.
 
constexpr TColor invert (T amount=0.0, bool applyOnAlpha=false) const noexcept
 Inverts the color value.
 
constexpr TColor opacity (T amount) const noexcept
 Applies transparency to the color.
 
constexpr TColor saturate (T saturation) const noexcept
 Saturates the color.
 
constexpr TColor operator+ (const TColor &rhs) const
 
constexpr TColor operator- (const TColor &rhs) const
 
constexpr TColor operator* (T rhs) const
 
constexpr TColor operator* (const TColor &rhs) const
 
constexpr TColor operator/ (const TColor &rhs) const
 
constexpr TColor operator/ (T rhs) const
 
constexpr TColoroperator+= (const TColor &rhs)
 
constexpr TColoroperator+= (T rhs)
 
constexpr TColoroperator-= (const TColor &rhs)
 
constexpr TColoroperator-= (T rhs)
 
constexpr TColoroperator*= (const TColor &rhs)
 
constexpr TColoroperator*= (T rhs)
 
constexpr TColoroperator/= (const TColor &rhs)
 
constexpr TColoroperator/= (T rhs)
 
constexpr bool operator== (const TColor &rhs) const
 
constexpr bool operator!= (const TColor &rhs) const
 
constexpr operator TVector4< T > () const
 

Static Public Member Functions

static TColor fromString (StringView string)
 

Public Attributes

r
 
g
 
b
 
a
 

Static Public Attributes

static const TColor zero {0, 0, 0, 0}
 
static const TColor white {1, 1, 1, 1}
 
static const TColor black {0, 0, 0, 1}
 
static const TColor red {1, 0, 0, 1}
 
static const TColor green {0, 1, 0, 1}
 
static const TColor blue {0, 0, 1, 1}
 

Friends

constexpr TColor operator* (T lhs, const TColor &rhs)
 

Constructor & Destructor Documentation

◆ TColor() [1/5]

template<typename T >
constexpr Math::TColor< T >::TColor ( value = 0.0)
inlineexplicitconstexprnoexcept

◆ TColor() [2/5]

template<typename T >
constexpr Math::TColor< T >::TColor ( value,
alpha 
)
inlineexplicitconstexprnoexcept

◆ TColor() [3/5]

template<typename T >
constexpr Math::TColor< T >::TColor ( red,
green,
blue,
alpha = 1.0 
)
inlineexplicitconstexprnoexcept

◆ TColor() [4/5]

template<typename T >
constexpr Math::TColor< T >::TColor ( const TColor< T > &  )
constexprdefaultnoexcept

◆ TColor() [5/5]

template<typename T >
template<typename U >
constexpr Math::TColor< T >::TColor ( const TColor< U > &  other)
inlineexplicitconstexprnoexcept

Member Function Documentation

◆ changeAlpha()

template<typename T >
constexpr TColor Math::TColor< T >::changeAlpha ( alpha) const
inlineconstexpr

Sets the alpha channel of a color to a new value.

◆ changeBlue()

template<typename T >
constexpr TColor Math::TColor< T >::changeBlue ( blue) const
inlineconstexpr

Sets the blue channel of a color to a new value.

◆ changeGreen()

template<typename T >
constexpr TColor Math::TColor< T >::changeGreen ( green) const
inlineconstexpr

Sets the green channel of a color to a new value.

◆ changeRed()

template<typename T >
constexpr TColor Math::TColor< T >::changeRed ( red) const
inlineconstexpr

Sets the red channel of a color to a new value.

◆ darken()

template<typename T >
constexpr TColor Math::TColor< T >::darken ( amount) const
inlineconstexpr

Makes the color darker.

The amount must be a number between 0.0 and 1.0 (inclusive). Decreases the HSL lightness of the color by that amount.

Note
The darken() function decreases lightness by a fixed amount, which is often not the desired effect. To make a color a certain percentage darker than it was before, use scale() instead.

◆ fromString()

template<typename T >
template TColor< float > Math::TColor< T >::fromString ( StringView  string)
static

◆ invert()

template<typename T >
constexpr TColor Math::TColor< T >::invert ( amount = 0.0,
bool  applyOnAlpha = false 
) const
inlineconstexprnoexcept

Inverts the color value.

The passed parameter defines the proportion of the conversion. A value of 0.0 is completely inverted. A value of 0.0 leaves the input unchanged. Values between 0% and 100% are linear multipliers on the effect. Values of amount over 100% are allowed but the value will be clamped to 1.0.

Note
Negative values are not allowed.

◆ opacity()

template<typename T >
constexpr TColor Math::TColor< T >::opacity ( amount) const
inlineconstexprnoexcept

Applies transparency to the color.

The passed parameter defines the proportion of the conversion. A value of 0.0 is completely transparent. A value of 1.0 leaves the input unchanged. Values between 0.0 and 1.0 are linear multipliers on the effect. Values of amount over 1.0 are allowed but will be clamped to 1.

Note
Negative values are not allowed.

◆ operator TVector4< T >()

template<typename T >
constexpr Math::TColor< T >::operator TVector4< T > ( ) const
inlineexplicitconstexpr

◆ operator!=()

template<typename T >
constexpr bool Math::TColor< T >::operator!= ( const TColor< T > &  rhs) const
inlineconstexpr

◆ operator*() [1/2]

template<typename T >
constexpr TColor Math::TColor< T >::operator* ( const TColor< T > &  rhs) const
inlineconstexpr

◆ operator*() [2/2]

template<typename T >
constexpr TColor Math::TColor< T >::operator* ( rhs) const
inlineconstexpr

◆ operator*=() [1/2]

template<typename T >
constexpr TColor & Math::TColor< T >::operator*= ( const TColor< T > &  rhs)
inlineconstexpr

◆ operator*=() [2/2]

template<typename T >
constexpr TColor & Math::TColor< T >::operator*= ( rhs)
inlineconstexpr

◆ operator+()

template<typename T >
constexpr TColor Math::TColor< T >::operator+ ( const TColor< T > &  rhs) const
inlineconstexpr

◆ operator+=() [1/2]

template<typename T >
constexpr TColor & Math::TColor< T >::operator+= ( const TColor< T > &  rhs)
inlineconstexpr

◆ operator+=() [2/2]

template<typename T >
constexpr TColor & Math::TColor< T >::operator+= ( rhs)
inlineconstexpr

◆ operator-()

template<typename T >
constexpr TColor Math::TColor< T >::operator- ( const TColor< T > &  rhs) const
inlineconstexpr

◆ operator-=() [1/2]

template<typename T >
constexpr TColor & Math::TColor< T >::operator-= ( const TColor< T > &  rhs)
inlineconstexpr

◆ operator-=() [2/2]

template<typename T >
constexpr TColor & Math::TColor< T >::operator-= ( rhs)
inlineconstexpr

◆ operator/() [1/2]

template<typename T >
constexpr TColor Math::TColor< T >::operator/ ( const TColor< T > &  rhs) const
inlineconstexpr

◆ operator/() [2/2]

template<typename T >
constexpr TColor Math::TColor< T >::operator/ ( rhs) const
inlineconstexpr

◆ operator/=() [1/2]

template<typename T >
constexpr TColor & Math::TColor< T >::operator/= ( const TColor< T > &  rhs)
inlineconstexpr

◆ operator/=() [2/2]

template<typename T >
constexpr TColor & Math::TColor< T >::operator/= ( rhs)
inlineconstexpr

◆ operator=()

template<typename T >
constexpr TColor & Math::TColor< T >::operator= ( const TColor< T > &  )
constexprdefaultnoexcept

◆ operator==()

template<typename T >
constexpr bool Math::TColor< T >::operator== ( const TColor< T > &  rhs) const
inlineconstexpr

◆ saturate()

template<typename T >
constexpr TColor Math::TColor< T >::saturate ( saturation) const
inlineconstexprnoexcept

Saturates the color.

The passed parameter defines the proportion of the conversion. A value of 0.0 is completely un-saturated. A value of 1.0 leaves the input unchanged. Other values are linear multipliers on the effect. Values of amount over 1.0 are allowed, providing super-saturated results.

Note
Negative values are not allowed.

◆ toHSL()

template<typename T >
constexpr TColor Math::TColor< T >::toHSL ( ) const
inlineconstexpr

◆ toRGB()

template<typename T >
TColor Math::TColor< T >::toRGB ( ) const
inline

Friends And Related Symbol Documentation

◆ operator*

template<typename T >
constexpr TColor operator* ( lhs,
const TColor< T > &  rhs 
)
friend

Member Data Documentation

◆ a

template<typename T >
T Math::TColor< T >::a

◆ b

template<typename T >
T Math::TColor< T >::b

◆ black

template<typename T >
const TColor< T > Math::TColor< T >::black {0, 0, 0, 1}
static

◆ blue

template<typename T >
const TColor< T > Math::TColor< T >::blue {0, 0, 1, 1}
static

◆ g

template<typename T >
T Math::TColor< T >::g

◆ green

template<typename T >
const TColor< T > Math::TColor< T >::green {0, 1, 0, 1}
static

◆ r

template<typename T >
T Math::TColor< T >::r

◆ red

template<typename T >
const TColor< T > Math::TColor< T >::red {1, 0, 0, 1}
static

◆ white

template<typename T >
const TColor< T > Math::TColor< T >::white {1, 1, 1, 1}
static

◆ zero

template<typename T >
const TColor< T > Math::TColor< T >::zero {0, 0, 0, 0}
static

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