Board 0.9.6
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 ()
 
 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)
 
 Color (const std::string &htmlColor)
 Build a color from an HTML color string (#RRGGBB or #RRGGBBAA)
 
 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
 
ColorsetHSV (float hue, float saturation, float value, float alpha=1.0)
 setHSV
 
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 gray (unsigned char grayLevel, unsigned char alpha=255)
 
static Color fromHSV (float hue, float saturation, float value, float alpha=1.0f)
 
static Color mixRGB (const Color &a, const Color &b, float t)
 
static Color mixHSV (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/Julia.cpp, examples/arithmetic.cpp, examples/array.cpp, examples/arrows.cpp, examples/circled_framed.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, examples/interpolate.cpp, examples/rough.cpp, examples/traversal.cpp, and examples/xkcd.cpp.

Constructor & Destructor Documentation

◆ Color() [1/8]

LibBoard::Color::Color ( )
inline

Referenced by fromRGBf(), and gray().

◆ Color() [2/8]

LibBoard::Color::Color ( const unsigned int  rgb,
unsigned char  alpha = 255 
)
inline

◆ Color() [3/8]

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

◆ Color() [4/8]

LibBoard::Color::Color ( unsigned char  gray,
unsigned char  alpha = 255 
)
inline

◆ Color() [5/8]

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() [6/8]

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() [7/8]

LibBoard::Color::Color ( const char *  htmlColor,
unsigned char  alpha = 255 
)
inline

References alpha(), LibBoard::Tools::error, and Null.

◆ Color() [8/8]

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

Create a null color

Member Function Documentation

◆ alpha() [1/2]

unsigned char LibBoard::Color::alpha ( ) const
inline

◆ alpha() [2/2]

void LibBoard::Color::alpha ( unsigned char  alpha)
inline

References alpha().

Referenced by mixRGB().

◆ blue() [1/2]

unsigned char LibBoard::Color::blue ( ) const
inline

Referenced by blue(), fromRGBf(), mixRGB(), setRGBf(), and setRGBi().

◆ blue() [2/2]

void LibBoard::Color::blue ( unsigned char  blue)
inline

◆ flush()

std::ostream & LibBoard::Color::flush ( std::ostream &  out) const

References isNull(), and toHSV().

Referenced by LibBoard::operator<<().

◆ flushPostscript()

void LibBoard::Color::flushPostscript ( std::ostream &  stream) const

◆ fromHSV()

Color LibBoard::Color::fromHSV ( float  hue,
float  saturation,
float  value,
float  alpha = 1.0f 
)
static

References alpha(), and setHSV().

Referenced by fromHueColormap(), and mixHSV().

◆ fromHueColormap()

Color LibBoard::Color::fromHueColormap ( float  t)
static

References fromHSV().

Referenced by main(), and mustache().

◆ fromRGBf()

Color LibBoard::Color::fromRGBf ( float  red,
float  green,
float  blue,
float  alpha = 1.0f 
)
inlinestatic

References alpha(), blue(), Color(), green(), and red().

Referenced by julia(), and mixRGB().

◆ gray()

Color LibBoard::Color::gray ( unsigned char  grayLevel,
unsigned char  alpha = 255 
)
inlinestatic

References alpha(), and Color().

Referenced by main().

◆ green() [1/2]

unsigned char LibBoard::Color::green ( ) const
inline

Referenced by fromRGBf(), green(), mixRGB(), setRGBf(), and setRGBi().

◆ green() [2/2]

void LibBoard::Color::green ( unsigned char  green)
inline

◆ isNull()

bool LibBoard::Color::isNull ( ) const
inline

◆ isValid()

bool LibBoard::Color::isValid ( ) const
inline

References isNull().

◆ mixHSV()

Color LibBoard::Color::mixHSV ( const Color a,
const Color b,
float  t 
)
static

References fromHSV(), and toHSV().

Referenced by mustache().

◆ mixRGB()

Color LibBoard::Color::mixRGB ( const Color a,
const Color b,
float  t 
)
static

References alpha(), alpha(), blue(), blue(), fromRGBf(), green(), green(), red(), and red().

Referenced by LibBoard::mix().

◆ operator!=()

bool LibBoard::Color::operator!= ( const Color other) const

◆ operator<()

bool LibBoard::Color::operator< ( const Color other) const

◆ operator==()

bool LibBoard::Color::operator== ( const Color other) const

◆ postscript()

string LibBoard::Color::postscript ( ) const

◆ red() [1/2]

unsigned char LibBoard::Color::red ( ) const
inline

Referenced by fromRGBf(), mixRGB(), red(), setRGBf(), and setRGBi().

◆ red() [2/2]

void LibBoard::Color::red ( unsigned char  red)
inline

◆ setHSV()

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

setHSV

Parameters
hue
saturation
value
alpha
Returns

References alpha().

Referenced by fromHSV(), and LibBoard::Board::setFillColorHSV().

◆ setRGBf()

Color & LibBoard::Color::setRGBf ( float  red,
float  green,
float  blue,
float  alpha = 1.0 
)

◆ 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

References alpha(), blue(), green(), and red().

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

◆ svg()

string LibBoard::Color::svg ( ) const

◆ 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\>".

References Null, and secured_sprintf.

Referenced by LibBoard::Text::flushSVG(), and LibBoard::Style::svgProperties().

◆ 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.

References Black, Blue, Gray, Green, Lime, Navy, Null, Purple, Red, secured_sprintf, Silver, and White.

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

◆ toHSV()

void LibBoard::Color::toHSV ( float &  hue,
float &  saturation,
float &  value,
float &  alpha 
) const

References alpha().

Referenced by flush(), and mixHSV().

◆ valid()

bool LibBoard::Color::valid ( ) const
inline

Member Data Documentation

◆ Aqua

const Color LibBoard::Color::Aqua
static

◆ Black

const Color LibBoard::Color::Black
static

◆ Blue

const Color LibBoard::Color::Blue
static

Referenced by LeaveBox(), main(), strikeOut(), and tikz().

◆ Brown

const Color LibBoard::Color::Brown
static

Referenced by ell(), and rough().

◆ Cyan

const Color LibBoard::Color::Cyan
static

Referenced by main(), and polygons().

◆ DarkCyan

const Color LibBoard::Color::DarkCyan
static

◆ DarkGreen

const Color LibBoard::Color::DarkGreen
static

Referenced by rough().

◆ Gray

const Color LibBoard::Color::Gray
static

Referenced by interpolate(), main(), rough(), and tikz().

◆ Green

const Color LibBoard::Color::Green
static

◆ Lime

const Color LibBoard::Color::Lime
static

Referenced by rough(), and tikz().

◆ Magenta

const Color LibBoard::Color::Magenta
static

Referenced by main().

◆ Navy

const Color LibBoard::Color::Navy
static

Referenced by tikz().

◆ Null

const Color LibBoard::Color::Null
static

◆ Pink

const Color LibBoard::Color::Pink
static

Referenced by main().

◆ Purple

const Color LibBoard::Color::Purple
static

Referenced by main(), and tikz().

◆ Red

const Color LibBoard::Color::Red
static

◆ Silver

const Color LibBoard::Color::Silver
static

Referenced by main(), and tikz().

◆ White

const Color LibBoard::Color::White
static

◆ Yellow

const Color LibBoard::Color::Yellow
static

Referenced by diamond().


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