KiCad PCB EDA Suite
numEval::KIGFX::COLOR4D Class Reference

Class COLOR4D is the color representation with 4 components: red, green, blue, alpha. More...

Public Member Functions

 COLOR4D ()
 
 COLOR4D (double aRed, double aGreen, double aBlue, double aAlpha)
 Constructor. More...
 
 COLOR4D (EDA_COLOR_T aColor)
 Constructor. More...
 
COLOR4DBrighten (double aFactor)
 Function Brighten Makes the color brighter by a given factor. More...
 
COLOR4DDarken (double aFactor)
 Function Darken Makes the color darker by a given factor. More...
 
COLOR4DInvert ()
 Function Invert Makes the color inverted, alpha remains the same. More...
 
COLOR4DSaturate (double aFactor)
 Saturates the color to a given factor (in HSV model) More...
 
COLOR4D Brightened (double aFactor) const
 Function Brightened Returns a color that is brighter by a given factor, without modifying object. More...
 
COLOR4D Darkened (double aFactor) const
 Function Darkened Returns a color that is darker by a given factor, without modifying object. More...
 
COLOR4D WithAlpha (double aAlpha) const
 Function WithAlpha Returns a colour with the same colour, but the given alpha. More...
 
COLOR4D Inverted () const
 Function Inverted Returns an inverted color, alpha remains the same. More...
 
double GetBrightness () const
 Function GetBrightness Returns the brightness value of the color ranged from 0.0 to 1.0. More...
 
void ToHSV (double &aOutHue, double &aOutSaturation, double &aOutValue, bool aAlwaysDefineHue=false) const
 Function ToHSV() Converts current color (stored in RGB) to HSV format. More...
 
void FromHSV (double aInH, double aInS, double aInV)
 Function FromHSV() Changes currently used color to the one given by hue, saturation and value parameters. More...
 

Public Attributes

double r
 Red component. More...
 
double g
 Green component. More...
 
double b
 Blue component. More...
 
double a
 Alpha component. More...
 

Static Public Attributes

static const COLOR4D UNSPECIFIED
 For legacy support; used as a value to indicate color hasn't been set yet. More...
 
static const COLOR4D WHITE
 
static const COLOR4D BLACK
 

Detailed Description

Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.

Definition at line 39 of file numeric_evaluator.cpp.

Constructor & Destructor Documentation

numEval::KIGFX::COLOR4D::COLOR4D ( )
inline

Definition at line 43 of file numeric_evaluator.cpp.

numEval::KIGFX::COLOR4D::COLOR4D ( double  aRed,
double  aGreen,
double  aBlue,
double  aAlpha 
)
inline

Constructor.

Parameters
aRedis the red component [0.0 .. 1.0].
aGreenis the green component [0.0 .. 1.0].
aBlueis the blue component [0.0 .. 1.0].
aAlphais the alpha value [0.0 .. 1.0].

Definition at line 56 of file numeric_evaluator.cpp.

60 {
61  struct lconv* lc = localeconv();
62  m_localeDecimalSeparator = *lc->decimal_point;
63 
numEval::KIGFX::COLOR4D::COLOR4D ( EDA_COLOR_T  aColor)

Constructor.

Parameters
aColoris one of KiCad's palette colors.
See also
EDA_COLOR_T

Member Function Documentation

COLOR4D& numEval::KIGFX::COLOR4D::Brighten ( double  aFactor)
inline

Function Brighten Makes the color brighter by a given factor.

Parameters
aFactorSpecifies how bright the color should become (valid values: 0.0 .. 1.0).
Returns
COLOR4D& Brightened color.

Definition at line 148 of file numeric_evaluator.cpp.

151  {
152  // Reset parser by passing zero as token ID, value is ignored.
153  numEval::Parse( m_parser, 0, tok.value, this );
154  break;
155  }
156  } while( tok.token );
157 
void Parse(void *yyp, int yymajor, ParseTOKENTYPE yyminorParseARG_PDECL)
COLOR4D numEval::KIGFX::COLOR4D::Brightened ( double  aFactor) const
inline

Function Brightened Returns a color that is brighter by a given factor, without modifying object.

Parameters
aFactorSpecifies how bright the color should become (valid values: 0.0 .. 1.0).
Returns
COLOR4D Highlighted color.

Definition at line 201 of file numeric_evaluator.cpp.

206  {
207  if( isDecimalSeparator( ch ) && haveSeparator )
208  break;
209 
COLOR4D& numEval::KIGFX::COLOR4D::Darken ( double  aFactor)
inline

Function Darken Makes the color darker by a given factor.

Parameters
aFactorSpecifies how dark the color should become (valid values: 0.0 .. 1.0).
Returns
COLOR4D& Darkened color.

Definition at line 165 of file numeric_evaluator.cpp.

COLOR4D numEval::KIGFX::COLOR4D::Darkened ( double  aFactor) const
inline

Function Darkened Returns a color that is darker by a given factor, without modifying object.

Parameters
aFactorSpecifies how dark the color should become (valid values: 0.0 .. 1.0).
Returns
COLOR4D Darkened color.

Definition at line 217 of file numeric_evaluator.cpp.

228  {
void numEval::KIGFX::COLOR4D::FromHSV ( double  aInH,
double  aInS,
double  aInV 
)

Function FromHSV() Changes currently used color to the one given by hue, saturation and value parameters.

Parameters
aInHis hue component, in degrees.
aInSis saturation component.
aInVis value component.
double numEval::KIGFX::COLOR4D::GetBrightness ( ) const
inline

Function GetBrightness Returns the brightness value of the color ranged from 0.0 to 1.0.

Returns
The brightness value.

Definition at line 255 of file numeric_evaluator.cpp.

260  {
COLOR4D& numEval::KIGFX::COLOR4D::Invert ( )
inline

Function Invert Makes the color inverted, alpha remains the same.

Returns
COLOR4D& Inverted color.

Definition at line 181 of file numeric_evaluator.cpp.

195  {
COLOR4D numEval::KIGFX::COLOR4D::Inverted ( ) const
inline

Function Inverted Returns an inverted color, alpha remains the same.

Returns
COLOR4D& Inverted color.

Definition at line 245 of file numeric_evaluator.cpp.

References numEval::NUMERIC_EVALUATOR::m_token, and numEval::NUMERIC_EVALUATOR::TokenStat::pos.

248  {
COLOR4D& numEval::KIGFX::COLOR4D::Saturate ( double  aFactor)

Saturates the color to a given factor (in HSV model)

void numEval::KIGFX::COLOR4D::ToHSV ( double &  aOutHue,
double &  aOutSaturation,
double &  aOutValue,
bool  aAlwaysDefineHue = false 
) const

Function ToHSV() Converts current color (stored in RGB) to HSV format.

Parameters
aOutHueis the conversion result for hue component, in degrees 0 ... 360.0
aOutSaturationis the conversion result for saturation component (0 ... 1.0).
aOutValueis conversion result for value component (0 ... 1.0).
aAlwaysDefineHuecontrols the way hue is defined when r = v = b
Note
saturation is set to 0.0 for black color (r = v = b = 0), and if r = v = b, hue is set to 0.0 if aAlwaysDefineHue = true, and set to NAN if aAlwaysDefineHue = false. this option is usefull to convert a 4D color to a legacy color, because Red has hue = 0, therefore aAlwaysDefineHue = false makes difference between Red and Gray colors.
COLOR4D numEval::KIGFX::COLOR4D::WithAlpha ( double  aAlpha) const
inline

Function WithAlpha Returns a colour with the same colour, but the given alpha.

Parameters
aAlphaspecifies the alpha of the new color
Returns
COLOR4D color with that alpha

Definition at line 233 of file numeric_evaluator.cpp.

242  {

Member Data Documentation

double numEval::KIGFX::COLOR4D::a

Alpha component.

Definition at line 290 of file numeric_evaluator.cpp.

double numEval::KIGFX::COLOR4D::b

Blue component.

Definition at line 289 of file numeric_evaluator.cpp.

const COLOR4D numEval::KIGFX::COLOR4D::BLACK
static

Definition at line 297 of file numeric_evaluator.cpp.

double numEval::KIGFX::COLOR4D::g

Green component.

Definition at line 288 of file numeric_evaluator.cpp.

double numEval::KIGFX::COLOR4D::r

Red component.

Definition at line 287 of file numeric_evaluator.cpp.

const COLOR4D numEval::KIGFX::COLOR4D::UNSPECIFIED
static

For legacy support; used as a value to indicate color hasn't been set yet.

Definition at line 293 of file numeric_evaluator.cpp.

const COLOR4D numEval::KIGFX::COLOR4D::WHITE
static

Definition at line 296 of file numeric_evaluator.cpp.


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