Board  0.9.5
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
LibBoard::Color Class Reference

Structure representing an RGB triple. More...

#include <Color.h>

Public Member Functions

 Color (const unsigned int rgb, unsigned char alpha=255)
 
 Color (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
 
 Color (unsigned char gray, unsigned char alpha=255)
 
 Color (const std::string &htmlColor, unsigned char alpha)
 Build a color from an HTML color string (#RRGGBB) More...
 
 Color (const std::string &htmlColor)
 Build a color from an HTML color string (#RRGGBB or #RRGGBBAA) More...
 
 Color (const char *htmlColor, unsigned char alpha=255)
 
 Color (std::nullptr_t)
 
void red (unsigned char red)
 
void green (unsigned char green)
 
void blue (unsigned char blue)
 
void alpha (unsigned char alpha)
 
unsigned char red () const
 
unsigned char green () const
 
unsigned char blue () const
 
unsigned char alpha () const
 
ColorsetRGBi (const unsigned char red, const unsigned char green, const unsigned char blue, const unsigned char alpha=255)
 setRGBi More...
 
ColorsetHSV (float hue, float saturation, float value, float alpha=1.0)
 setHSV More...
 
ColorsetRGBf (float red, float green, float blue, float alpha=1.0)
 
bool operator== (const Color &other) const
 
bool operator!= (const Color &other) const
 
bool operator< (const Color &other) const
 
void flushPostscript (std::ostream &) const
 
std::string svg () const
 
bool isNull () const
 
bool isValid () const
 
std::string svgAlpha (const char *prefix) const
 
std::string postscript () const
 
std::string tikz () const
 
void toHSV (float &hue, float &saturation, float &value, float &alpha) const
 
bool valid () const
 
std::ostream & flush (std::ostream &out) const
 

Static Public Member Functions

static Color fromRGBf (float red, float green, float blue, float alpha=1.0f)
 
static Color fromHSV (float hue, float saturation, float value, float alpha=1.0f)
 
static Color midRGB (const Color &a, const Color &b, float t)
 
static Color midHSV (const Color &a, const Color &b, float t)
 
static Color fromHueColormap (float t)
 

Static Public Attributes

static const Color Null
 
static const Color Black
 
static const Color Brown
 
static const Color Pink
 
static const Color Gray
 
static const Color White
 
static const Color Red
 
static const Color Green
 
static const Color DarkGreen
 
static const Color Lime
 
static const Color Blue
 
static const Color Cyan
 
static const Color DarkCyan
 
static const Color Magenta
 
static const Color Yellow
 
static const Color Silver
 
static const Color Purple
 
static const Color Navy
 
static const Color Aqua
 

Detailed Description

Structure representing an RGB triple.

Color structure.

Examples
examples/arithmetic.cpp, examples/arrows.cpp, examples/clipping.cpp, examples/ellipse.cpp, examples/example1.cpp, examples/example3.cpp, examples/example4.cpp, examples/graph.cpp, examples/holes.cpp, examples/hull.cpp, and examples/traversal.cpp.

Constructor & Destructor Documentation

◆ Color() [1/3]

LibBoard::Color::Color ( const std::string &  htmlColor,
unsigned char  alpha 
)
inline

Build a color from an HTML color string (#RRGGBB)

Parameters
htmlColorAn HTML color string
alphaThe alpha value

◆ Color() [2/3]

LibBoard::Color::Color ( const std::string &  htmlColor)
inline

Build a color from an HTML color string (#RRGGBB or #RRGGBBAA)

Parameters
htmlColorAn HTML color string

◆ Color() [3/3]

LibBoard::Color::Color ( std::nullptr_t  )
inline

Create a null color

Member Function Documentation

◆ setHSV()

Color & LibBoard::Color::setHSV ( float  hue,
float  saturation,
float  value,
float  alpha = 1.0 
)

setHSV

Parameters
hue
saturation
value
alpha
Returns

Referenced by LibBoard::Board::setFillColorHSV().

◆ setRGBi()

Color & LibBoard::Color::setRGBi ( const unsigned char  red,
const unsigned char  green,
const unsigned char  blue,
const unsigned char  alpha = 255 
)
inline

setRGBi

Parameters
red
green
blue
alpha
Returns

Referenced by LibBoard::Board::setFillColorRGBi(), and LibBoard::Board::setPenColorRGBi().

◆ svgAlpha()

string LibBoard::Color::svgAlpha ( const char *  prefix) const

Return a an SVG parameter string for the opacity value.

Parameters
prefixA prefix string to be appended to the returned string if not empty.
Returns
An empty string if alpha == 255, otherwise the string <prefix>-opacity="\<alpha-value\>".

◆ tikz()

string LibBoard::Color::tikz ( ) const

Return a string representation of the color usable in TikZ commands. Use the corresponding named color (or a mixture of a named color and black) for predefined colors. Use a mixture of red, green and blue for general colors.

Returns
a string representation of the color usable in TikZ commands.

Referenced by LibBoard::Style::tikzProperties().


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