| 
    KiCad PCB EDA Suite
    
   | 
 
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) | |
| COLOR4D (const wxString &aColorStr) | |
| Defines a color from a CSS or HTML-type string.   | |
| COLOR4D (const wxColour &aColor) | |
| 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.   | |
| bool | SetFromWxString (const wxString &aColorString) | 
| Set color values by parsing a string using wxColour::Set().   | |
| wxString | ToCSSString () const | 
| bool | SetFromHexString (const wxString &aColorString) | 
| wxString | ToHexString () const | 
| wxColour | ToColour () const | 
| COLOR4D | LegacyMix (const COLOR4D &aColor) const | 
| Mix this COLOR4D with an input COLOR4D using the OR-mixing of legacy canvas.   | |
| void | ToHSL (double &aOutHue, double &aOutSaturation, double &aOutLightness) const | 
| Converts current color (stored in RGB) to HSL format.   | |
| void | FromHSL (double aInHue, double aInSaturation, double aInLightness) | 
| Change currently used color to the one given by hue, saturation and lightness parameters.   | |
| COLOR4D & | Brighten (double aFactor) | 
| Makes the color brighter by a given factor.   | |
| COLOR4D & | Darken (double aFactor) | 
| Makes the color darker by a given factor.   | |
| COLOR4D & | Invert () | 
| Makes the color inverted, alpha remains the same.   | |
| COLOR4D & | Saturate (double aFactor) | 
| Saturates the color to a given factor (in HSV model)   | |
| COLOR4D & | Desaturate () | 
| Removes color (in HSL model)   | |
| COLOR4D | Brightened (double aFactor) const | 
| Return a color that is brighter by a given factor, without modifying object.   | |
| COLOR4D | Darkened (double aFactor) const | 
| Return a color that is darker by a given factor, without modifying object.   | |
| COLOR4D | Mix (const COLOR4D &aColor, double aFactor) const | 
| Return a color that is mixed with the input by a factor.   | |
| COLOR4D | WithAlpha (double aAlpha) const | 
| Return a color with the same color, but the given alpha.   | |
| COLOR4D | Inverted () const | 
| Returns an inverted color, alpha remains the same.   | |
| double | GetBrightness () const | 
| Returns the brightness value of the color ranged from 0.0 to 1.0.   | |
| void | ToHSV (double &aOutHue, double &aOutSaturation, double &aOutValue, bool aAlwaysDefineHue=false) const | 
| Convert current color (stored in RGB) to HSV format.   | |
| void | FromHSV (double aInH, double aInS, double aInV) | 
| Changes currently used color to the one given by hue, saturation and value parameters.   | |
| double | Distance (const COLOR4D &other) const | 
| Returns the distance (in RGB space) between two colors.   | |
| int | Compare (const COLOR4D &aRhs) const | 
| double | RelativeLuminance () const | 
| Compute the relative luminance of a color using the formula from WCAG21.   | |
Static Public Member Functions | |
| static double | ContrastRatio (const COLOR4D &aLeft, const COLOR4D &aRight) | 
| Compute the contrast ration between two colors using the formula from WCAG21.   | |
| 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.   | |
Public Attributes | |
| double | r | 
| Red component.   | |
| double | g | 
| Green component.   | |
| double | b | 
| Blue component.   | |
| double | a | 
| Alpha component.   | |
Static Public Attributes | |
| static const COLOR4D | UNSPECIFIED | 
| For legacy support; used as a value to indicate color hasn't been set yet.   | |
| static const COLOR4D | WHITE | 
| static const COLOR4D | BLACK | 
| static const COLOR4D | CLEAR | 
A color representation with 4 components: red, green, blue, alpha.
      
  | 
  inline | 
| COLOR4D::COLOR4D | ( | EDA_COLOR_T | aColor | ) | 
| aColor | is one of KiCad's palette colors. | 
Definition at line 84 of file color4d.cpp.
| COLOR4D::COLOR4D | ( | const wxString & | aColorStr | ) | 
Defines a color from a CSS or HTML-type string.
| aColorStr | input string | 
Definition at line 113 of file color4d.cpp.
| COLOR4D::COLOR4D | ( | const wxColour & | aColor | ) | 
| aColor | is the color type used by wxWidgets. | 
Definition at line 120 of file color4d.cpp.
      
  | 
  inline | 
      
  | 
  inline | 
| int COLOR4D::Compare | ( | const COLOR4D & | aRhs | ) | const | 
Definition at line 588 of file color4d.cpp.
Compute the contrast ration between two colors using the formula from WCAG21.
| aLeft | is the first color to use in the ratio | 
| aRight | is the second color to use in the ratio | 
Definition at line 617 of file color4d.cpp.
      
  | 
  inline | 
      
  | 
  inline | 
| COLOR4D & COLOR4D::Desaturate | ( | ) | 
Removes color (in HSL model)
Definition at line 511 of file color4d.cpp.
| double COLOR4D::Distance | ( | const COLOR4D & | other | ) | const | 
Returns the distance (in RGB space) between two colors.
Definition at line 532 of file color4d.cpp.
      
  | 
  static | 
Returns a legacy color ID that is closest to the given 8-bit RGB values.
Definition at line 540 of file color4d.cpp.
Referenced by getDXFColorName().
| 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.
Definition at line 577 of file color4d.cpp.
| void COLOR4D::FromHSL | ( | double | aInHue, | 
| double | aInSaturation, | ||
| double | aInLightness ) | 
Change currently used color to the one given by hue, saturation and lightness parameters.
| aInHue | is hue component, in degrees (0.0 - 360.0). | 
| aInSaturation | is saturation component (0.0 - 1.0). | 
| aInLightness | is lightness component (0.0 - 1.0). | 
Definition at line 327 of file color4d.cpp.
| void COLOR4D::FromHSV | ( | double | aInH, | 
| double | aInS, | ||
| double | aInV ) | 
Changes currently used color to the one given by hue, saturation and value parameters.
| aInH | is hue component, in degrees. | 
| aInS | is saturation component. | 
| aInV | is value component. | 
Definition at line 422 of file color4d.cpp.
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inline | 
Mix this COLOR4D with an input COLOR4D using the OR-mixing of legacy canvas.
Can be removed once legacy canvas is removed. Depends on wxColour for simplicity, but could be re-written to avoid this dependency if desired.
| aColor | The color to mix with this one | 
Definition at line 231 of file color4d.cpp.
| double COLOR4D::RelativeLuminance | ( | ) | const | 
Compute the relative luminance of a color using the formula from WCAG21.
Definition at line 606 of file color4d.cpp.
| COLOR4D & COLOR4D::Saturate | ( | double | aFactor | ) | 
Saturates the color to a given factor (in HSV model)
Definition at line 496 of file color4d.cpp.
| bool COLOR4D::SetFromHexString | ( | const wxString & | aColorString | ) | 
Definition at line 177 of file color4d.cpp.
| bool COLOR4D::SetFromWxString | ( | const wxString & | aColorString | ) | 
Set color values by parsing a string using wxColour::Set().
| aColorString | is a color string that wxColour can understand. | 
Definition at line 129 of file color4d.cpp.
| wxColour COLOR4D::ToColour | ( | ) | const | 
Definition at line 220 of file color4d.cpp.
| wxString COLOR4D::ToCSSString | ( | ) | const | 
Definition at line 147 of file color4d.cpp.
| wxString COLOR4D::ToHexString | ( | ) | const | 
Definition at line 210 of file color4d.cpp.
| void COLOR4D::ToHSL | ( | double & | aOutHue, | 
| double & | aOutSaturation, | ||
| double & | aOutLightness ) const | 
Converts current color (stored in RGB) to HSL format.
| aOutHue | is the conversion result for hue component, in degrees 0 ... 360.0. | 
| aOutSaturation | is the conversion result for saturation component (0 ... 1.0). | 
| aOutLightness | is conversion result for value component (0 ... 1.0). | 
Definition at line 296 of file color4d.cpp.
| void COLOR4D::ToHSV | ( | double & | aOutHue, | 
| double & | aOutSaturation, | ||
| double & | aOutValue, | ||
| bool | aAlwaysDefineHue = false ) const | 
Convert current color (stored in RGB) to HSV format.
| aOutHue | is the conversion result for hue component, in degrees 0 ... 360.0. | 
| aOutSaturation | is the conversion result for saturation component (0 ... 1.0). | 
| aOutValue | is conversion result for value component (0 ... 1.0). | 
| aAlwaysDefineHue | controls the way hue is defined when r = v = b | 
Definition at line 368 of file color4d.cpp.
      
  | 
  inline | 
      
  | 
  static | 
Definition at line 402 of file color4d.h.
Referenced by BOARD_PRINTOUT::DrawPage(), DXF_PLOTTER::DXF_PLOTTER(), SCH_RENDER_SETTINGS::GetBackgroundColor(), LAYER_WIDGET::getBackgroundLayerColor(), GRSetBrush(), GRSetColorPen(), SVG_IMPORT_PLUGIN::Import(), PlotDrawingSheet(), SCH_PLOTTER::plotOneSheetDXF(), SCH_PLOTTER::plotOneSheetPDF(), SCH_PLOTTER::plotOneSheetPS(), SCH_PLOTTER::plotOneSheetSVG(), PlotStandardLayer(), SCH_PRINTOUT::PrintPage(), COLOR_SWATCH::RenderToDC(), DXF_PLOTTER::SetColor(), PCBNEW_PRINTOUT::setupPainter(), and DXF_PLOTTER::SetViewport().
      
  | 
  static | 
For legacy support; used as a value to indicate color hasn't been set yet.
Definition at line 398 of file color4d.h.
Referenced by GRAPHICS_IMPORTER_LIB_SYMBOL::AddPolygon(), GRAPHICS_IMPORTER_SCH::AddPolygon(), GERBER_LAYER_WIDGET::CollectCurrentColorSettings(), RULE_AREA_CREATE_HELPER::createNewRuleArea(), CONVERT_TOOL::CreatePolys(), PANEL_FP_EDITOR_COLOR_SETTINGS::createSwatches(), DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS(), DIALOG_JUNCTION_PROPS::DIALOG_JUNCTION_PROPS(), DIALOG_LINE_PROPERTIES::DIALOG_LINE_PROPERTIES(), DIALOG_PLOT::DIALOG_PLOT(), DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES(), DIALOG_SHEET_PIN_PROPERTIES::DIALOG_SHEET_PIN_PROPERTIES(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_WIRE_BUS_PROPERTIES::DIALOG_WIRE_BUS_PROPERTIES(), PNS_KICAD_IFACE::DisplayRatline(), DRAWING_TOOL::drawArc(), BITMAP_BASE::DrawBitmap(), LAYER_PRESENTATION::DrawColorSwatch(), DRAWING_TOOL::drawOneBezier(), DRAWING_TOOL::drawShape(), DS_DATA_ITEM_TEXT::DS_DATA_ITEM_TEXT(), EESCHEMA_SETTINGS::EESCHEMA_SETTINGS(), EDA_TEXT::Format(), DS_DATA_MODEL_IO::format(), GENDRILL_WRITER_BASE::genDrillMapFile(), SCH_BUS_ENTRY_BASE::GetBusEntryColor(), COLOR_SETTINGS::GetColor(), SCH_FIELD::GetFieldColor(), SCH_JUNCTION::GetJunctionColor(), SCH_LABEL_BASE::GetLabelColor(), LAYER_WIDGET::GetLayerColor(), SCH_LINE::GetLineColor(), COLOR_SWATCH::GetNewSwatchColor(), NETCLASS::GetPcbColor(), DIALOG_PLOT_SCHEMATIC::getPlotOptions(), LAYER_WIDGET::GetRenderColor(), NETCLASS::GetSchematicColor(), GERBVIEW_FRAME::GetVisibleElementColor(), GRResetPenAndBrush(), GRSetColorPen(), NETCLASS::HasPcbColor(), SVG_IMPORT_PLUGIN::Import(), LAYER_WIDGET::insertRenderRow(), PCB_EDIT_FRAME::LoadProjectSettings(), NET_SETTINGS::makeEffectiveNetclass(), NETCLASS::NETCLASS(), DIALOG_SHAPE_PROPERTIES::onBorderSwatch(), DIALOG_SHAPE_PROPERTIES::onFillRadioButton(), APPEARANCE_CONTROLS::onNetclassContextMenu(), PANE_ZONE_VIEWER::PANE_ZONE_VIEWER(), PANEL_EESCHEMA_EDITING_OPTIONS::PANEL_EESCHEMA_EDITING_OPTIONS(), SCH_IO_KICAD_SEXPR_PARSER::parseEDA_TEXT(), SCH_IO_KICAD_SEXPR_PARSER::parseFill(), DRAWING_SHEET_PARSER::parseText(), PCB_PLOT_PARAMS::PCB_PLOT_PARAMS(), LIB_SYMBOL::Plot(), SCH_BUS_ENTRY_BASE::Plot(), SCH_FIELD::Plot(), SCH_JUNCTION::Plot(), SCH_LABEL_BASE::Plot(), SCH_LINE::Plot(), SCH_RULE_AREA::Plot(), SCH_SHAPE::Plot(), SCH_SHEET::Plot(), SCH_TABLE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), PlotDrawingSheet(), LIB_SYMBOL::PlotFields(), plotPdfBackground(), SCH_PIN::PlotPinTexts(), SCH_PIN::PlotPinType(), PlotStandardLayer(), GRAPHICS_IMPORTER_BUFFER::PostprocessNestedPolygons(), DS_DRAW_ITEM_TEXT::PrintWsItem(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), PROPERTIES_FRAME::PROPERTIES_FRAME(), NET_GRID_TABLE::Rebuild(), APPEARANCE_CONTROLS::rebuildLayers(), APPEARANCE_CONTROLS::rebuildNets(), APPEARANCE_CONTROLS::rebuildObjects(), GERBER_LAYER_WIDGET::ReFillRender(), COLOR_SWATCH::RenderToDC(), DRAWING_TOOL::Reset(), DIALOG_JUNCTION_PROPS::resetDefaults(), DIALOG_LINE_PROPERTIES::resetDefaults(), DIALOG_WIRE_BUS_PROPERTIES::resetDefaults(), NETCLASS::ResetParameters(), LAYER_WIDGET::ROW::ROW(), LAYER_WIDGET::ROW::ROW(), SCH_IO_KICAD_LEGACY::saveLine(), SCH_BUS_BUS_ENTRY::SCH_BUS_BUS_ENTRY(), SCH_BUS_ENTRY_BASE::SCH_BUS_ENTRY_BASE(), SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY(), SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY(), SCH_JUNCTION::SCH_JUNCTION(), SCH_LINE::SCH_LINE(), SCH_SHEET::SCH_SHEET(), NETCLASS::Serialize(), SetLibShapeLine(), SCH_LINE::SetLineColor(), PCBNEW_PRINTOUT::setupViewLayers(), PANEL_COLOR_SETTINGS::ShowColorContextMenu(), DIALOG_TABLECELL_PROPERTIES::TransferDataFromWindow(), DIALOG_JUNCTION_PROPS::TransferDataToWindow(), DIALOG_LINE_PROPERTIES::TransferDataToWindow(), DIALOG_SHAPE_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PROPERTIES::TransferDataToWindow(), DIALOG_TABLECELL_PROPERTIES::TransferDataToWindow(), DIALOG_WIRE_BUS_PROPERTIES::TransferDataToWindow(), SCH_DRAG_NET_COLLISION_MONITOR::Update(), NET_GRID_TABLE::updateNetColor(), and RATSNEST_VIEW_ITEM::ViewDraw().
      
  | 
  static | 
Definition at line 401 of file color4d.h.
Referenced by BOARD_PRINTOUT::DrawPage(), SCH_RENDER_SETTINGS::GetColor(), BRDITEMS_PLOTTER::getColor(), DIALOG_COLOR_PICKER::initDefinedColors(), ZONE_CREATE_HELPER::OnFirstPoint(), PANE_ZONE_VIEWER::PANE_ZONE_VIEWER(), LIB_SYMBOL::Plot(), SCH_FIELD::Plot(), SCH_RULE_AREA::Plot(), SCH_SHAPE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_SYMBOL::PlotFields(), SCH_PIN::PlotPinTexts(), SCH_PIN::PlotPinType(), SCH_PRINTOUT::PrintPage(), APPEARANCE_CONTROLS_3D::rebuildLayers(), COLOR_SWATCH::RenderToDC(), PANEL_EESCHEMA_COLOR_SETTINGS::saveCurrentTheme(), DXF_PLOTTER::SetColor(), PSLIKE_PLOTTER::SetColor(), BOARD_PRINTOUT::setupPainter(), DIALOG_COLOR_PICKER::updatePreview(), and MY_DRAWING::ViewDraw().