|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
47 : r_( r ), g_( g ), b_( b ), a_( a )
50 ! std::isfinite(
r) || ! std::isfinite(
g) || ! std::isfinite(
b) || ! std::isfinite(
a) ||
51 r < 0.0 || r > 1.0 || g < 0.0 || g > 1.0 || b < 0.0 || b > 1.0 || a < 0.0 || a > 1.0
53 throw std::invalid_argument(
54 "Color can only be constructed with values in range [ 0.0, 1.0 ]."
79 if( ! std::isfinite(value) || value < 0.0 || value > 1.0 ) {
80 throw std::invalid_argument(
81 "Color can only be used with values in range [ 0.0, 1.0 ]."
89 if( ! std::isfinite(value) || value < 0.0 || value > 1.0 ) {
90 throw std::invalid_argument(
91 "Color can only be used with values in range [ 0.0, 1.0 ]."
99 if( ! std::isfinite(value) || value < 0.0 || value > 1.0 ) {
100 throw std::invalid_argument(
101 "Color can only be used with values in range [ 0.0, 1.0 ]."
109 if( ! std::isfinite(value) || value < 0.0 || value > 1.0 ) {
110 throw std::invalid_argument(
111 "Color can only be used with values in range [ 0.0, 1.0 ]."
121 unsigned char Color::to_byte_(
double v )
123 assert( std::isfinite(v) && 0.0 <= v && v <= 1.0 );
124 return static_cast<unsigned char>( std::round( 255.0 * v ));
127 double Color::from_byte_(
unsigned char v )
129 return static_cast<double>( v ) / 255.0;
Color 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]".
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]".
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Color operators and functions.
Color()
Default constructor. Sets the color to black.
Color color_from_bytes(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Create a Color given three or four values in the range [ 0, 255 ] for each of the components red,...
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,...