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...
 
void ToHSL (double &aOutHue, double &aOutSaturation, double &aOutValue) const
 Function ToHSL() Converts current color (stored in RGB) to HSL format. More...
 
void FromHSL (double aInHue, double aInSaturation, double aInLightness)
 Function FromHSL() Changes currently used color to the one given by hue, saturation and lightness parameters. 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

◆ COLOR4D() [1/3]

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

Definition at line 43 of file numeric_evaluator.cpp.

47 {

◆ COLOR4D() [2/3]

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.

57  {
58  case INCHES:
59  if( aUseMils )
60  m_defaultUnits = Unit::Mil;
61  else
62  m_defaultUnits = Unit::Inch;
63  break;

◆ COLOR4D() [3/3]

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

◆ Brighten()

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 170 of file numeric_evaluator.cpp.

182  {

◆ Brightened()

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 223 of file numeric_evaluator.cpp.

229  {
230  m_token.pos += 2;
231  return Unit::Metric;

◆ Darken()

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 187 of file numeric_evaluator.cpp.

187  {
188  bool haveSeparator = false;
189  idx = 0;
190  auto ch = m_token.input[ m_token.pos ];
191 
192  do
193  {
194  if( isDecimalSeparator( ch ) && haveSeparator )
195  break;
196 

◆ Darkened()

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 239 of file numeric_evaluator.cpp.

241  {
242  m_token.pos += 3;
243  return Unit::Mil;
244  }
245 
246  if( sizeLeft >= 4 && ch == 't' && cptr[ 1 ] == 'h' && cptr[ 2 ] == 'o' && cptr[ 3 ] == 'u' && !isalnum( cptr[ 4 ] ))
247  {

◆ FromHSL()

void numEval::KIGFX::COLOR4D::FromHSL ( double  aInHue,
double  aInSaturation,
double  aInLightness 
)

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

Parameters
aInHueis hue component, in degrees (0.0 - 360.0)
aInSaturationis saturation component (0.0 - 1.0)
aInLightnessis lightness component (0.0 - 1.0)

◆ FromHSV()

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.

◆ GetBrightness()

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 277 of file numeric_evaluator.cpp.

282  {

◆ Invert()

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

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

Returns
COLOR4D& Inverted color.

Definition at line 203 of file numeric_evaluator.cpp.

215  {

◆ Inverted()

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

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

Returns
COLOR4D& Inverted color.

Definition at line 267 of file numeric_evaluator.cpp.

271  {

◆ Saturate()

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

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

◆ ToHSL()

void numEval::KIGFX::COLOR4D::ToHSL ( double &  aOutHue,
double &  aOutSaturation,
double &  aOutValue 
) const

Function ToHSL() Converts current color (stored in RGB) to HSL format.

Parameters
aOutHueis the conversion result for hue component, in degrees 0 ... 360.0
aOutSaturationis the conversion result for saturation component (0 ... 1.0).
aOutLightnessis conversion result for value component (0 ... 1.0).
Note
saturation is set to 0.0 for black color if r = g = b,

◆ ToHSV()

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.

◆ WithAlpha()

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 255 of file numeric_evaluator.cpp.

259  {
260  ch = m_token.input[ m_token.pos ];

Member Data Documentation

◆ a

double numEval::KIGFX::COLOR4D::a

Alpha component.

Definition at line 312 of file numeric_evaluator.cpp.

◆ b

double numEval::KIGFX::COLOR4D::b

Blue component.

Definition at line 311 of file numeric_evaluator.cpp.

◆ BLACK

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

Definition at line 319 of file numeric_evaluator.cpp.

◆ g

double numEval::KIGFX::COLOR4D::g

Green component.

Definition at line 310 of file numeric_evaluator.cpp.

◆ r

double numEval::KIGFX::COLOR4D::r

Red component.

Definition at line 309 of file numeric_evaluator.cpp.

◆ UNSPECIFIED

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 315 of file numeric_evaluator.cpp.

◆ WHITE

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

Definition at line 318 of file numeric_evaluator.cpp.


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