KiCad PCB EDA Suite
KIGFX::COLOR4D Class Reference

A color representation with 4 components: red, green, blue, alpha. More...

#include <color4d.h>

Public Member Functions

 COLOR4D ()
 
 COLOR4D (double aRed, double aGreen, double aBlue, double aAlpha)
 
 COLOR4D (EDA_COLOR_T aColor)
 
COLOR4DFromCSSRGBA (int aRed, int aGreen, int aBlue, double aAlpha=1.0)
 Initialize the color from a RGBA value with 0-255 red/green/blue and 0-1 alpha. More...
 
void ToHSL (double &aOutHue, double &aOutSaturation, double &aOutValue) const
 Converts current color (stored in RGB) to HSL format. More...
 
void FromHSL (double aInHue, double aInSaturation, double aInLightness)
 Change currently used color to the one given by hue, saturation and lightness parameters. More...
 
COLOR4DBrighten (double aFactor)
 Makes the color brighter by a given factor. More...
 
COLOR4DDarken (double aFactor)
 Makes the color darker by a given factor. More...
 
COLOR4DInvert ()
 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
 Return a color that is brighter by a given factor, without modifying object. More...
 
COLOR4D Darkened (double aFactor) const
 Return a color that is darker by a given factor, without modifying object. More...
 
COLOR4D Mix (const COLOR4D &aColor, double aFactor) const
 Return a color that is mixed with the input by a factor. More...
 
COLOR4D WithAlpha (double aAlpha) const
 Return a color with the same color, but the given alpha. More...
 
COLOR4D Inverted () const
 Returns an inverted color, alpha remains the same. More...
 
double GetBrightness () const
 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
 Convert current color (stored in RGB) to HSV format. More...
 
void FromHSV (double aInH, double aInS, double aInV)
 Changes currently used color to the one given by hue, saturation and value parameters. More...
 
double Distance (const COLOR4D &other) const
 Returns the distance (in RGB space) between two colors. 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
 
static const COLOR4D CLEAR
 

Detailed Description

A color representation with 4 components: red, green, blue, alpha.

Definition at line 103 of file color4d.h.

Constructor & Destructor Documentation

◆ COLOR4D() [1/3]

KIGFX::COLOR4D::COLOR4D ( )
inline

Definition at line 107 of file color4d.h.

107 :
108 r( 0 ),
109 g( 0 ),
110 b( 0 ),
111 a( 1.0 )
112 {
113 }
double r
Red component.
Definition: color4d.h:384
double g
Green component.
Definition: color4d.h:385
double a
Alpha component.
Definition: color4d.h:387
double b
Blue component.
Definition: color4d.h:386

Referenced by Brightened(), Darkened(), Inverted(), Mix(), and WithAlpha().

◆ COLOR4D() [2/3]

KIGFX::COLOR4D::COLOR4D ( double  aRed,
double  aGreen,
double  aBlue,
double  aAlpha 
)
inline
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 121 of file color4d.h.

121 :
122 r( aRed ),
123 g( aGreen ),
124 b( aBlue ),
125 a( aAlpha )
126 {
127 wxASSERT( r >= 0.0 && r <= 1.0 );
128 wxASSERT( g >= 0.0 && g <= 1.0 );
129 wxASSERT( b >= 0.0 && b <= 1.0 );
130 wxASSERT( a >= 0.0 && a <= 1.0 );
131 }

References a, b, g, and r.

◆ COLOR4D() [3/3]

COLOR4D::COLOR4D ( EDA_COLOR_T  aColor)
Parameters
aColoris one of KiCad's palette colors.
See also
EDA_COLOR_T

Definition at line 83 of file color4d.cpp.

84{
85 if( aColor <= UNSPECIFIED_COLOR || aColor >= NBCOLORS )
86 {
88 return;
89 }
90
91 int candidate = 0;
92
93 for( ; candidate < NBCOLORS; ++candidate )
94 {
95 if( colorRefs()[candidate].m_Numcolor == aColor )
96 break;
97 }
98
99 if( candidate >= NBCOLORS )
100 {
101 *this = COLOR4D::UNSPECIFIED;
102 return;
103 }
104
105 r = colorRefs()[candidate].m_Red / 255.0;
106 g = colorRefs()[candidate].m_Green / 255.0;
107 b = colorRefs()[candidate].m_Blue / 255.0;
108 a = 1.0;
109}
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:390
const StructColors * colorRefs()
Global list of legacy color names, still used all over the place for constructing COLOR4D's.
Definition: color4d.cpp:39
@ NBCOLORS
Number of colors.
Definition: color4d.h:79
unsigned char m_Blue
Definition: color4d.h:86
unsigned char m_Green
Definition: color4d.h:87
unsigned char m_Red
Definition: color4d.h:88

References a, b, colorRefs(), g, StructColors::m_Blue, StructColors::m_Green, StructColors::m_Red, NBCOLORS, r, and UNSPECIFIED.

Member Function Documentation

◆ Brighten()

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

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 225 of file color4d.h.

226 {
227 wxASSERT( aFactor >= 0.0 && aFactor <= 1.0 );
228
229 r = r * ( 1.0 - aFactor ) + aFactor;
230 g = g * ( 1.0 - aFactor ) + aFactor;
231 b = b * ( 1.0 - aFactor ) + aFactor;
232
233 return *this;
234 }

References b, g, and r.

Referenced by KIGFX::PCB_RENDER_SETTINGS::GetColor().

◆ Brightened()

COLOR4D KIGFX::COLOR4D::Brightened ( double  aFactor) const
inline

Return 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 278 of file color4d.h.

279 {
280 wxASSERT( aFactor >= 0.0 && aFactor <= 1.0 );
281
282 return COLOR4D( r * ( 1.0 - aFactor ) + aFactor, g * ( 1.0 - aFactor ) + aFactor,
283 b * ( 1.0 - aFactor ) + aFactor, a );
284 }

References a, b, COLOR4D(), g, and r.

Referenced by KIGFX::SCH_PAINTER::drawDanglingSymbol(), KIGFX::SCH_PAINTER::drawPinDanglingSymbol(), KIGFX::DS_RENDER_SETTINGS::DS_RENDER_SETTINGS(), EXPORTER_PCB_VRML::EXPORTER_PCB_VRML(), KIGFX::GERBVIEW_RENDER_SETTINGS::LoadColors(), COLOR_SWATCH::MakeBitmap(), KIGFX::RENDER_SETTINGS::update(), and EDIT_POINTS::ViewDraw().

◆ Darken()

COLOR4D & KIGFX::COLOR4D::Darken ( double  aFactor)
inline

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 242 of file color4d.h.

243 {
244 wxASSERT( aFactor >= 0.0 && aFactor <= 1.0 );
245
246 r = r * ( 1.0 - aFactor );
247 g = g * ( 1.0 - aFactor );
248 b = b * ( 1.0 - aFactor );
249
250 return *this;
251 }

References b, g, and r.

Referenced by KIGFX::PCB_RENDER_SETTINGS::GetColor().

◆ Darkened()

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

Return 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 292 of file color4d.h.

293 {
294 wxASSERT( aFactor >= 0.0 && aFactor <= 1.0 );
295
296 return COLOR4D( r * ( 1.0 - aFactor ), g * ( 1.0 - aFactor ), b * ( 1.0 - aFactor ), a );
297 }

References a, b, COLOR4D(), g, and r.

Referenced by KIGFX::GERBVIEW_RENDER_SETTINGS::LoadColors(), COLOR_SWATCH::MakeBitmap(), KIGFX::RENDER_SETTINGS::update(), and EDIT_POINTS::ViewDraw().

◆ Distance()

double COLOR4D::Distance ( const COLOR4D other) const

Returns the distance (in RGB space) between two colors.

Definition at line 536 of file color4d.cpp.

537{
538 return ( r - other.r ) * ( r - other.r )
539 + ( g - other.g ) * ( g - other.g )
540 + ( b - other.b ) * ( b - other.b );
541}

References b, g, and r.

Referenced by EDIT_POINTS::ViewDraw().

◆ FindNearestLegacyColor()

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

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

Definition at line 544 of file color4d.cpp.

545{
547
548 /* Find the 'nearest' color in the palette. This is fun. There is
549 a gazilion of metrics for the color space and no one of the
550 useful one is in the RGB color space. Who cares, this is a CAD,
551 not a photosomething...
552
553 I hereby declare that the distance is the sum of the square of the
554 component difference. Think about the RGB color cube. Now get the
555 euclidean distance, but without the square root... for ordering
556 purposes it's the same, obviously. Also each component can't be
557 less of the target one, since I found this currently work better...
558 */
559 int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this
560
562 trying = static_cast<EDA_COLOR_T>( int( trying ) + 1 ) )
563 {
564 const StructColors &c = colorRefs()[trying];
565 int distance = ( aR - c.m_Red ) * ( aR - c.m_Red ) +
566 ( aG - c.m_Green ) * ( aG - c.m_Green ) +
567 ( aB - c.m_Blue ) * ( aB - c.m_Blue );
568
569 if( distance < nearest_distance && c.m_Red >= aR &&
570 c.m_Green >= aG && c.m_Blue >= aB )
571 {
572 nearest_distance = distance;
573 candidate = trying;
574 }
575 }
576
577 return candidate;
578}
EDA_COLOR_T
Legacy color enumeration.
Definition: color4d.h:42
@ BLACK
Definition: color4d.h:44
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)

References BLACK, colorRefs(), distance(), StructColors::m_Blue, StructColors::m_Green, StructColors::m_Red, and NBCOLORS.

◆ FromCSSRGBA()

COLOR4D & COLOR4D::FromCSSRGBA ( int  aRed,
int  aGreen,
int  aBlue,
double  aAlpha = 1.0 
)

Initialize the color from a RGBA value with 0-255 red/green/blue and 0-1 alpha.

Suitable for taking the values directly from the "CSS syntax" from ToWxString.

Returns
this color.

Definition at line 581 of file color4d.cpp.

582{
583 r = std::max( 0, std::min( 255, aRed ) ) / 255.0;
584 g = std::max( 0, std::min( 255, aGreen ) ) / 255.0;
585 b = std::max( 0, std::min( 255, aBlue ) ) / 255.0;
586 a = std::max( 0.0, std::min( 1.0, aAlpha ) );
587
588 return *this;
589}

References a, b, g, and r.

Referenced by GetColorFromInt().

◆ FromHSL()

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

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

Definition at line 346 of file color4d.cpp.

347{
348 const auto P = ( 1.0 - std::abs( 2.0 * aInLightness - 1.0 ) ) * aInSaturation;
349 const auto scaled_hue = aInHue / 60.0;
350 const auto Q = P * ( 1.0 - std::abs( std::fmod( scaled_hue, 2.0 ) - 1.0 ) );
351
352 r = g = b = aInLightness - P / 2.0;
353
354 if (scaled_hue < 1.0)
355 {
356 r += P;
357 g += Q;
358 }
359 else if (scaled_hue < 2.0)
360 {
361 r += Q;
362 g += P;
363 }
364 else if (scaled_hue < 3.0)
365 {
366 g += P;
367 b += Q;
368 }
369 else if (scaled_hue < 4.0)
370 {
371 g += Q;
372 b += P;
373 }
374 else if (scaled_hue < 5.0)
375 {
376 r += Q;
377 b += P;
378 }
379 else
380 {
381 r += P;
382 b += Q;
383 }
384}
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
#define Q()
#define P()

References std::abs(), b, g, P, Q, and r.

Referenced by BOOST_AUTO_TEST_CASE().

◆ FromHSV()

void COLOR4D::FromHSV ( double  aInH,
double  aInS,
double  aInV 
)

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.

Definition at line 441 of file color4d.cpp.

442{
443 if( aInS <= 0.0 )
444 {
445 r = aInV;
446 g = aInV;
447 b = aInV;
448 return;
449 }
450
451 double hh = aInH;
452
453 while( hh >= 360.0 )
454 hh -= 360.0;
455
456 /* Hue in degrees (0...360) is coded according to this table
457 * 0 or 360 : red
458 * 60 : yellow
459 * 120 : green
460 * 180 : cyan
461 * 240 : blue
462 * 300 : magenta
463 */
464 hh /= 60.0;
465
466 int i = (int) hh;
467 double ff = hh - i;
468
469 double p = aInV * ( 1.0 - aInS );
470 double q = aInV * ( 1.0 - ( aInS * ff ) );
471 double t = aInV * ( 1.0 - ( aInS * ( 1.0 - ff ) ) );
472
473 switch( i )
474 {
475 case 0:
476 r = aInV;
477 g = t;
478 b = p;
479 break;
480
481 case 1:
482 r = q;
483 g = aInV;
484 b = p;
485 break;
486
487 case 2:
488 r = p;
489 g = aInV;
490 b = t;
491 break;
492
493 case 3:
494 r = p;
495 g = q;
496 b = aInV;
497 break;
498
499 case 4:
500 r = t;
501 g = p;
502 b = aInV;
503 break;
504
505 case 5:
506 default:
507 r = aInV;
508 g = p;
509 b = q;
510 break;
511 }
512}

References b, g, and r.

Referenced by BOOST_AUTO_TEST_CASE(), DIALOG_COLOR_PICKER::OnChangeBrightness(), DIALOG_COLOR_PICKER::OnChangeEditHue(), DIALOG_COLOR_PICKER::OnChangeEditSat(), Saturate(), and DIALOG_COLOR_PICKER::setHSvaluesFromCursor().

◆ GetBrightness()

double KIGFX::COLOR4D::GetBrightness ( ) const
inline

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

Returns
The brightness value.

Definition at line 343 of file color4d.h.

344 {
345 // Weighted W3C formula
346 return r * 0.299 + g * 0.587 + b * 0.117;
347 }

References b, g, and r.

Referenced by RC_TREE_MODEL::GetAttr(), KIGFX::PREVIEW::GetShadowColor(), KIGFX::SCH_RENDER_SETTINGS::IsBackgroundDark(), KIGFX::DS_RENDER_SETTINGS::IsBackgroundDark(), KIGFX::PCB_RENDER_SETTINGS::IsBackgroundDark(), COLOR_SWATCH::MakeBitmap(), and EDIT_POINTS::ViewDraw().

◆ Invert()

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

Makes the color inverted, alpha remains the same.

Returns
COLOR4D& Inverted color.

Definition at line 258 of file color4d.h.

259 {
260 r = ( 1.0 - r );
261 g = ( 1.0 - g );
262 b = ( 1.0 - b );
263
264 return *this;
265 }

References b, g, and r.

Referenced by EDIT_POINTS::ViewDraw().

◆ Inverted()

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

Returns an inverted color, alpha remains the same.

Returns
COLOR4D& Inverted color.

Definition at line 333 of file color4d.h.

334 {
335 return COLOR4D( 1.0 - r, 1.0 - g, 1.0 - b, a );
336 }

References a, b, COLOR4D(), g, and r.

Referenced by KIGFX::PCB_RENDER_SETTINGS::LoadColors().

◆ Mix()

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

Return 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 305 of file color4d.h.

306 {
307 wxASSERT( aFactor >= 0.0 && aFactor <= 1.0 );
308
309 return COLOR4D( aColor.r * ( 1.0 - aFactor ) + r * aFactor,
310 aColor.g * ( 1.0 - aFactor ) + g * aFactor,
311 aColor.b * ( 1.0 - aFactor ) + b * aFactor,
312 a );
313 }

References a, b, COLOR4D(), g, and r.

Referenced by KIGFX::SCH_PAINTER::draw(), EXPORTER_PCB_VRML::EXPORTER_PCB_VRML(), BOARD_ADAPTER::InitSettings(), LIB_PIN::PlotPinTexts(), LIB_PIN::printPinTexts(), KIGFX::SCH_PAINTER::setDeviceColors(), SCINTILLA_TRICKS::setupStyles(), and KIGFX::RENDER_SETTINGS::update().

◆ Saturate()

COLOR4D & COLOR4D::Saturate ( double  aFactor)

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

Definition at line 515 of file color4d.cpp.

516{
517 // One can saturate a color only when r, v, b are not equal
518 if( r == g && r == b )
519 return *this;
520
521 double h, s, v;
522
523 ToHSV( h, s, v, true );
524 FromHSV( h, aFactor, 1.0 );
525
526 return *this;
527}
void ToHSV(double &aOutHue, double &aOutSaturation, double &aOutValue, bool aAlwaysDefineHue=false) const
Convert current color (stored in RGB) to HSV format.
Definition: color4d.cpp:387
void FromHSV(double aInH, double aInS, double aInV)
Changes currently used color to the one given by hue, saturation and value parameters.
Definition: color4d.cpp:441

References b, FromHSV(), g, r, and ToHSV().

◆ ToHSL()

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

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,

Definition at line 315 of file color4d.cpp.

316{
317 auto min = std::min( r, std::min( g, b ) );
318 auto max = std::max( r, std::max( g, b ) );
319 auto diff = max - min;
320
321 aOutLightness = ( max + min ) / 2.0;
322
323 if( aOutLightness >= 1.0 )
324 aOutSaturation = 0.0;
325 else
326 aOutSaturation = diff / ( 1.0 - std::abs( 2.0 * aOutLightness - 1.0 ) );
327
328 double hue;
329
330 if( diff <= 0.0 )
331 hue = 0.0;
332 else if( max == r )
333 hue = ( g - b ) / diff;
334 else if( max == g )
335 hue = ( b - r ) / diff + 2.0;
336 else
337 hue = ( r - g ) / diff + 4.0;
338
339 aOutHue = hue > 0.0 ? hue * 60.0 : hue * 60.0 + 360.0;
340
341 while( aOutHue < 0.0 )
342 aOutHue += 360.0;
343}

References std::abs(), b, g, and r.

Referenced by PNS_TUNE_STATUS_POPUP::UpdateStatus().

◆ ToHSV()

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

Convert 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 useful to convert a 4D color to a legacy color, because Red has hue = 0, therefore aAlwaysDefineHue = false makes difference between Red and Gray colors.

Definition at line 387 of file color4d.cpp.

389{
390 double min, max, delta;
391
392 min = r < g ? r : g;
393 min = min < b ? min : b;
394
395 max = r > g ? r : g;
396 max = max > b ? max : b;
397
398 aOutValue = max; // value
399 delta = max - min;
400
401 if( max > 0.0 )
402 {
403 aOutSaturation = ( delta / max );
404 }
405 else // for black color (r = g = b = 0 ) saturation is set to 0.
406 {
407 aOutSaturation = 0.0;
408 aOutHue = aAlwaysDefineHue ? 0.0 : NAN;
409 return;
410 }
411
412 /* Hue in degrees (0...360) is coded according to this table
413 * 0 or 360 : red
414 * 60 : yellow
415 * 120 : green
416 * 180 : cyan
417 * 240 : blue
418 * 300 : magenta
419 */
420 if( delta != 0.0 )
421 {
422 if( r >= max )
423 aOutHue = ( g - b ) / delta; // between yellow & magenta
424 else if( g >= max )
425 aOutHue = 2.0 + ( b - r ) / delta; // between cyan & yellow
426 else
427 aOutHue = 4.0 + ( r - g ) / delta; // between magenta & cyan
428
429 aOutHue *= 60.0; // degrees
430
431 if( aOutHue < 0.0 )
432 aOutHue += 360.0;
433 }
434 else // delta = 0 means r = g = b. hue is set to 0.0
435 {
436 aOutHue = aAlwaysDefineHue ? 0.0 : NAN;
437 }
438}
constexpr int delta

References b, delta, g, and r.

Referenced by DIALOG_COLOR_PICKER::buttColorClick(), DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER(), DIALOG_COLOR_PICKER::OnColorValueText(), DIALOG_COLOR_PICKER::OnResetButton(), DIALOG_COLOR_PICKER::onRGBMouseDrag(), Saturate(), and DIALOG_COLOR_PICKER::SetEditVals().

◆ WithAlpha()

COLOR4D KIGFX::COLOR4D::WithAlpha ( double  aAlpha) const
inline

Return a color with the same color, but the given alpha.

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

Definition at line 321 of file color4d.h.

322 {
323 wxASSERT( aAlpha >= 0.0 && aAlpha <= 1.0 );
324
325 return COLOR4D( r, g, b, aAlpha );
326 }

References b, COLOR4D(), g, and r.

Referenced by PNS_LOG_VIEWER_OVERLAY::Arc(), deemphasise(), LAYER_SELECTOR::DrawColorSwatch(), BOARD_PRINTOUT::DrawPage(), FAB_LAYER_COLOR::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), COLOR_SWATCH::MakeBitmap(), PCB_GRID_HELPER::PCB_GRID_HELPER(), PCB_EDIT_FRAME::PrepareLayerIndicator(), SCINTILLA_TRICKS::setupStyles(), and EDIT_POINTS::ViewDraw().

Member Data Documentation

◆ a

double KIGFX::COLOR4D::a

Alpha component.

Definition at line 387 of file color4d.h.

Referenced by KIGFX::OPENGL_GAL::BitmapText(), KIGFX::OPENGL_GAL::blitCursor(), KIGFX::CAIRO_GAL_BASE::blitCursor(), Brightened(), DIALOG_COLOR_PICKER::buttColorClick(), KIGFX::CAIRO_GAL_BASE::ChangeGroupColor(), KIGFX::VERTEX_MANAGER::ChangeItemColor(), KIGFX::VERTEX_MANAGER::Color(), COLOR4D(), CUSTOM_COLOR_ITEM::CUSTOM_COLOR_ITEM(), Darkened(), DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER(), KIGFX::PCB_PAINTER::draw(), KIGFX::OPENGL_GAL::DrawArc(), KIGFX::CAIRO_GAL_BASE::DrawArcSegment(), KIGFX::OPENGL_GAL::DrawArcSegment(), KIGFX::CAIRO_GAL_BASE::drawAxes(), KIGFX::OPENGL_GAL::drawBitmapOverbar(), KIGFX::OPENGL_GAL::drawCircle(), KIGFX::OPENGL_GAL::DrawGrid(), KIGFX::CAIRO_GAL_BASE::drawGridCross(), KIGFX::CAIRO_GAL_BASE::drawGridLine(), KIGFX::CAIRO_GAL_BASE::drawGridPoint(), KIGFX::CAIRO_GAL_BASE::DrawGroup(), KIGFX::OPENGL_GAL::DrawLine(), KIGFX::OPENGL_GAL::drawPolygon(), KIGFX::OPENGL_GAL::drawPolyline(), KIGFX::OPENGL_GAL::DrawRectangle(), KIGFX::CAIRO_GAL_BASE::DrawSegment(), KIGFX::OPENGL_GAL::drawSegment(), KIGFX::OPENGL_GAL::drawSegmentChain(), KIGFX::OPENGL_GAL::drawSemiCircle(), KIGFX::OPENGL_GAL::drawTriangulatedPolyset(), EXPORTER_PCB_VRML::EXPORTER_PCB_VRML(), KIGFX::CAIRO_GAL_BASE::flushPath(), DS_DATA_MODEL_IO::format(), formatFill(), FromCSSRGBA(), BOARD_ADAPTER::GetColor(), BOARD_ADAPTER::InitSettings(), Inverted(), KI_TEST::IsColorNear(), KI_TEST::IsColorNearHex(), PCB_CONTROL::LayerAlphaDec(), PCB_CONTROL::LayerAlphaInc(), KIGFX::GERBVIEW_RENDER_SETTINGS::LoadColors(), KIGFX::PCB_RENDER_SETTINGS::LoadColors(), PANEL_PREVIEW_3D_MODEL::loadSettings(), Mix(), DIALOG_COLOR_PICKER::OnChangeAlpha(), DIALOG_COLOR_PICKER::OnResetButton(), KIGFX::operator<(), KIGFX::operator==(), DRAWING_SHEET_PARSER::parseText(), SCH_SEXPR_PLUGIN::saveJunction(), SCH_SEXPR_PLUGIN::saveSheet(), DIALOG_COLOR_PICKER::SetEditVals(), KIGFX::CAIRO_GAL_BASE::SetFillColor(), SCH_LINE::SetLineColor(), KIGFX::CAIRO_GAL_BASE::SetStrokeColor(), SCINTILLA_TRICKS::setupStyles(), KIGFX::CAIRO_GAL_BASE::storePath(), and ROUTER_PREVIEW_ITEM::Update().

◆ b

double KIGFX::COLOR4D::b

Blue component.

Definition at line 386 of file color4d.h.

Referenced by KIGFX::OPENGL_GAL::BitmapText(), KIGFX::OPENGL_GAL::blitCursor(), KIGFX::CAIRO_GAL_BASE::blitCursor(), Brighten(), Brightened(), DIALOG_COLOR_PICKER::buttColorClick(), KIGFX::CAIRO_GAL_BASE::ChangeGroupColor(), KIGFX::VERTEX_MANAGER::ChangeItemColor(), KIGFX::OPENGL_COMPOSITOR::ClearBuffer(), KIGFX::CAIRO_GAL_BASE::ClearScreen(), KIGFX::VERTEX_MANAGER::Color(), COLOR4D(), EXPORTER_STEP::composePCB(), CUSTOM_COLOR_ITEM::CUSTOM_COLOR_ITEM(), Darken(), Darkened(), Distance(), KIGFX::OPENGL_GAL::DrawArc(), KIGFX::CAIRO_GAL_BASE::DrawArcSegment(), KIGFX::OPENGL_GAL::DrawArcSegment(), KIGFX::CAIRO_GAL_BASE::drawAxes(), KIGFX::OPENGL_GAL::drawBitmapOverbar(), KIGFX::OPENGL_GAL::drawCircle(), KIGFX::OPENGL_GAL::DrawGrid(), KIGFX::CAIRO_GAL_BASE::drawGridCross(), KIGFX::CAIRO_GAL_BASE::drawGridLine(), KIGFX::CAIRO_GAL_BASE::drawGridPoint(), KIGFX::CAIRO_GAL_BASE::DrawGroup(), KIGFX::OPENGL_GAL::DrawLine(), KIGFX::OPENGL_GAL::drawPolygon(), KIGFX::OPENGL_GAL::drawPolyline(), KIGFX::OPENGL_GAL::DrawRectangle(), DIALOG_COLOR_PICKER::drawRGBPalette(), KIGFX::CAIRO_GAL_BASE::DrawSegment(), KIGFX::OPENGL_GAL::drawSegment(), KIGFX::OPENGL_GAL::drawSegmentChain(), KIGFX::OPENGL_GAL::drawSemiCircle(), KIGFX::OPENGL_GAL::drawTriangulatedPolyset(), EXPORTER_PCB_VRML::EXPORTER_PCB_VRML(), KIGFX::CAIRO_GAL_BASE::flushPath(), DS_DATA_MODEL_IO::format(), formatFill(), FromCSSRGBA(), FromHSL(), FromHSV(), GetBrightness(), BOARD_ADAPTER::GetColor(), getDXFColorName(), TRANSLINE::Init(), Invert(), Inverted(), KI_TEST::IsColorNear(), KI_TEST::IsColorNearHex(), PANEL_PREVIEW_3D_MODEL::loadSettings(), Mix(), DIALOG_COLOR_PICKER::OnChangeEditBlue(), DIALOG_COLOR_PICKER::OnResetButton(), DIALOG_COLOR_PICKER::onRGBMouseDrag(), KIGFX::operator<(), KIGFX::operator==(), DRAWING_SHEET_PARSER::parseText(), Saturate(), SCH_SEXPR_PLUGIN::saveJunction(), SCH_SEXPR_PLUGIN::saveSheet(), DIALOG_COLOR_PICKER::SetEditVals(), KIGFX::CAIRO_GAL_BASE::SetFillColor(), PANEL_TRANSLINE::SetPrmBgColor(), KIGFX::CAIRO_GAL_BASE::SetStrokeColor(), KIGFX::CAIRO_GAL_BASE::storePath(), ToHSL(), ToHSV(), KIGFX::RENDER_SETTINGS::update(), RATSNEST_VIEW_ITEM::ViewDraw(), and WithAlpha().

◆ BLACK

◆ CLEAR

const COLOR4D COLOR4D::CLEAR
static

Definition at line 395 of file color4d.h.

Referenced by KIGFX::PCB_PAINTER::draw(), and KIGFX::PCB_RENDER_SETTINGS::GetColor().

◆ g

double KIGFX::COLOR4D::g

Green component.

Definition at line 385 of file color4d.h.

Referenced by KIGFX::OPENGL_GAL::BitmapText(), KIGFX::OPENGL_GAL::blitCursor(), KIGFX::CAIRO_GAL_BASE::blitCursor(), Brighten(), Brightened(), DIALOG_COLOR_PICKER::buttColorClick(), KIGFX::CAIRO_GAL_BASE::ChangeGroupColor(), KIGFX::VERTEX_MANAGER::ChangeItemColor(), KIGFX::OPENGL_COMPOSITOR::ClearBuffer(), KIGFX::CAIRO_GAL_BASE::ClearScreen(), KIGFX::VERTEX_MANAGER::Color(), COLOR4D(), EXPORTER_STEP::composePCB(), CUSTOM_COLOR_ITEM::CUSTOM_COLOR_ITEM(), Darken(), Darkened(), Distance(), KIGFX::OPENGL_GAL::DrawArc(), KIGFX::CAIRO_GAL_BASE::DrawArcSegment(), KIGFX::OPENGL_GAL::DrawArcSegment(), KIGFX::CAIRO_GAL_BASE::drawAxes(), KIGFX::OPENGL_GAL::drawBitmapOverbar(), KIGFX::OPENGL_GAL::drawCircle(), KIGFX::OPENGL_GAL::DrawGrid(), KIGFX::CAIRO_GAL_BASE::drawGridCross(), KIGFX::CAIRO_GAL_BASE::drawGridLine(), KIGFX::CAIRO_GAL_BASE::drawGridPoint(), KIGFX::CAIRO_GAL_BASE::DrawGroup(), KIGFX::OPENGL_GAL::DrawLine(), KIGFX::OPENGL_GAL::drawPolygon(), KIGFX::OPENGL_GAL::drawPolyline(), KIGFX::OPENGL_GAL::DrawRectangle(), DIALOG_COLOR_PICKER::drawRGBPalette(), KIGFX::CAIRO_GAL_BASE::DrawSegment(), KIGFX::OPENGL_GAL::drawSegment(), KIGFX::OPENGL_GAL::drawSegmentChain(), KIGFX::OPENGL_GAL::drawSemiCircle(), KIGFX::OPENGL_GAL::drawTriangulatedPolyset(), EXPORTER_PCB_VRML::EXPORTER_PCB_VRML(), KIGFX::CAIRO_GAL_BASE::flushPath(), DS_DATA_MODEL_IO::format(), formatFill(), FromCSSRGBA(), FromHSL(), FromHSV(), GetBrightness(), BOARD_ADAPTER::GetColor(), getDXFColorName(), TRANSLINE::Init(), Invert(), Inverted(), KI_TEST::IsColorNear(), KI_TEST::IsColorNearHex(), PANEL_PREVIEW_3D_MODEL::loadSettings(), Mix(), DIALOG_COLOR_PICKER::OnChangeEditGreen(), DIALOG_COLOR_PICKER::OnResetButton(), DIALOG_COLOR_PICKER::onRGBMouseDrag(), KIGFX::operator<(), KIGFX::operator==(), DRAWING_SHEET_PARSER::parseText(), Saturate(), SCH_SEXPR_PLUGIN::saveJunction(), SCH_SEXPR_PLUGIN::saveSheet(), DIALOG_COLOR_PICKER::SetEditVals(), KIGFX::CAIRO_GAL_BASE::SetFillColor(), PANEL_TRANSLINE::SetPrmBgColor(), KIGFX::CAIRO_GAL_BASE::SetStrokeColor(), KIGFX::CAIRO_GAL_BASE::storePath(), ToHSL(), ToHSV(), and WithAlpha().

◆ r

double KIGFX::COLOR4D::r

Red component.

Definition at line 384 of file color4d.h.

Referenced by KIGFX::OPENGL_GAL::BitmapText(), KIGFX::OPENGL_GAL::blitCursor(), KIGFX::CAIRO_GAL_BASE::blitCursor(), Brighten(), Brightened(), DIALOG_COLOR_PICKER::buttColorClick(), KIGFX::CAIRO_GAL_BASE::ChangeGroupColor(), KIGFX::VERTEX_MANAGER::ChangeItemColor(), KIGFX::OPENGL_COMPOSITOR::ClearBuffer(), KIGFX::CAIRO_GAL_BASE::ClearScreen(), KIGFX::VERTEX_MANAGER::Color(), COLOR4D(), EXPORTER_STEP::composePCB(), CUSTOM_COLOR_ITEM::CUSTOM_COLOR_ITEM(), Darken(), Darkened(), Distance(), KIGFX::OPENGL_GAL::DrawArc(), KIGFX::CAIRO_GAL_BASE::DrawArcSegment(), KIGFX::OPENGL_GAL::DrawArcSegment(), KIGFX::CAIRO_GAL_BASE::drawAxes(), KIGFX::OPENGL_GAL::drawBitmapOverbar(), KIGFX::OPENGL_GAL::drawCircle(), KIGFX::OPENGL_GAL::DrawGrid(), KIGFX::CAIRO_GAL_BASE::drawGridCross(), KIGFX::CAIRO_GAL_BASE::drawGridLine(), KIGFX::CAIRO_GAL_BASE::drawGridPoint(), KIGFX::CAIRO_GAL_BASE::DrawGroup(), KIGFX::OPENGL_GAL::DrawLine(), KIGFX::OPENGL_GAL::drawPolygon(), KIGFX::OPENGL_GAL::drawPolyline(), KIGFX::OPENGL_GAL::DrawRectangle(), DIALOG_COLOR_PICKER::drawRGBPalette(), KIGFX::CAIRO_GAL_BASE::DrawSegment(), KIGFX::OPENGL_GAL::drawSegment(), KIGFX::OPENGL_GAL::drawSegmentChain(), KIGFX::OPENGL_GAL::drawSemiCircle(), KIGFX::OPENGL_GAL::drawTriangulatedPolyset(), EXPORTER_PCB_VRML::EXPORTER_PCB_VRML(), KIGFX::CAIRO_GAL_BASE::flushPath(), DS_DATA_MODEL_IO::format(), formatFill(), FromCSSRGBA(), FromHSL(), FromHSV(), GetBrightness(), BOARD_ADAPTER::GetColor(), getDXFColorName(), TRANSLINE::Init(), Invert(), Inverted(), KI_TEST::IsColorNear(), KI_TEST::IsColorNearHex(), PANEL_PREVIEW_3D_MODEL::loadSettings(), Mix(), DIALOG_COLOR_PICKER::OnChangeEditRed(), DIALOG_COLOR_PICKER::OnResetButton(), DIALOG_COLOR_PICKER::onRGBMouseDrag(), KIGFX::operator<(), KIGFX::operator==(), DRAWING_SHEET_PARSER::parseText(), Saturate(), SCH_SEXPR_PLUGIN::saveJunction(), SCH_SEXPR_PLUGIN::saveSheet(), DIALOG_COLOR_PICKER::SetEditVals(), KIGFX::CAIRO_GAL_BASE::SetFillColor(), PANEL_TRANSLINE::SetPrmBgColor(), KIGFX::CAIRO_GAL_BASE::SetStrokeColor(), KIGFX::CAIRO_GAL_BASE::storePath(), ToHSL(), ToHSV(), and WithAlpha().

◆ UNSPECIFIED

const COLOR4D COLOR4D::UNSPECIFIED
static

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

Definition at line 390 of file color4d.h.

Referenced by COLOR4D(), STROKE_PARAMS::Format(), KIGFX::DS_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), and KIGFX::SCH_PAINTER::getRenderColor().

◆ WHITE

const COLOR4D COLOR4D::WHITE
static

Definition at line 393 of file color4d.h.

Referenced by PNS_DEBUG_SHAPE::PNS_DEBUG_SHAPE().


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