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::graphics::Colour Class Referencefinal

Represents an RGBA colour. More...

#include <Colour.hpp>

+ Collaboration diagram for galaxy::graphics::Colour:

Public Member Functions

 Colour ()
 Constructor.
 
 Colour (Colour &&)
 Move constructor.
 
 Colour (const Colour &)
 Copy constructor.
 
Colouroperator= (Colour &&)
 Move assignment operator.
 
Colouroperator= (const Colour &)
 Copy assignment operator.
 
 ~Colour ()
 Destructor.
 
void set_r (const std::uint8_t r)
 Red.
 
void set_g (const std::uint8_t g)
 Green.
 
void set_b (const std::uint8_t b)
 Blue.
 
void set_a (const std::uint8_t a)
 Alpha.
 
template<typename R >
requires std::is_same_v<std::uint8_t, R> || std::is_same_v<float, R>
r () const
 Get red.
 
template<typename G >
requires std::is_same_v<std::uint8_t, G> || std::is_same_v<float, G>
g () const
 Get green.
 
template<typename B >
requires std::is_same_v<std::uint8_t, B> || std::is_same_v<float, B>
b () const
 Get blue.
 
template<typename A >
requires std::is_same_v<std::uint8_t, A> || std::is_same_v<float, A>
a () const
 Get alpha.
 
void set_rgba (const glm::vec4 &rgba)
 Set RGBA.
 
std::array< std::uint8_t, 4 > & array ()
 Get integer array.
 
glm::vec4 & vec4 ()
 Get vec4.
 
const std::array< std::uint8_t, 4 > & array () const
 Get const integer array.
 
const glm::vec4 & vec4 () const
 Get const vec4.
 
auto operator<=> (const Colour &) const =default
 Comparison operator.
 
template<>
float r () const
 
template<>
std::uint8_t r () const
 
template<>
float g () const
 
template<>
std::uint8_t g () const
 
template<>
float b () const
 
template<>
std::uint8_t b () const
 
template<>
float a () const
 
template<>
std::uint8_t a () const
 

Static Public Attributes

static const constexpr std::uint8_t OPAQUE = 255
 Opaque colour.
 
static const constexpr std::uint8_t TRANSPARENT = 0
 Transparent colour.
 

Private Attributes

std::array< std::uint8_t, 4 > m_array
 r,g,b,a = 0,1,2,3.
 
glm::vec4 m_vec4
 r,g,b,a = x,y,z,w.
 

Detailed Description

Represents an RGBA colour.

Definition at line 26 of file Colour.hpp.

Constructor & Destructor Documentation

◆ Colour() [1/3]

galaxy::graphics::Colour::Colour ( )

Constructor.

Definition at line 24 of file Colour.cpp.

◆ Colour() [2/3]

galaxy::graphics::Colour::Colour ( Colour && c)

Move constructor.

Definition at line 30 of file Colour.cpp.

◆ Colour() [3/3]

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

Copy constructor.

Definition at line 36 of file Colour.cpp.

◆ ~Colour()

galaxy::graphics::Colour::~Colour ( )

Destructor.

Definition at line 64 of file Colour.cpp.

Member Function Documentation

◆ operator=() [1/2]

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

Move assignment operator.

Definition at line 42 of file Colour.cpp.

◆ operator=() [2/2]

Colour & galaxy::graphics::Colour::operator= ( const Colour & c)

Copy assignment operator.

Definition at line 53 of file Colour.cpp.

◆ set_r()

void galaxy::graphics::Colour::set_r ( const std::uint8_t r)

Red.

Parameters
r0 - 255.

Definition at line 68 of file Colour.cpp.

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

◆ set_g()

void galaxy::graphics::Colour::set_g ( const std::uint8_t g)

Green.

Parameters
g0 - 255.

Definition at line 86 of file Colour.cpp.

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

◆ set_b()

void galaxy::graphics::Colour::set_b ( const std::uint8_t b)

Blue.

Parameters
b0 - 255.

Definition at line 104 of file Colour.cpp.

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

◆ set_a()

void galaxy::graphics::Colour::set_a ( const std::uint8_t a)

Alpha.

Parameters
a0 - 255.

Definition at line 122 of file Colour.cpp.

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

◆ r() [1/3]

template<typename R >
requires std::is_same_v<std::uint8_t, R> || std::is_same_v<float, R>
R galaxy::graphics::Colour::r ( ) const

Get red.

Template Parameters
RDetermines return value.
Returns
Int for 0 - 255, Float for 0 - 1.
+ Here is the caller graph for this function:

◆ g() [1/3]

template<typename G >
requires std::is_same_v<std::uint8_t, G> || std::is_same_v<float, G>
G galaxy::graphics::Colour::g ( ) const

Get green.

Template Parameters
GDetermines return value.
Returns
Int for 0 - 255, Float for 0 - 1.
+ Here is the caller graph for this function:

◆ b() [1/3]

template<typename B >
requires std::is_same_v<std::uint8_t, B> || std::is_same_v<float, B>
B galaxy::graphics::Colour::b ( ) const

Get blue.

Template Parameters
BDetermines return value.
Returns
Int for 0 - 255, Float for 0 - 1.
+ Here is the caller graph for this function:

◆ a() [1/3]

template<typename A >
requires std::is_same_v<std::uint8_t, A> || std::is_same_v<float, A>
A galaxy::graphics::Colour::a ( ) const

Get alpha.

Template Parameters
ADetermines return value.
Returns
Int for 0 - 255, Float for 0 - 1.
+ Here is the caller graph for this function:

◆ set_rgba()

void galaxy::graphics::Colour::set_rgba ( const glm::vec4 & rgba)

Set RGBA.

Parameters
rgbaClamps from 0 to 1.

Definition at line 140 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ array() [1/2]

std::array< std::uint8_t, 4 > & galaxy::graphics::Colour::array ( )
nodiscard

Get integer array.

Returns
Integers 0 - 255.

Definition at line 155 of file Colour.cpp.

◆ vec4() [1/2]

glm::vec4 & galaxy::graphics::Colour::vec4 ( )
nodiscard

Get vec4.

Returns
Floats 0 - 1.

Definition at line 160 of file Colour.cpp.

+ Here is the caller graph for this function:

◆ array() [2/2]

const std::array< std::uint8_t, 4 > & galaxy::graphics::Colour::array ( ) const
nodiscard

Get const integer array.

Returns
Integers 0 - 255.

Definition at line 165 of file Colour.cpp.

◆ vec4() [2/2]

const glm::vec4 & galaxy::graphics::Colour::vec4 ( ) const
nodiscard

Get const vec4.

Returns
Floats 0 - 1.

Definition at line 170 of file Colour.cpp.

◆ operator<=>()

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

Comparison operator.

◆ r() [2/3]

template<>
float galaxy::graphics::Colour::r ( ) const
inline

Definition at line 200 of file Colour.hpp.

◆ r() [3/3]

template<>
std::uint8_t galaxy::graphics::Colour::r ( ) const
inline

Definition at line 206 of file Colour.hpp.

◆ g() [2/3]

template<>
float galaxy::graphics::Colour::g ( ) const
inline

Definition at line 212 of file Colour.hpp.

◆ g() [3/3]

template<>
std::uint8_t galaxy::graphics::Colour::g ( ) const
inline

Definition at line 218 of file Colour.hpp.

◆ b() [2/3]

template<>
float galaxy::graphics::Colour::b ( ) const
inline

Definition at line 224 of file Colour.hpp.

◆ b() [3/3]

template<>
std::uint8_t galaxy::graphics::Colour::b ( ) const
inline

Definition at line 230 of file Colour.hpp.

◆ a() [2/3]

template<>
float galaxy::graphics::Colour::a ( ) const
inline

Definition at line 236 of file Colour.hpp.

◆ a() [3/3]

template<>
std::uint8_t galaxy::graphics::Colour::a ( ) const
inline

Definition at line 242 of file Colour.hpp.

Member Data Documentation

◆ OPAQUE

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

Opaque colour.

Definition at line 32 of file Colour.hpp.

◆ TRANSPARENT

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

Transparent colour.

Definition at line 37 of file Colour.hpp.

◆ m_array

std::array<std::uint8_t, 4> galaxy::graphics::Colour::m_array
private

r,g,b,a = 0,1,2,3.

Definition at line 191 of file Colour.hpp.

◆ m_vec4

glm::vec4 galaxy::graphics::Colour::m_vec4
private

r,g,b,a = x,y,z,w.

Definition at line 196 of file Colour.hpp.


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