GraphLibrary  0.0.1
A simple library that implements various graph algorithms.
 All Classes Namespaces Files Functions Variables Typedefs Macros
gl::Color Class Reference

Stores an RGBA Color. More...

#include <Color.hpp>

Public Types

using color_val_t = unsigned char
 

Public Member Functions

 Color (const Color &)=default
 Copy constructor. More...
 
 Color (Color &&) noexcept=default
 Move constructor. More...
 
Coloroperator= (const Color &)=default
 Copy assignment. More...
 
Coloroperator= (Color &&) noexcept=default
 Move assignment. More...
 
 ~Color ()=default
 Destructor. More...
 
bool operator== (const Color &rhs) const
 Check whether two colors are equal. More...
 
bool operator!= (const Color &rhs) const
 Check whether two colors are not equal. More...
 
Constructors

Constructs a new Color object.

 Color ()
 Default constructor. More...
 
 Color (const int r, const int g, const int b, const int a=100)
 Constructor for integer R,G,B,A values. More...
 
 Color (const double r, const double g, const double b, const double a=1.0)
 Constructor for separate double R,G,B,A values. More...
 
 Color (const unsigned int hex, const unsigned int a=0x64)
 Constructor for combined hexadecimal R,G,B,A values. More...
 
 Color (const char *name, color_val_t a=100)
 Constructor for combined hexadecimal R,G,B,A values. More...
 
Read access to stored RGBA color values.

Getters for stored color values.

std::string RGBA () const
 Gets the hexadecimal value of the RGBA color as a string. More...
 
std::string RGB () const
 Gets the hexadecimal value of the RGB color as a string. More...
 
int hex () const
 Gets the hexadecimal value of the RGBA color. More...
 
color_val_t r () const
 Gets the red value of the RGBA color. More...
 
color_val_t g () const
 Gets the green value of the RGBA color. More...
 
color_val_t b () const
 Gets the blue value of the RGBA color. More...
 
color_val_t a () const
 Gets the alpha/opacity value of the RGBA color. More...
 
Write access to stored RGBA color values.

Setters for stored color values Takes the new value for the red/blue/green/alpha respectively.

void hex (const int hex)
 Sets all values of the RGBA color. More...
 
void hex (const int hex, const unsigned int a)
 Sets all values of the RGBA color. More...
 
void r (color_val_t r)
 Sets the red value of the RGBA color. More...
 
void g (color_val_t g)
 Sets the green value of the RGBA color. More...
 
void b (color_val_t b)
 Sets the blue value of the RGBA color. More...
 
void a (color_val_t a)
 Sets the alpha/opacity value of the RGBA color. More...
 

Private Attributes

color_val_t r_
 Red value. $r \in \{0,\ldots,255\}$. More...
 
color_val_t g_
 Green value. $g \in \{0,\ldots,255\}$. More...
 
color_val_t b_
 Blue value. $b \in \{0,\ldots,255\}$. More...
 
color_val_t a_
 Alpha/opacity value. $a \in \{0,\ldots,100\}$. More...
 

Detailed Description

Stores an RGBA Color.

Member Typedef Documentation

using gl::Color::color_val_t = unsigned char

color value type, has a range of exactly $ \{0,\ldots,255\}$

Constructor & Destructor Documentation

gl::Color::Color ( )
inline

Default constructor.

gl::Color::Color ( const int  r,
const int  g,
const int  b,
const int  a = 100 
)
inline

Constructor for integer R,G,B,A values.

Parameters
[in]rR value. $r \in \{0,\ldots,255\}$
[in]gG value. $g \in \{0,\ldots,255\}$
[in]bB value. $b \in \{0,\ldots,255\}$
[in]aAlpha value. $a \in \{0,\ldots,100\}$
gl::Color::Color ( const double  r,
const double  g,
const double  b,
const double  a = 1.0 
)
inline

Constructor for separate double R,G,B,A values.

Parameters
[in]rR value. $r \in [0,1]$
[in]gG value. $g \in [0,1]$
[in]bB value. $b \in [0,1]$
[in]aAlpha value. $a \in [0,1]$
gl::Color::Color ( const unsigned int  hex,
const unsigned int  a = 0x64 
)
inlineexplicit

Constructor for combined hexadecimal R,G,B,A values.

Parameters
[in]hexHexadecimal color code. Format: $ 0xRRGGBB $ where $ RR, GG, BB $ signify the red, blue and green bytes.
[in]aHexadecimal color code for A value. Format: $ 0xAA $ where $ AA $ is optional and signifies the alpha (opacity) byte.
gl::Color::Color ( const char *  name,
color_val_t  a = 100 
)
inline

Constructor for combined hexadecimal R,G,B,A values.

Parameters
[in]nameName of color. Available are the following: $ \{"black","gray","silver","white","orange","maroon",\\"red","olive","yellow","green","lime","teal",\\"aqua", "navy","blue","purple","fuchsia"\}$
[in]a(optional) Opacity of the color. $ a\in\{0,\ldots,100\} $
gl::Color::Color ( const Color )
default

Copy constructor.

gl::Color::Color ( Color &&  )
defaultnoexcept

Move constructor.

gl::Color::~Color ( )
default

Destructor.

Member Function Documentation

Color& gl::Color::operator= ( const Color )
default

Copy assignment.

Color& gl::Color::operator= ( Color &&  )
defaultnoexcept

Move assignment.

bool gl::Color::operator== ( const Color rhs) const
inline

Check whether two colors are equal.

Returns
true if equal, false otherwise.
bool gl::Color::operator!= ( const Color rhs) const
inline

Check whether two colors are not equal.

Returns
true if not equal, false otherwise.
std::string gl::Color::RGBA ( ) const
inline

Gets the hexadecimal value of the RGBA color as a string.

std::string gl::Color::RGB ( ) const
inline

Gets the hexadecimal value of the RGB color as a string.

int gl::Color::hex ( ) const
inline

Gets the hexadecimal value of the RGBA color.

color_val_t gl::Color::r ( ) const
inline

Gets the red value of the RGBA color.

color_val_t gl::Color::g ( ) const
inline

Gets the green value of the RGBA color.

color_val_t gl::Color::b ( ) const
inline

Gets the blue value of the RGBA color.

color_val_t gl::Color::a ( ) const
inline

Gets the alpha/opacity value of the RGBA color.

void gl::Color::hex ( const int  hex)
inline

Sets all values of the RGBA color.

Parameters
[in]hexNew hexadecimal color code (0xRRGGBB).
void gl::Color::hex ( const int  hex,
const unsigned int  a 
)
inline

Sets all values of the RGBA color.

Parameters
[in]hexNew hexadecimal color code (0xRRGGBB).
[in]aOptional new alpha/opacity value (0xAA).
void gl::Color::r ( color_val_t  r)
inline

Sets the red value of the RGBA color.

void gl::Color::g ( color_val_t  g)
inline

Sets the green value of the RGBA color.

void gl::Color::b ( color_val_t  b)
inline

Sets the blue value of the RGBA color.

void gl::Color::a ( color_val_t  a)
inline

Sets the alpha/opacity value of the RGBA color.

Member Data Documentation

color_val_t gl::Color::r_
private

Red value. $r \in \{0,\ldots,255\}$.

color_val_t gl::Color::g_
private

Green value. $g \in \{0,\ldots,255\}$.

color_val_t gl::Color::b_
private

Blue value. $b \in \{0,\ldots,255\}$.

color_val_t gl::Color::a_
private

Alpha/opacity value. $a \in \{0,\ldots,100\}$.


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