This class allows the definition of an RGB color as triplet of 3 normalized floating point values (red, green, blue).
More...
|
| Quantity_Color () |
| Creates Quantity_NOC_YELLOW color (for historical reasons).
|
|
| Quantity_Color (const Quantity_NameOfColor theName) |
| Creates the color from enumeration value.
|
|
| Quantity_Color (const Standard_Real theC1, const Standard_Real theC2, const Standard_Real theC3, const Quantity_TypeOfColor theType) |
| Creates a color according to the definition system theType. Throws exception if values are out of range.
|
|
| Quantity_Color (const NCollection_Vec3< float > &theRgb) |
| Define color from linear RGB values.
|
|
Quantity_NameOfColor | Name () const |
| Returns the name of the nearest color from the Quantity_NameOfColor enumeration.
|
|
void | SetValues (const Quantity_NameOfColor theName) |
| Updates the color from specified named color.
|
|
const NCollection_Vec3< float > & | Rgb () const |
| Return the color as vector of 3 float elements.
|
|
| operator const NCollection_Vec3< float > & () const |
| Return the color as vector of 3 float elements.
|
|
void | Values (Standard_Real &theC1, Standard_Real &theC2, Standard_Real &theC3, const Quantity_TypeOfColor theType) const |
| Returns in theC1, theC2 and theC3 the components of this color according to the color system definition theType.
|
|
void | SetValues (const Standard_Real theC1, const Standard_Real theC2, const Standard_Real theC3, const Quantity_TypeOfColor theType) |
| Updates a color according to the mode specified by theType. Throws exception if values are out of range.
|
|
Standard_Real | Red () const |
| Returns the Red component (quantity of red) of the color within range [0.0; 1.0].
|
|
Standard_Real | Green () const |
| Returns the Green component (quantity of green) of the color within range [0.0; 1.0].
|
|
Standard_Real | Blue () const |
| Returns the Blue component (quantity of blue) of the color within range [0.0; 1.0].
|
|
Standard_Real | Hue () const |
| Returns the Hue component (hue angle) of the color in degrees within range [0.0; 360.0], 0.0 being Red. -1.0 is a special value reserved for grayscale color (S should be 0.0)
|
|
Standard_Real | Light () const |
| Returns the Light component (value of the lightness) of the color within range [0.0; 1.0].
|
|
void | ChangeIntensity (const Standard_Real theDelta) |
| Increases or decreases the intensity (variation of the lightness). The delta is a percentage. Any value greater than zero will increase the intensity. The variation is expressed as a percentage of the current value.
|
|
Standard_Real | Saturation () const |
| Returns the Saturation component (value of the saturation) of the color within range [0.0; 1.0].
|
|
void | ChangeContrast (const Standard_Real theDelta) |
| Increases or decreases the contrast (variation of the saturation). The delta is a percentage. Any value greater than zero will increase the contrast. The variation is expressed as a percentage of the current value.
|
|
Standard_Boolean | IsDifferent (const Quantity_Color &theOther) const |
| Returns TRUE if the distance between two colors is greater than Epsilon().
|
|
Standard_Boolean | operator!= (const Quantity_Color &theOther) const |
| Alias to IsDifferent().
|
|
Standard_Boolean | IsEqual (const Quantity_Color &theOther) const |
| Returns TRUE if the distance between two colors is no greater than Epsilon().
|
|
Standard_Boolean | operator== (const Quantity_Color &theOther) const |
| Alias to IsEqual().
|
|
Standard_Real | Distance (const Quantity_Color &theColor) const |
| Returns the distance between two colors. It's a value between 0 and the square root of 3 (the black/white distance).
|
|
Standard_Real | SquareDistance (const Quantity_Color &theColor) const |
| Returns the square of distance between two colors.
|
|
void | Delta (const Quantity_Color &theColor, Standard_Real &DC, Standard_Real &DI) const |
| Returns the percentage change of contrast and intensity between this and another color. <DC> and <DI> are percentages, either positive or negative. The calculation is with respect to this color. If <DC> is positive then <me> is more contrasty. If <DI> is positive then <me> is more intense.
|
|
Standard_Real | DeltaE2000 (const Quantity_Color &theOther) const |
| Returns the value of the perceptual difference between this color and theOther , computed using the CIEDE2000 formula. The difference is in range [0, 100.], with 1 approximately corresponding to the minimal perceivable difference (usually difference 5 or greater is needed for the difference to be recognizable in practice).
|
|
|
void | DumpJson (Standard_OStream &theOStream, Standard_Integer theDepth=-1) const |
| Dumps the content of me into the stream.
|
|
Standard_Boolean | InitFromJson (const Standard_SStream &theSStream, Standard_Integer &theStreamPos) |
| Inits the content of me from the stream.
|
|
static bool | ColorFromHex (const Standard_CString theHexColorString, Quantity_Color &theColor) |
| Parses the string as a hex color (like "#FF0" for short sRGB color, or "#FFFF00" for sRGB color)
|
|
static TCollection_AsciiString | ColorToHex (const Quantity_Color &theColor, const bool theToPrefixHash=true) |
| Returns hex sRGB string in format "#FFAAFF".
|
|
static NCollection_Vec3< float > | Convert_sRGB_To_HLS (const NCollection_Vec3< float > &theRgb) |
| Converts sRGB components into HLS ones.
|
|
static NCollection_Vec3< float > | Convert_HLS_To_sRGB (const NCollection_Vec3< float > &theHls) |
| Converts HLS components into RGB ones.
|
|
static NCollection_Vec3< float > | Convert_LinearRGB_To_HLS (const NCollection_Vec3< float > &theRgb) |
| Converts Linear RGB components into HLS ones.
|
|
static NCollection_Vec3< float > | Convert_HLS_To_LinearRGB (const NCollection_Vec3< float > &theHls) |
| Converts HLS components into linear RGB ones.
|
|
static NCollection_Vec3< float > | Convert_LinearRGB_To_Lab (const NCollection_Vec3< float > &theRgb) |
| Converts linear RGB components into CIE Lab ones.
|
|
static NCollection_Vec3< float > | Convert_Lab_To_Lch (const NCollection_Vec3< float > &theLab) |
| Converts CIE Lab components into CIE Lch ones.
|
|
static NCollection_Vec3< float > | Convert_Lab_To_LinearRGB (const NCollection_Vec3< float > &theLab) |
| Converts CIE Lab components into linear RGB ones. Note that the resulting values may be out of the valid range for RGB.
|
|
static NCollection_Vec3< float > | Convert_Lch_To_Lab (const NCollection_Vec3< float > &theLch) |
| Converts CIE Lch components into CIE Lab ones.
|
|
static void | Color2argb (const Quantity_Color &theColor, Standard_Integer &theARGB) |
| Convert the color value to ARGB integer value, with alpha equals to 0. So the output is formatted as 0x00RRGGBB. Note that this unpacking does NOT involve non-linear sRGB -> linear RGB conversion, as would be usually expected for RGB color packed into 4 bytes.
|
|
static void | Argb2color (const Standard_Integer theARGB, Quantity_Color &theColor) |
| Convert integer ARGB value to Color. Alpha bits are ignored. Note that this packing does NOT involve linear -> non-linear sRGB conversion, as would be usually expected to preserve higher (for human eye) color precision in 4 bytes.
|
|
static Standard_Real | Convert_LinearRGB_To_sRGB (Standard_Real theLinearValue) |
| Convert linear RGB component into sRGB using OpenGL specs formula (double precision), also known as gamma correction.
|
|
static float | Convert_LinearRGB_To_sRGB (float theLinearValue) |
| Convert linear RGB component into sRGB using OpenGL specs formula (single precision), also known as gamma correction.
|
|
static Standard_Real | Convert_sRGB_To_LinearRGB (Standard_Real thesRGBValue) |
| Convert sRGB component into linear RGB using OpenGL specs formula (double precision), also known as gamma correction.
|
|
static float | Convert_sRGB_To_LinearRGB (float thesRGBValue) |
| Convert sRGB component into linear RGB using OpenGL specs formula (single precision), also known as gamma correction.
|
|
template<typename T > |
static NCollection_Vec3< T > | Convert_LinearRGB_To_sRGB (const NCollection_Vec3< T > &theRGB) |
| Convert linear RGB components into sRGB using OpenGL specs formula.
|
|
template<typename T > |
static NCollection_Vec3< T > | Convert_sRGB_To_LinearRGB (const NCollection_Vec3< T > &theRGB) |
| Convert sRGB components into linear RGB using OpenGL specs formula.
|
|
static float | Convert_LinearRGB_To_sRGB_approx22 (float theLinearValue) |
| Convert linear RGB component into sRGB using approximated uniform gamma coefficient 2.2.
|
|
static float | Convert_sRGB_To_LinearRGB_approx22 (float thesRGBValue) |
| Convert sRGB component into linear RGB using approximated uniform gamma coefficient 2.2.
|
|
static NCollection_Vec3< float > | Convert_LinearRGB_To_sRGB_approx22 (const NCollection_Vec3< float > &theRGB) |
| Convert linear RGB components into sRGB using approximated uniform gamma coefficient 2.2.
|
|
static NCollection_Vec3< float > | Convert_sRGB_To_LinearRGB_approx22 (const NCollection_Vec3< float > &theRGB) |
| Convert sRGB components into linear RGB using approximated uniform gamma coefficient 2.2.
|
|
static void | HlsRgb (const Standard_Real theH, const Standard_Real theL, const Standard_Real theS, Standard_Real &theR, Standard_Real &theG, Standard_Real &theB) |
| Converts HLS components into sRGB ones.
|
|
static void | RgbHls (const Standard_Real theR, const Standard_Real theG, const Standard_Real theB, Standard_Real &theH, Standard_Real &theL, Standard_Real &theS) |
| Converts sRGB components into HLS ones.
|
|
static Standard_Real | Epsilon () |
| Returns the value used to compare two colors for equality; 0.0001 by default.
|
|
static void | SetEpsilon (const Standard_Real theEpsilon) |
| Set the value used to compare two colors for equality.
|
|
This class allows the definition of an RGB color as triplet of 3 normalized floating point values (red, green, blue).
Although Quantity_Color can be technically used for pass-through storage of RGB triplet in any color space, other OCCT interfaces taking/returning Quantity_Color would expect them in linear space. Therefore, take a look into methods converting to and from non-linear sRGB color space, if needed; for instance, application usually providing color picking within 0..255 range in sRGB color space.