Taxonomy Categories:
Member Functions:
Interface Category:
API.
Inherits From:
TColor
Inherited By:
None.
Purpose:
THLSColor, derived from TColor, defines the HLS (hue, lightness, and saturation) color model. The HLS color model is defined by a double hexcone in 3-D space. Hue is measured by the angle around the L axis. Red occurs at H =0.0. Transversing the perimeter in a counterclockwise direction yields: red, yellow, green, cyan, blue, and magenta. You can obtain a color's complement by adding 180 degrees to the H value. Saturation is measured radially from the vertical axis, ranging from 0.0 to 1.0. Lightness is 0 for black (at the bottom of ghd double hexcone) to 1.0 (at the top of the hexcone).
The HLS color model is uncalibrated; therefore, HLS colors must be defined with respect to a particular color device through a color profile.
The class provides arithmetic operators that operate on two colors.
Instantiation:
Allocate on the heap or the stack.
Deriving Classes:
Derive new color models from TColor.
Concurrency:
Multithread safe.
Resource Use:
No special requirements.
- THLSColor ()
- THLSColor (const TColor & aColor)
- THLSColor (TColorProfile * theDeviceColorProfile)
- THLSColor (GIntensity aHue, GIntensity aLightness, GIntensity aSaturation, GIntensity opacity =1.0)
- THLSColor (const THLSColor & aHLSColor)
- THLSColor (TColorProfile * theDeviceColorProfile, GIntensity aHue, GIntensity aLightness, GIntensity aSaturation, GIntensity opacity =1.0)
Interface Category:
API.
Purpose:
- Default constructor; it has the default color profile, and color components are not initialized.
- Creates a THLSColor from a TColor.
- Creates a THLSColor with the specified color profile. The color components are not initialized.
- Creates a THLSColor with the specified components. It has the default color profile.
- Copy constructor.
- Creates a THLSColor with the specified components and color profile.
Calling Context:
- Called by the stream-in operators. You can also call this function directly.
- Call this function directly.
- Call this function directly.
- Call this function directly.
- Called to copy an object. You can also call this function directly.
- Call this function directly.
Parameters:
- Takes no parameters.
- const TColor & aColor -The color to be copied.
- TColorProfile * theDeviceColorProfile -The color profile for the new color.
- GIntensity aHue -The hue component of the new color.
- GIntensity aLightness -The lightness component of the new color.
- GIntensity aSaturation -The saturation component of the new color.
- GIntensity opacity =1.0 -The opacity of the new color.
- const THLSColor & aHLSColor -The color to be copied.
- TColorProfile * theDeviceColorProfile -The color profile for the new color.
- GIntensity aHue -The hue component of the new color.
- GIntensity aLightness -The lightness component of the new color.
- GIntensity aSaturation -The saturation component of the new color.
- GIntensity opacity =1.0 -The opacity of the new color.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Member Function: THLSColor::GetComponents
void GetComponents (GIntensity & aHue, GIntensity & aLightness, GIntensity & aSaturation, GIntensity & opacity) const
Interface Category:
API.
Purpose:
Gets the components of the THLSColor.
Calling Context:
Call this function directly.
Parameters:
- GIntensity & aHue -The hue component of this color.
- GIntensity & aLightness -The lightness component of this color.
- GIntensity & aSaturation -The saturation component of this color.
- GIntensity & opacity -The opacity of this color.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::GetClampedComponents
void GetClampedComponents (GIntensity & aHue, GIntensity & aLightness, GIntensity & aSaturation, GIntensity & opacity) const
Interface Category:
API.
Purpose:
Gets the components of this THLSColor clamped between 0.0 <= N <=1.0.
Calling Context:
Call this function directly.
Parameters:
- GIntensity & aHue -The clamped hue component of this color.
- GIntensity & aLightness -The clamped lightness component of this color.
- GIntensity & aSaturation -The clamped saturation component of this color.
- GIntensity & opacity -The clamped opacity of this color.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::GetHue
GIntensity GetHue () const
Interface Category:
API.
Purpose:
Gets the hue component of this THLSColor.
Calling Context:
Call this function directly.
Parameters:
Return Value:
Returns the hue component of the color.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::GetLightness
GIntensity GetLightness () const
Interface Category:
API.
Purpose:
Gets the lightness component of this THLSColor.
Calling Context:
Call this function directly.
Parameters:
Return Value:
Returns the lightness component of the color.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::GetSaturation
GIntensity GetSaturation () const
Interface Category:
API.
Purpose:
Gets the saturation component of this THLSColor.
Calling Context:
Call this function directly.
Parameters:
Return Value:
Returns the saturation component of the color.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::GetColorDifference
GCoordinate GetColorDifference (const THLSColor & aColor2) const
Interface Category:
API.
Purpose:
Calculates the color difference between this THLSColor and the specified one. The color difference is defined as the sqrt( (H1-H2)^2+(L1-L2)^2+(S1-S2)^2 ).
Calling Context:
Call this function directly.
Parameters:
- const THLSColor & aColor2 -The color with which the difference is computed.
Return Value:
The value of the color difference between the two colors.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::SetComponents
void SetComponents (GIntensity aHue, GIntensity aLightness, GIntensity aSaturation, GIntensity opacity =1.0)
Interface Category:
API.
Purpose:
Sets the components of this THLSColor.
Calling Context:
Call this function directly.
Parameters:
- GIntensity aHue -The new value for the hue component.
- GIntensity aLightness -The new value for the lightness component.
- GIntensity aSaturation -The new value for the saturation component.
- GIntensity opacity =1.0 -The new value for the opacity.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::SetLightness
void SetLightness (GIntensity aLightness)
Interface Category:
API.
Purpose:
Sets the lightness component of this THLSColor.
Calling Context:
Call this function directly.
Parameters:
- GIntensity aLightness -The new value for the lightness component.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::SetSaturation
void SetSaturation (GIntensity aSaturation)
Interface Category:
API.
Purpose:
Sets the saturation component of this THLSColor.
Calling Context:
Call this function directly.
Parameters:
- GIntensity aSaturation -The new value for the saturation component.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::operatorTRGBColor
virtual operator TRGBColor () const
Interface Category:
API.
Purpose:
Casts the THLSColor to a TRGBColor.
Calling Context:
Call this function directly.
Parameters:
Return Value:
Returns a TRGBColor that corresponds to this color.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::operatorTXYZColor
virtual operator TXYZColor () const
Interface Category:
API.
Purpose:
Casts the THLSColor into a TXYZColor.
Calling Context:
Call this function directly.
Parameters:
Return Value:
Returns a TXYZColor that corresponds to this color.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::operator=
- THLSColor & operator =(const THLSColor & aSource)
- TColor & operator =(const TColor & aSource)
Interface Category:
API.
Purpose:
- Assignment operator.
- Assignment operator that casts the specified operand to a THLSColor.
Calling Context:
- Called when an object is assigned to another compatible object.
- Called when an object is assigned to another compatible object.
Parameters:
- const THLSColor & aSource -The object to be copied.
- const TColor & aSource -The object to be converted and copied.
Return Value:
A non-const reference to the left-hand side object.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::operator+
- THLSColor operator + (const THLSColor & aColor2) const
- THLSColor operator + (const float aScalar) const
Interface Category:
API.
Purpose:
- Adds the components of the two THLSColors together.
- Adds the specified scalar to each component of this THLSColor.
Calling Context:
- Call this operator directly.
- Call this operator directly.
Parameters:
- const THLSColor & aColor2 -The color to be added to this one.
- const float aScalar -The scalar to be added to each component of this color.
Return Value:
- Returns a new color with the new components.
- Returns a new color with the new components.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The values of the components are not clamped to the range 0.0 <= N <= 1.0.
Member Function: THLSColor::operator-
- THLSColor operator -(const THLSColor & aColor2) const
- THLSColor operator -(const float aScalar) const
Interface Category:
API.
Purpose:
- Subtracts the components of the specified color from this THLSColor.
- Subtracts the specified scalar from each component of this THLSColor.
Calling Context:
- Call this operator directly.
- Call this operator directly.
Parameters:
- const THLSColor & aColor2 -The subtrahend.
- const float aScalar -The subtrahend.
Return Value:
- Returns a new color with the new components.
- Returns a new color with the new components.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The values of the components are not clamped to the range 0.0 <= N <= 1.0.
Member Function: THLSColor::operator*
- THLSColor operator * (const THLSColor & aColor2) const
- THLSColor operator * (const float aScalar) const
Interface Category:
API.
Purpose:
- Multiplies the components of this THLSColor by the components of the specified color.
- Multiplies each component of this THLSColor by the specified scalar.
Calling Context:
- Call this operator directly.
- Call this operator directly.
Parameters:
- const THLSColor & aColor2 -The multiplier.
- const float aScalar -The multiplier.
Return Value:
- Returns a new color with the new components.
- Returns a new color with the new components.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The values of the components are not clamped to the range 0.0 <= N <= 1.0.
Member Function: THLSColor::operator/=
THLSColor & operator /= (const float aScalar)
Interface Category:
API.
Purpose:
Divides the components of this THLSColor by the specified scalar and assigns the new values to the respective components.
Calling Context:
Call this operator directly.
Parameters:
- const float aScalar -The divisor.
Return Value:
Returns this color with the new components.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::operator+=
- THLSColor & operator += (const float aScalar)
- THLSColor & operator += (const THLSColor & aColor2)
Interface Category:
API.
Purpose:
- Adds the specified scalar to the components of this THLSColor and assigns the new values to the respective components.
- Adds the specified colors to the components of this THLSColor and assigns the new values to the respective components.
Calling Context:
- Call this operator directly.
- Call this operator directly.
Parameters:
- const float aScalar -The number to be added to this color.
- const THLSColor & aColor2 -The color to be added to this color.
Return Value:
- Returns this color with the new components.
- Returns this color with the new components.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::operator-=
- THLSColor & operator -=(const float aScalar)
- THLSColor & operator -=(const THLSColor & aColor2)
Interface Category:
API.
Purpose:
- Subtracts the specified scalar from the components of this THLSColor and assigns the new values to the respective components.
- Subtracts the specified scalar from the components of this THLSColor and assigns the new values to the respective components.
Calling Context:
- Call this operator directly.
- Call this operator directly.
Parameters:
- const float aScalar -The subtrahend.
- const THLSColor & aColor2 -The subtrahend.
Return Value:
- Returns this color with the new components.
- Returns this color with the new components.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::operator*=
THLSColor & operator *= (const float aScalar)
Interface Category:
API.
Purpose:
Multiplies the components of this THLSColor by the specified scalar and assigns the new values to the respective components.
Calling Context:
Call this operator directly.
Parameters:
- const float aScalar -The multiplier.
Return Value:
Returns this color with the new components.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::operator/
THLSColor operator / (const float aScalar) const
Interface Category:
API.
Purpose:
Divides each component of this THLSColor by the specified scalar.
Calling Context:
Call this operator directly.
Parameters:
- const float aScalar -The divisor.
Return Value:
Returns a color with the new components.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The values of the components are not clamped to the range 0.0 <= N <= 1.0.
Member Function: THLSColor::FuzzyCompare
- bool FuzzyCompare (const THLSColor & aHLSColor, float acceptableErrorPerComponent =0.0001) const
- bool FuzzyCompare (const THLSColor & aHLSColor, float errOpacity, float errHue, float errLightness, float errSaturation) const
Interface Category:
API.
Purpose:
- Compares this THLSColor and the specified color with reference to the specified tolerance. It takes the absolute difference between the components of the color and compares them to a known value.
- Compares this THLSColor and the specified color to a given accuracy on a component by component level.
Calling Context:
- Call this function directly.
- Call this function directly.
Parameters:
- const THLSColor & aHLSColor -The color that is compared to this one.
- float acceptableErrorPerComponent =0.0001 -The tolerance with which the two colors are compared.
- const THLSColor & aHLSColor -The color that is compared to this color.
- float errOpacity -The tolerance with which the opacities of the two colors are compared.
- float errHue -The tolerance with which the hue components of the two colors are compared.
- float errLightness -The tolerance with which the lightness components of the two colors are compared.
- float errSaturation -The tolerance with which the saturation components of the two colors are compared.
Return Value:
- Returns true if the two colors are equal with reference to the specified tolerance.
- Returns true if the two colors are equal with reference to the specified tolerance.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::LinearInterpolate
void LinearInterpolate (const float aWeight, const THLSColor & aColor2)
Interface Category:
API.
Purpose:
Makes a weighted linear interpolation of each component of this THLSColor. The interpolation is returned in this color.
The interpolation that is done for each component is (using hue as an example) given by hue1 =hue1 + (hue1 -hue2) * Weight.
Calling Context:
Call this function directly.
Parameters:
- const float aWeight -The weight to use.
- const THLSColor & aColor2 -The color to be interpolated with this one.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::AddAndPin
void AddAndPin (const THLSColor & aColor2)
Interface Category:
API.
Purpose:
Adds the specified color to this THLSColor and then clamps the resulting values of the components.
Calling Context:
Call this function directly.
Parameters:
- const THLSColor & aColor2 -The color to be added to this one.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::SubtractAndPin
void SubtractAndPin (const THLSColor & aColor2)
Interface Category:
API.
Purpose:
Subtracts the specified color from this THLSColor and then clamps the resulting values of the components.
Calling Context:
Call this function directly.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::Maximum
void Maximum (const THLSColor & aColor2)
Interface Category:
API.
Purpose:
Determines the maximum of individual components of this THLSColor and the specified color. It sets the components of this color to the resulting maximum values.
Calling Context:
Call this function directly.
Parameters:
- const THLSColor & aColor2 -The color whose components are compared with this one.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::Minimum
void Minimum (const THLSColor & aColor2)
Interface Category:
API.
Purpose:
Determines the minimum of individual components of this THLSColor and the specified color. It sets the components of this color to the resulting minimum values.
Calling Context:
Call this function directly.
Parameters:
- const THLSColor & aColor2 -The color whose components are compared with this one.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::Blend
void Blend (const THLSColor & aColor2)
Interface Category:
API.
Purpose:
Averages the individual components of the two colors and returns them in this THLSColor.
Calling Context:
Call this function directly.
Parameters:
- const THLSColor & aColor2 -The color to be blended with this one.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::Invert
void Invert ()
Interface Category:
API.
Purpose:
Inverts the THLSColor.
Calling Context:
Call this function directly.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::Clamp
void Clamp ()
Interface Category:
API.
Purpose:
Clamps the components of this THLSColor between 0.0 <= N <= 1.0. If a value is less than 0.0, it is set to 0.0, and if it is greater than 1.0, it is set to 1.0.
Calling Context:
Call this function directly.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::Scale
void Scale ()
Interface Category:
API.
Purpose:
Scales this THLSColor to 1.0. If all of the color's components are between 0.0 <= N <= 1.0, the color is untouched. If there are components with values greater than 1.0, then the largest component is used to renormalize the color.
If any of the color's components are less than 0.0, they set to 0.0.
Calling Context:
Call this function directly.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
The color's opacity is set to 1.0.
Member Function: THLSColor::TemporaryTypeID
virtual TemporaryColorClassID TemporaryTypeID () const
Interface Category:
API.
Purpose:
Returns TColor::kHLSColor.
Calling Context:
Call this function directly.
Parameters:
Return Value:
Returns TColor::kHLSColor.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::operator<<=
virtual TStream & operator <<= (TStream &)
Interface Category:
API.
Purpose:
Stream-in operator.
Calling Context:
Called to stream in data.
Parameters:
- TStream & -The stream that the object's data is streamed in from.
Return Value:
Returns a reference to the stream the object streams itself in from.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::operator>>=
virtual TStream & operator >>=(TStream &) const
Interface Category:
API.
Purpose:
Stream-out operator.
Calling Context:
Called to stream out data.
Parameters:
- TStream & -The stream that the object's data is streamed out to.
Return Value:
Returns a reference to the stream the object streams itself out to.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::SetHue
void SetHue (GIntensity aHue)
Interface Category:
API.
Purpose:
Sets the hue component of this THLSColor.
Calling Context:
Call this function directly.
Parameters:
- GIntensity aHue -The new value for the hue component.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
virtual ~ THLSColor ()
Interface Category:
API.
Purpose:
Destructor.
Calling Context:
Called to destroy an object.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::ClampOpacity
void ClampOpacity ()
Interface Category:
API.
Purpose:
Pins the opacity of this THLSColor to the range 0.0 to 1.0.
Calling Context:
Call this function directly.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::SetOpacity
void SetOpacity (GIntensity opacity =1.0)
Interface Category:
API.
Purpose:
Sets the opacity of this THLSColor to the specified value.
Calling Context:
Call this function directly.
Parameters:
- GIntensity opacity =1.0 -The new value for the opacity.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::GetClampedOpacity
GIntensity GetClampedOpacity () const
Interface Category:
API.
Purpose:
Returns the opacity of this THLSColor and pins the value to the range 0.0 to 1.0.
Calling Context:
Call this function directly.
Parameters:
Return Value:
The clamped opacity.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Member Function: THLSColor::GetOpacity
GIntensity GetOpacity () const
Interface Category:
API.
Purpose:
Returns the opacity of this THLSColor.
Calling Context:
Call this function directly.
Parameters:
Return Value:
The opacity that can be outside the range 0.0 to 1.0.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.