A library for working with phylogenetic and population genetic data.
v0.32.0
Color Class Reference

#include <genesis/utils/color/color.hpp>

Detailed Description

Definition at line 47 of file color.hpp.

Public Member Functions

 Color ()
 Default constructor. Sets the color to black. More...
 
 Color (Color &&)=default
 
 Color (Color const &)=default
 
 Color (double r, double g, double b)
 Constructor for setting the RGB value. More...
 
 Color (double r, double g, double b, double a)
 Constructor for setting the RGB value including alpha. More...
 
 ~Color ()=default
 
double a () const
 
void a (double value)
 
unsigned char a_byte () const
 
void a_byte (unsigned char value)
 
double b () const
 
void b (double value)
 
unsigned char b_byte () const
 
void b_byte (unsigned char value)
 
double g () const
 
void g (double value)
 
unsigned char g_byte () const
 
void g_byte (unsigned char value)
 
Coloroperator= (Color &&)=default
 
Coloroperator= (Color const &)=default
 
double r () const
 
void r (double value)
 
unsigned char r_byte () const
 
void r_byte (unsigned char value)
 
void swap (Color &other)
 

Static Public Member Functions

static Color from_bytes (unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
 Create a Color given three or four values in the range [ 0, 255 ] for each of the components red, green and blue, and optionally alpha. More...
 
static Color from_hex (std::string const &hex_color, std::string const &prefix="#")
 Create a Color given a hex color string in the format "#003366[ff]". More...
 

Constructor & Destructor Documentation

◆ Color() [1/5]

Color ( )
inline

Default constructor. Sets the color to black.

Definition at line 58 of file color.hpp.

◆ Color() [2/5]

Color ( double  r,
double  g,
double  b 
)
inline

Constructor for setting the RGB value.

Definition at line 65 of file color.hpp.

◆ Color() [3/5]

Color ( double  r,
double  g,
double  b,
double  a 
)

Constructor for setting the RGB value including alpha.

Definition at line 46 of file color.cpp.

◆ ~Color()

~Color ( )
default

◆ Color() [4/5]

Color ( Color const &  )
default

◆ Color() [5/5]

Color ( Color &&  )
default

Member Function Documentation

◆ a() [1/2]

double a ( ) const
inline

Definition at line 124 of file color.hpp.

◆ a() [2/2]

void a ( double  value)

Definition at line 107 of file color.cpp.

◆ a_byte() [1/2]

unsigned char a_byte ( ) const
inline

Definition at line 144 of file color.hpp.

◆ a_byte() [2/2]

void a_byte ( unsigned char  value)
inline

Definition at line 176 of file color.hpp.

◆ b() [1/2]

double b ( ) const
inline

Definition at line 119 of file color.hpp.

◆ b() [2/2]

void b ( double  value)

Definition at line 97 of file color.cpp.

◆ b_byte() [1/2]

unsigned char b_byte ( ) const
inline

Definition at line 139 of file color.hpp.

◆ b_byte() [2/2]

void b_byte ( unsigned char  value)
inline

Definition at line 171 of file color.hpp.

◆ from_bytes()

Color from_bytes ( unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255 
)
static

Create a Color given three or four values in the range [ 0, 255 ] for each of the components red, green and blue, and optionally alpha.

Definition at line 63 of file color.cpp.

◆ from_hex()

Color from_hex ( std::string const &  hex_color,
std::string const &  prefix = "#" 
)
static

Create a Color given a hex color string in the format "#003366[ff]".

The hash sign in the beginning can be replaced by any given prefix. If the string is not correctly formatted, an std::invalid_argument exception is thrown. If the string contains only RGB, alpha is set to 1.0.

Definition at line 68 of file color.cpp.

◆ g() [1/2]

double g ( ) const
inline

Definition at line 114 of file color.hpp.

◆ g() [2/2]

void g ( double  value)

Definition at line 87 of file color.cpp.

◆ g_byte() [1/2]

unsigned char g_byte ( ) const
inline

Definition at line 134 of file color.hpp.

◆ g_byte() [2/2]

void g_byte ( unsigned char  value)
inline

Definition at line 166 of file color.hpp.

◆ operator=() [1/2]

Color& operator= ( Color &&  )
default

◆ operator=() [2/2]

Color& operator= ( Color const &  )
default

◆ r() [1/2]

double r ( ) const
inline

Definition at line 109 of file color.hpp.

◆ r() [2/2]

void r ( double  value)

Definition at line 77 of file color.cpp.

◆ r_byte() [1/2]

unsigned char r_byte ( ) const
inline

Definition at line 129 of file color.hpp.

◆ r_byte() [2/2]

void r_byte ( unsigned char  value)
inline

Definition at line 161 of file color.hpp.

◆ swap()

void swap ( Color other)
inline

Definition at line 82 of file color.hpp.


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