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

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

Public Member Functions

 COLOR4D ()
 
constexpr 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 Mix (const COLOR4D &aColor, double aFactor) const
 Function Mix Returns a color that is mixed with the input by a factor. 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...
 

Static Public Member Functions

static EDA_COLOR_T FindNearestLegacyColor (int aR, int aG, int aB)
 Returns a legacy color ID that is closest to the given 8-bit RGB values. 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

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

Definition at line 100 of file numeric_evaluator.cpp.

Constructor & Destructor Documentation

◆ COLOR4D() [1/3]

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

Definition at line 104 of file numeric_evaluator.cpp.

107 {

◆ COLOR4D() [2/3]

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

123 {
124  return m_originalText;

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

226  {

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

270  {

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

226  {
227  char ch = m_token.input[ m_token.pos ];
228 
229  if( ch == '"' )
230  {
231  m_token.pos++;
232  return Unit::Inch;
233  }

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

282  {
283  /* End of input */
284  }

◆ FindNearestLegacyColor()

static EDA_COLOR_T numEval::KIGFX::COLOR4D::FindNearestLegacyColor ( int  aR,
int  aG,
int  aB 
)
static

Returns a legacy color ID that is closest to the given 8-bit RGB values.

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

333  {
334  // VAR

◆ Invert()

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

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

Returns
COLOR4D& Inverted color.

Definition at line 240 of file numeric_evaluator.cpp.

240  {
241  m_token.pos += 2;
242  return Unit::Metric;
243  }
244 
245  if( sizeLeft >= 2 && ch == 'i' && cptr[ 1 ] == 'n' && !isalnum( cptr[ 2 ] ))
246  {
247  m_token.pos += 2;

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

322  {
323  switch( convertFrom )

◆ Mix()

COLOR4D numEval::KIGFX::COLOR4D::Mix ( const COLOR4D aColor,
double  aFactor 
) const
inline

Function Mix Returns a color that is mixed with the input by a factor.

Parameters
aFactorSpecifies how much of the original color to keep (valid values: 0.0 .. 1.0).
Returns
COLOR4D Mixed color.

Definition at line 292 of file numeric_evaluator.cpp.

293  {
294  // UNIT
295  // Units are appended to a VALUE.
296  // Determine factor to default unit if unit for value is given.
297  // Example: Default is mm, unit is inch: factor is 25.4
298  // The factor is assigned to the terminal UNIT. The actual
299  // conversion is done within a parser action.
300  retval.token = UNIT;
#define UNIT

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

308  :break;
309  }
310  }
311  else if( m_defaultUnits == Unit::Inch )
312  {
313  switch( convertFrom )

Member Data Documentation

◆ a

double numEval::KIGFX::COLOR4D::a

Alpha component.

Definition at line 370 of file numeric_evaluator.cpp.

◆ b

double numEval::KIGFX::COLOR4D::b

Blue component.

Definition at line 369 of file numeric_evaluator.cpp.

◆ BLACK

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

Definition at line 377 of file numeric_evaluator.cpp.

◆ g

double numEval::KIGFX::COLOR4D::g

Green component.

Definition at line 368 of file numeric_evaluator.cpp.

◆ r

double numEval::KIGFX::COLOR4D::r

Red component.

Definition at line 367 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 373 of file numeric_evaluator.cpp.

◆ WHITE

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

Definition at line 376 of file numeric_evaluator.cpp.


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