bpp-core  2.2.0
bpp::ColorTools Class Reference

Provide tools to deal with color objects. More...

#include <Bpp/Graphics/ColorTools.h>

+ Collaboration diagram for bpp::ColorTools:

Public Member Functions

 ColorTools ()
 
virtual ~ColorTools ()
 

Static Public Member Functions

static std::vector< RGBColorgradient (unsigned int n, const RGBColor &low, const RGBColor &high)
 Create a set of colors according to a gradient defined by two extrema. More...
 
static std::vector< RGBColorgradient (unsigned int n, const RGBColor &low, const RGBColor &mid, const RGBColor &high)
 Create a set of colors according to a gradient defined by two extrema and a midpoint. More...
 
static RGBColor gray (double level)
 
static RGBColor cmyk2rgb (double c, double m, double y, double k)
 Get a RGBColor from a cyan-magenta-yellow-key description. More...
 

Static Public Attributes

static const RGBColor RED = RGBColor(255,0,0)
 
static const RGBColor GREEN = RGBColor(0,255,0)
 
static const RGBColor BLUE = RGBColor(0,0,255)
 
static const RGBColor BLACK = RGBColor(0,0,0)
 
static const RGBColor WHITE = RGBColor(255,255,255)
 
static const RGBColor YELLOW = RGBColor(255,255,0)
 
static const RGBColor CYAN = RGBColor(0,255,255)
 
static const RGBColor MAGENTA = RGBColor(255,0,255)
 
static const RGBColor ORANGE = RGBColor(255,127,0)
 

Detailed Description

Provide tools to deal with color objects.

Definition at line 53 of file ColorTools.h.

Constructor & Destructor Documentation

◆ ColorTools()

bpp::ColorTools::ColorTools ( )
inline

Definition at line 56 of file ColorTools.h.

◆ ~ColorTools()

virtual bpp::ColorTools::~ColorTools ( )
inlinevirtual

Definition at line 57 of file ColorTools.h.

Member Function Documentation

◆ cmyk2rgb()

static RGBColor bpp::ColorTools::cmyk2rgb ( double  c,
double  m,
double  y,
double  k 
)
inlinestatic

Get a RGBColor from a cyan-magenta-yellow-key description.

The following formula are used for the transformation:

\[ \begin{array}{rcl} r &=& 255 * (1 - c)(1 - k)\\ g &=& 255 * (1 - m)(1 - k)\\ b &=& 255 * (1 - y)(1 - k) \end{array} \]

Parameters
cCyan proportion.
mMagenta proportion.
yYellow proportion.
kBlack proportion.
Returns
A RGBColor object.

Definition at line 109 of file ColorTools.h.

◆ gradient() [1/2]

std::vector< RGBColor > ColorTools::gradient ( unsigned int  n,
const RGBColor low,
const RGBColor high 
)
static

Create a set of colors according to a gradient defined by two extrema.

Parameters
nNumber of colors to output.
lowFirst color in gradient.
highLast color in gradient.
Returns
A set of ordered colors defining a gradient.

Definition at line 57 of file ColorTools.cpp.

◆ gradient() [2/2]

std::vector< RGBColor > ColorTools::gradient ( unsigned int  n,
const RGBColor low,
const RGBColor mid,
const RGBColor high 
)
static

Create a set of colors according to a gradient defined by two extrema and a midpoint.

Parameters
nNumber of colors to output.
lowFirst color in gradient.
midMidpoint color.
highLast color in gradient.
Returns
A set of ordered colors defining a gradient.

Definition at line 87 of file ColorTools.cpp.

◆ gray()

static RGBColor bpp::ColorTools::gray ( double  level)
inlinestatic
Returns
A gray color.
Parameters
levelGray intensity ([0,1]).

Definition at line 85 of file ColorTools.h.

Member Data Documentation

◆ BLACK

◆ BLUE

◆ CYAN

◆ GREEN

◆ MAGENTA

const RGBColor ColorTools::MAGENTA = RGBColor(255,0,255)
static

◆ ORANGE

const RGBColor ColorTools::ORANGE = RGBColor(255,127,0)
static

Definition at line 126 of file ColorTools.h.

◆ RED

◆ WHITE

const RGBColor ColorTools::WHITE = RGBColor(255,255,255)
static

◆ YELLOW

const RGBColor ColorTools::YELLOW = RGBColor(255,255,0)
static

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