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 ()
 
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...
 

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]

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

148  {
149  // Reset parser by passing zero as token ID, value is ignored.
150  numEval::Parse( m_parser, 0, tok.value, this );
151  break;
152  }
153  } while( tok.token );
154 
155  return !m_parseError;
void Parse(void *yyp, int yymajor, ParseTOKENTYPE yyminor ParseARG_PDECL)

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

203  {
204  if( isDecimalSeparator( ch ) && haveSeparator )
205  break;
206 
207  m_token.token[ idx++ ] = ch;

References NUMERIC_EVALUATOR::m_token, and NUMERIC_EVALUATOR::TokenStat::token.

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

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

225  {

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

269  {
270  ch = m_token.input[ m_token.pos ];
271 
272  if( ch == ' ' )
273  m_token.pos++;

◆ Invert()

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

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

Returns
COLOR4D& Inverted color.

Definition at line 179 of file numeric_evaluator.cpp.

192  {

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

269  {

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

239  {

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

251  {
252  m_token.pos += 3;

Member Data Documentation

◆ a

double numEval::KIGFX::COLOR4D::a

Alpha component.

Definition at line 304 of file numeric_evaluator.cpp.

◆ b

double numEval::KIGFX::COLOR4D::b

Blue component.

Definition at line 303 of file numeric_evaluator.cpp.

◆ BLACK

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

Definition at line 311 of file numeric_evaluator.cpp.

◆ g

double numEval::KIGFX::COLOR4D::g

Green component.

Definition at line 302 of file numeric_evaluator.cpp.

◆ r

double numEval::KIGFX::COLOR4D::r

Red component.

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

◆ WHITE

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

Definition at line 310 of file numeric_evaluator.cpp.


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