Horizon
|
A color representation with 4 components: red, green, blue, alpha. More...
#include <color4d.h>
Public Member Functions | |
COLOR4D (double aRed, double aGreen, double aBlue, double aAlpha) | |
COLOR4D (EDA_COLOR_T 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. | |
void | ToHSL (double &aOutHue, double &aOutSaturation, double &aOutValue) 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 | 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. | |
int | Distance (const COLOR4D &other) const |
Returns the distance (in RGB space) between two colors. | |
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. | |
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 |
aRed | is the red component [0.0 .. 1.0]. |
aGreen | is the green component [0.0 .. 1.0]. |
aBlue | is the blue component [0.0 .. 1.0]. |
aAlpha | is the alpha value [0.0 .. 1.0]. |
COLOR4D::COLOR4D | ( | EDA_COLOR_T | aColor | ) |
aColor | is one of KiCad's palette colors. |
|
inline |
Makes the color brighter by a given factor.
aFactor | Specifies how bright the color should become (valid values: 0.0 .. 1.0). |
|
inline |
Return a color that is brighter by a given factor, without modifying object.
aFactor | Specifies how bright the color should become (valid values: 0.0 .. 1.0). |
|
inline |
Makes the color darker by a given factor.
aFactor | Specifies how dark the color should become (valid values: 0.0 .. 1.0). |
|
inline |
Return a color that is darker by a given factor, without modifying object.
aFactor | Specifies how dark the color should become (valid values: 0.0 .. 1.0). |
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.
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). |
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. |
|
inline |
Returns the brightness value of the color ranged from 0.0 to 1.0.
|
inline |
Makes the color inverted, alpha remains the same.
|
inline |
Returns an inverted color, alpha remains the same.
Return a color that is mixed with the input by a factor.
aFactor | Specifies how much of the original color to keep (valid values: 0.0 .. 1.0). |
void COLOR4D::ToHSL | ( | double & | aOutHue, |
double & | aOutSaturation, | ||
double & | aOutValue | ||
) | 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). |
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 |
|
inline |
Return a color with the same color, but the given alpha.
aAlpha | specifies the alpha of the new color |