Quantity
OCCT package Quantity: Quantity_Color, Quantity_ColorRGBA, Quantity_NameOfColor, Quantity_TypeOfColor.
Quantity_Color
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.
Constructors(3)
Creates Quantity_NOC_YELLOW color (for historical reasons).
- constructor(theName: Quantity_NameOfColor): Quantity_Color
Creates the color from enumeration value.
Parameters (1)theName
- constructor(theC1: number, theC2: number, theC3: number, theType: Quantity_TypeOfColor): Quantity_Color
Creates a color according to the definition system theType. Throws exception if values are out of range.
Parameters (4)theC1theC2theC3theType
Static methods(14)
- Name(theR: number, theG: number, theB: number): Quantity_NameOfColor
Returns the color from
Quantity_NameOfColorenumeration nearest to specified RGB values.Parameters (3)theRtheGtheB
- StringName(theColor: Quantity_NameOfColor): string
Returns the name of the color identified by the given
Quantity_NameOfColorenumeration value.Parameters (1)theColor
- ColorFromHex(theHexColorString: string, theColor: Quantity_Color): booleanParameters (2)
theHexColorStringtheColor
- ColorToHex(theColor: Quantity_Color, theToPrefixHash?: boolean): TCollection_AsciiStringParameters (2)
theColortheToPrefixHash
- Color2argb(theColor: Quantity_Color, theARGB: number): { theARGB: number }Parameters (2)
theColortheARGB
- Argb2color(theARGB: number, theColor: Quantity_Color): voidParameters (2)
theARGBtheColor
- Convert_LinearRGB_To_sRGB(theLinearValue: number): numberParameters (1)
theLinearValue
- Convert_sRGB_To_LinearRGB(thesRGBValue: number): numberParameters (1)
thesRGBValue
- Convert_LinearRGB_To_sRGB_approx22(theLinearValue: number): numberParameters (1)
theLinearValue
- Convert_sRGB_To_LinearRGB_approx22(thesRGBValue: number): numberParameters (1)
thesRGBValue
- HlsRgb(theH: number, theL: number, theS: number, theR: number, theG: number, theB: number): { theR: number; theG: number; theB: number }Parameters (6)
theHtheLtheStheRtheGtheB
- RgbHls(theR: number, theG: number, theB: number, theH: number, theL: number, theS: number): { theH: number; theL: number; theS: number }Parameters (6)
theRtheGtheBtheHtheLtheS
- Epsilon(): number
- SetEpsilon(theEpsilon: number): voidParameters (1)
theEpsilon
Instance methods(18)
Returns the name of the nearest color from the
Quantity_NameOfColorenumeration.- SetValues(theName: Quantity_NameOfColor): void
Updates the color from specified named color.
Parameters (1)theName
- SetValues(theC1: number, theC2: number, theC3: number, theType: Quantity_TypeOfColor): void
Updates a color according to the mode specified by theType. Throws exception if values are out of range.
Parameters (4)theC1theC2theC3theType
- Rgb(): [number, number, number]
Return the color as vector of 3 float elements.
- Red(): number
Returns the Red component (quantity of red) of the color within range [0.0; 1.0].
- Green(): number
Returns the Green component (quantity of green) of the color within range [0.0; 1.0].
- Blue(): number
Returns the Blue component (quantity of blue) of the color within range [0.0; 1.0].
- Hue(): number
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).
- Light(): number
Returns the Light component (value of the lightness) of the color within range [0.0; 1.0].
- ChangeIntensity(theDelta: number): void
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.
Parameters (1)theDelta
- Saturation(): number
Returns the Saturation component (value of the saturation) of the color within range [0.0; 1.0].
- ChangeContrast(theDelta: number): void
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.
Parameters (1)theDelta
- IsDifferent(theOther: Quantity_Color): boolean
Returns TRUE if the distance between two colors is greater than
Epsilon().Parameters (1)theOther
- IsEqual(theOther: Quantity_Color): boolean
Returns TRUE if the distance between two colors is no greater than
Epsilon().Parameters (1)theOther
- Distance(theColor: Quantity_Color): number
Returns the distance between two colors. It's a value between 0 and the square root of 3 (the black/white distance).
Parameters (1)theColor
- SquareDistance(theColor: Quantity_Color): number
Returns the square of distance between two colors.
Parameters (1)theColor
- Delta(theColor: Quantity_Color, DC: number, DI: number): { DC: number; DI: number }
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.
Parameters (3)theColorDCDI
ReturnsA result object with fields:
DC: updated value from the call.DI: updated value from the call.
- DeltaE2000(theOther: Quantity_Color): number
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).Parameters (1)theOther
Quantity_ColorRGBA
The pair of Quantity_Color and Alpha component (1.0 opaque, 0.0 transparent).
Constructors(4)
Creates a color with the default value.
- constructor(theRgb: Quantity_Color): Quantity_ColorRGBA
Creates the color with specified RGB value.
Parameters (1)theRgb
- constructor(theRgb: Quantity_Color, theAlpha: number): Quantity_ColorRGBA
Creates the color with specified RGBA values.
Parameters (2)theRgbtheAlpha
- constructor(theRed: number, theGreen: number, theBlue: number, theAlpha: number): Quantity_ColorRGBA
Creates the color from RGBA values.
Parameters (4)theRedtheGreentheBluetheAlpha
Static methods(3)
- ColorFromName(theColorNameString: string, theColor: Quantity_ColorRGBA): boolean
Finds color from predefined names. For example, the name of the color which corresponds to "BLACK" is Quantity_NOC_BLACK. An alpha component is set to 1.0.
Parameters (2)theColorNameString—the color nametheColor—a found color Mutated in place; read the updated value from this argument after the call.
Returnsfalse if the color name is unknown, or true if the search by color name was successful
- ColorFromHex(theHexColorString: string, theColor: Quantity_ColorRGBA, theAlphaComponentIsOff: boolean): boolean
Parses the string as a hex color (like "#FF0" for short sRGB color, "#FF0F" for short sRGBA color, "#FFFF00" for RGB color, or "#FFFF00FF" for RGBA color).
Parameters (3)theHexColorString—the string to be parsedtheColor—a color that is a result of parsing Mutated in place; read the updated value from this argument after the call.theAlphaComponentIsOff—the flag that indicates if a color alpha component is presented in the input string (false) or not (true)
Returnstrue if parsing was successful, or false otherwise
- ColorToHex(theColor: Quantity_ColorRGBA, theToPrefixHash?: boolean): TCollection_AsciiString
Returns hex sRGBA string in format "#RRGGBBAA".
Parameters (2)theColortheToPrefixHash
Instance methods(8)
- SetValues(theRed: number, theGreen: number, theBlue: number, theAlpha: number): void
Assign new values to the color.
Parameters (4)theRedtheGreentheBluetheAlpha
Return RGB color value.
Modify RGB color components without affecting alpha value.
- SetRGB(theRgb: Quantity_Color): void
Assign RGB color components without affecting alpha value.
Parameters (1)theRgb
- Alpha(): number
Return alpha value (1.0 means opaque, 0.0 means fully transparent).
- SetAlpha(theAlpha: number): void
Assign the alpha value.
Parameters (1)theAlpha
- IsDifferent(theOther: Quantity_ColorRGBA): boolean
Returns true if the distance between colors is greater than
Epsilon().Parameters (1)theOther
- IsEqual(theOther: Quantity_ColorRGBA): boolean
Two colors are considered to be equal if their distance is no greater than
Epsilon().Parameters (1)theOther