galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::Colour Class Referencefinal

Represents an RGBA colour. More...

#include <Colour.hpp>

+ Collaboration diagram for galaxy::Colour:

Public Member Functions

 Colour () noexcept
 Constructor.
 
 Colour (const std::uint8_t r, const std::uint8_t g, const std::uint8_t b, const std::uint8_t a=OPAQUE) noexcept
 Colour constructor.
 
 Colour (Colour &&) noexcept
 Move constructor.
 
 Colour (const Colour &) noexcept
 Copy constructor.
 
Colouroperator= (Colour &&) noexcept
 Move assignment operator.
 
Colouroperator= (const Colour &w) noexcept
 Copy assignment operator.
 
 ~Colour () noexcept
 Destructor.
 
void r (const std::uint8_t r) noexcept
 Red.
 
void g (const std::uint8_t g) noexcept
 Green.
 
void b (const std::uint8_t b) noexcept
 Blue.
 
void a (const std::uint8_t a) noexcept
 Alpha.
 
std::uint8_t r () const noexcept
 Get red.
 
std::uint8_t g () const noexcept
 Get green.
 
std::uint8_t b () const noexcept
 Get blue.
 
std::uint8_t a () const noexcept
 Get alpha.
 
void set_from_norm (const glm::vec4 &rgba) noexcept
 Set RGBA from normalizaed values.
 
glm::vec4 normalize () noexcept
 Get normalized rgba vec4.
 
std::array< std::uint8_t, 4 > array () noexcept
 Get as array.
 
auto operator<=> (const Colour &) const =default
 Three-way comparison.
 
bool operator== (const Colour &) const =default
 Equality comparison.
 
bool operator!= (const Colour &) const =default
 Inequality comparison.
 
bool operator< (const Colour &) const =default
 Less than comparison.
 
bool operator> (const Colour &) const =default
 Greater than comparison.
 
bool operator<= (const Colour &) const =default
 Less than or equal comparison.
 
bool operator>= (const Colour &) const =default
 Greater than or equal comparison.
 

Static Public Attributes

static const constexpr std::uint8_t OPAQUE = 255
 Opaque colour.
 
static const constexpr std::uint8_t TRANSPARENT = 0
 Transparent colour.
 
static const constexpr std::uint8_t OFFSET = 0xFF
 Colour offsets for normalization.
 
static const constexpr std::uint8_t LOWER = 0
 Colour lower bounds.
 
static const constexpr std::uint8_t UPPER = 255
 Colour upper bounds.
 

Private Attributes

std::uint8_t m_red
 Red channel.
 
std::uint8_t m_green
 Green channel.
 
std::uint8_t m_blue
 Blue channel.
 
std::uint8_t m_alpha
 Alpha channel.
 

Detailed Description

Represents an RGBA colour.

Definition at line 23 of file Colour.hpp.

Constructor & Destructor Documentation

◆ Colour() [1/4]

galaxy::Colour::Colour ( )
noexcept

Constructor.

Definition at line 16 of file Colour.cpp.

◆ Colour() [2/4]

galaxy::Colour::Colour ( const std::uint8_t r,
const std::uint8_t g,
const std::uint8_t b,
const std::uint8_t a = OPAQUE )
noexcept

Colour constructor.

Parameters
rRed. 0 - 255.
gGreen. 0 - 255.
bBlue. 0 - 255.
aAlpha. 0 - 255.

Definition at line 24 of file Colour.cpp.

◆ Colour() [3/4]

galaxy::Colour::Colour ( Colour && c)
noexcept

Move constructor.

Definition at line 32 of file Colour.cpp.

◆ Colour() [4/4]

galaxy::Colour::Colour ( const Colour & c)
noexcept

Copy constructor.

Definition at line 40 of file Colour.cpp.

◆ ~Colour()

galaxy::Colour::~Colour ( )
noexcept

Destructor.

Definition at line 74 of file Colour.cpp.

Member Function Documentation

◆ operator=() [1/2]

Colour & galaxy::Colour::operator= ( Colour && c)
noexcept

Move assignment operator.

Definition at line 48 of file Colour.cpp.

◆ operator=() [2/2]

Colour & galaxy::Colour::operator= ( const Colour & w)
noexcept

Copy assignment operator.

Definition at line 61 of file Colour.cpp.

◆ r() [1/2]

void galaxy::Colour::r ( const std::uint8_t r)
noexcept

Red.

Parameters
r0 - 255.

Definition at line 78 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ g() [1/2]

void galaxy::Colour::g ( const std::uint8_t g)
noexcept

Green.

Parameters
g0 - 255.

Definition at line 83 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ b() [1/2]

void galaxy::Colour::b ( const std::uint8_t b)
noexcept

Blue.

Parameters
b0 - 255.

Definition at line 88 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ a() [1/2]

void galaxy::Colour::a ( const std::uint8_t a)
noexcept

Alpha.

Parameters
a0 - 255.

Definition at line 93 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ r() [2/2]

std::uint8_t galaxy::Colour::r ( ) const
noexcept

Get red.

Returns
Int in 0 - 255 range.

Definition at line 98 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ g() [2/2]

std::uint8_t galaxy::Colour::g ( ) const
noexcept

Get green.

Returns
Int in 0 - 255 range.

Definition at line 103 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ b() [2/2]

std::uint8_t galaxy::Colour::b ( ) const
noexcept

Get blue.

Returns
Int in 0 - 255 range.

Definition at line 108 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ a() [2/2]

std::uint8_t galaxy::Colour::a ( ) const
noexcept

Get alpha.

Returns
Int in 0 - 255 range.

Definition at line 113 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ set_from_norm()

void galaxy::Colour::set_from_norm ( const glm::vec4 & rgba)
noexcept

Set RGBA from normalizaed values.

Parameters
rgbaClamps from 0.0f to 1.0f.

Definition at line 118 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ normalize()

glm::vec4 galaxy::Colour::normalize ( )
nodiscardnoexcept

Get normalized rgba vec4.

Returns
Vec4 normalized to 0.0f - 1.0f.

Definition at line 126 of file Colour.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ array()

std::array< std::uint8_t, 4 > galaxy::Colour::array ( )
nodiscardnoexcept

Get as array.

Returns
0=red, 1=green, 2=blue, 3=alpha

Definition at line 138 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ operator<=>()

auto galaxy::Colour::operator<=> ( const Colour & ) const
default

Three-way comparison.

◆ operator==()

bool galaxy::Colour::operator== ( const Colour & ) const
default

Equality comparison.

◆ operator!=()

bool galaxy::Colour::operator!= ( const Colour & ) const
default

Inequality comparison.

◆ operator<()

bool galaxy::Colour::operator< ( const Colour & ) const
default

Less than comparison.

◆ operator>()

bool galaxy::Colour::operator> ( const Colour & ) const
default

Greater than comparison.

◆ operator<=()

bool galaxy::Colour::operator<= ( const Colour & ) const
default

Less than or equal comparison.

◆ operator>=()

bool galaxy::Colour::operator>= ( const Colour & ) const
default

Greater than or equal comparison.

Member Data Documentation

◆ OPAQUE

const constexpr std::uint8_t galaxy::Colour::OPAQUE = 255
inlinestaticconstexpr

Opaque colour.

Definition at line 29 of file Colour.hpp.

◆ TRANSPARENT

const constexpr std::uint8_t galaxy::Colour::TRANSPARENT = 0
inlinestaticconstexpr

Transparent colour.

Definition at line 34 of file Colour.hpp.

◆ OFFSET

const constexpr std::uint8_t galaxy::Colour::OFFSET = 0xFF
inlinestaticconstexpr

Colour offsets for normalization.

Definition at line 39 of file Colour.hpp.

◆ LOWER

const constexpr std::uint8_t galaxy::Colour::LOWER = 0
inlinestaticconstexpr

Colour lower bounds.

Definition at line 44 of file Colour.hpp.

◆ UPPER

const constexpr std::uint8_t galaxy::Colour::UPPER = 255
inlinestaticconstexpr

Colour upper bounds.

Definition at line 49 of file Colour.hpp.

◆ m_red

std::uint8_t galaxy::Colour::m_red
private

Red channel.

Definition at line 210 of file Colour.hpp.

◆ m_green

std::uint8_t galaxy::Colour::m_green
private

Green channel.

Definition at line 215 of file Colour.hpp.

◆ m_blue

std::uint8_t galaxy::Colour::m_blue
private

Blue channel.

Definition at line 220 of file Colour.hpp.

◆ m_alpha

std::uint8_t galaxy::Colour::m_alpha
private

Alpha channel.

Definition at line 225 of file Colour.hpp.


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