Class: THSVColor

Declaration: HSVColor.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TColor

Inherited By:

None.

Purpose:

THSVColor is derived from TColor. The HSV (hue, saturation, value) color model, also sometimes called HSB (with B standing for brightness), is defined in relation to the artistic concepts of tint, shade, and tone. The HSV model forms a hexcone in 3-D space. A value for V of 1.0 corresponds to relatively bright colors. The H coordinate (hue) is measured by the angle around the V axis. H =0.0 is red, 120 degrees is green, and so forth. You can obtain a color's complement by adding 180 degrees to the H value. The saturation value S is defined as a ratio ranging between 0.0 and 1.0. Saturation is measured relative to the color gamut. The HSV color model is uncalibrated; therefore, HSV 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.

Member Function: THSVColor::THSVColor

  1. THSVColor ()
  2. THSVColor (const TColor & aColor)
  3. THSVColor (TColorProfile * theDeviceColorProfile)
  4. THSVColor (GIntensity aHue, GIntensity aSaturation, GIntensity aValue, GIntensity opacity =1.0)
  5. THSVColor (const THSVColor & aHSVColor)
  6. THSVColor (TColorProfile * theDeviceColorProfile, GIntensity aHue, GIntensity aSaturation, GIntensity aValue, GIntensity opacity =1.0)

Interface Category:

API.

Purpose:

  1. Default constructor; it has the default color profile, and color components are not initialized.
  2. Creates a THSVColor from a TColor.
  3. Creates a THSVColor with the specified color profile. The color components are not initialized.
  4. Creates a THSVColor with the specified components. It has the default color profile.
  5. Copy constructor.
  6. Creates a THSVColor with the specified components and color profile.

Calling Context:

  1. Called by the stream-in operators. You can also call this function directly.
  2. Call this function directly.
  3. Call this function directly.
  4. Call this function directly.
  5. Called to copy an object. You can also call this function directly.
  6. Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Member Function: THSVColor::GetComponents

void GetComponents (GIntensity & aHue, GIntensity & aSaturation, GIntensity & aValue, GIntensity & opacity) const

Interface Category:

API.

Purpose:

Gets the components of the THSVColor.

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: THSVColor::GetClampedComponents

void GetClampedComponents (GIntensity & aHue, GIntensity & aSaturation, GIntensity & aValue, GIntensity & opacity) const

Interface Category:

API.

Purpose:

Gets the components of this THSVColor clamped between 0.0 <= N <=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: THSVColor::GetHue

GIntensity GetHue () const

Interface Category:

API.

Purpose:

Gets the hue component of this THSVColor.

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: THSVColor::GetSaturation

GIntensity GetSaturation () const

Interface Category:

API.

Purpose:

Gets the saturation component of this THSVColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the saturation component of this color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: THSVColor::GetValue

GIntensity GetValue () const

Interface Category:

API.

Purpose:

Gets the value component of this THSVColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the value component of the color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: THSVColor::GetColorDifference

GCoordinate GetColorDifference (const THSVColor & 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+(S1-S2)^2+(V1-V2)^2 ).

Calling Context:

Call this function directly.

Parameters:

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: THSVColor::SetComponents

void SetComponents (GIntensity aHue, GIntensity aSaturation, GIntensity aValue, GIntensity opacity =1.0)

Interface Category:

API.

Purpose:

Sets the components of this THSVColor with the specified values.

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: THSVColor::SetSaturation

void SetSaturation (GIntensity aSaturation)

Interface Category:

API.

Purpose:

Sets the saturation component of this THSVColor.

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: THSVColor::SetValue

void SetValue (GIntensity aValue)

Interface Category:

API.

Purpose:

Sets the value component of this THSVColor.

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: THSVColor::operatorTRGBColor

virtual operator TRGBColor () const

Interface Category:

API.

Purpose:

Casts this THSVColor to a TRGBColor.

Calling Context:

Call this operator directly.

Parameters:

Return Value:

Returns an RGBColor that corresponds with this color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: THSVColor::operatorTXYZColor

virtual operator TXYZColor () const

Interface Category:

API.

Purpose:

Casts this THSVColor to a TXYZColor.

Calling Context:

Call this operator directly.

Parameters:

Return Value:

Returns a XYZColor that corresponds with this color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: THSVColor::operator=

  1. THSVColor & operator =(const THSVColor & aSource)
  2. TColor & operator =(const TColor & aSource)

Interface Category:

API.

Purpose:

  1. Assignment operator.
  2. Assignment operator that casts the specified operand to a THSVColor.

Calling Context:

  1. Called when an object is assigned to another compatible object.
  2. Called when an object is assigned to another compatible object

Parameters:

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: THSVColor::operator+

  1. THSVColor operator + (const THSVColor & aColor2) const
  2. THSVColor operator + (const float aScalar) const

Interface Category:

API.

Purpose:

  1. Adds the components of the two THLSColors together.
  2. Adds the specified scalar to each component of this THSVColor.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

Return Value:

  1. Returns a new color with the new components.
  2. 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: THSVColor::operator-

  1. THSVColor operator -(const THSVColor & aColor2) const
  2. THSVColor operator -(const float aScalar) const

Interface Category:

API.

Purpose:

  1. Subtracts the components of the specified color from this THSVColor.
  2. Subtracts the specified scalar from each component of this THSVColor.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

Return Value:

  1. Returns a new color with the new components.
  2. 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: THSVColor::operator*

  1. THSVColor operator * (const THSVColor & aColor2) const
  2. THSVColor operator * (const float aScalar) const

Interface Category:

API.

Purpose:

  1. Multiplies the components of this THSVColor by the components of the specified color.
  2. Multiplies each component of this THSVColor by the specified scalar.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

Return Value:

  1. Returns a new color with the new components.
  2. 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: THSVColor::operator/=

THSVColor & operator /= (const float aScalar)

Interface Category:

API.

Purpose:

Divides the components of this THSVColor by the specified scalar and assigns the new values to the respective components.

Calling Context:

Call this operator directly.

Parameters:

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: THSVColor::operator+=

  1. THSVColor & operator += (const float aScalar)
  2. THSVColor & operator += (const THSVColor & aColor2)

Interface Category:

API.

Purpose:

  1. Adds the specified scalar to the components of this THSVColor and assigns the new values to the respective components.
  2. Adds the specified colors to the components of this THSVColor and assigns the new values to the respective components.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

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: THSVColor::operator-=

  1. THSVColor & operator -=(const float aScalar)
  2. THSVColor & operator -=(const THSVColor & aColor2)

Interface Category:

API.

Purpose:

  1. Subtracts the specified scalar from the components of this THSVColor and assigns the new values to the respective components.
  2. Subtracts the specified scalar from the components of this THSVColor and assigns the new values to the respective components.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

Return Value:

  1. Returns this color with the new components.
  2. 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: THSVColor::operator*=

THSVColor & operator *= (const float aScalar)

Interface Category:

API.

Purpose:

Multiplies the components of this THSVColor by the specified scalar and assigns the new values to the respective components.

Calling Context:

Call this operator directly.

Parameters:

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: THSVColor::operator/

THSVColor operator / (const float aScalar) const

Interface Category:

API.

Purpose:

Divides each component of this THSVColor by the specified scalar.

Calling Context:

Call this operator directly.

Parameters:

Return Value:

Returns this 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: THSVColor::FuzzyCompare

  1. bool FuzzyCompare (const THSVColor & aHSVColor, float acceptableErrorPerComponent =0.0001) const
  2. bool FuzzyCompare (const THSVColor & aHSVColor, float errOpacity, float errHue, float errSaturation, float errValue) const

Interface Category:

API.

Purpose:

  1. Compares this THSVColor 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.
  2. Compares this THSVColor and the specified color to a given accuracy on a component by component level.

Calling Context:

  1. Call this function directly.
  2. Call this function directly.

Parameters:

Return Value:

  1. Returns true if the two colors are equal with reference to the specified tolerance.
  2. 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: THSVColor::LinearInterpolate

void LinearInterpolate (const float aWeight, const THSVColor & aColor2)

Interface Category:

API.

Purpose:

Makes a weighted linear interpolation of each component of this THSVColor. 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 + (hue2 -hue1) * Weight.

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: THSVColor::AddAndPin

void AddAndPin (const THSVColor & aColor2)

Interface Category:

API.

Purpose:

Adds the specified color to this THSVColor 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: THSVColor::SubtractAndPin

void SubtractAndPin (const THSVColor & aColor2)

Interface Category:

API.

Purpose:

Subtracts the specified color from this THSVColor 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: THSVColor::Maximum

void Maximum (const THSVColor & aColor2)

Interface Category:

API.

Purpose:

Determines the maximum of individual components of this THSVColor and the specified color. It sets the components of this color to the resulting maximum values.

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: THSVColor::Minimum

void Minimum (const THSVColor & aColor2)

Interface Category:

API.

Purpose:

Determines the minimum of individual components of this THSVColor and the specified color. It sets the components of this color to the resulting minimum values.

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: THSVColor::Blend

void Blend (const THSVColor & aColor2)

Interface Category:

API.

Purpose:

Averages the individual components of the two colors and returns them in this THSVColor.

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: THSVColor::Invert

void Invert ()

Interface Category:

API.

Purpose:

Inverts this THSVColor.

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: THSVColor::Clamp

void Clamp ()

Interface Category:

API.

Purpose:

Clamps the components of this THSVColor 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: THSVColor::Scale

void Scale ()

Interface Category:

API.

Purpose:

Scales this THSVColor 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: THSVColor::TemporaryTypeID

virtual TemporaryColorClassID TemporaryTypeID () const

Interface Category:

API.

Purpose:

Returns TColor::kHSVColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns TColor::kHSVColor.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: THSVColor::operator<<=

virtual TStream & operator <<= (TStream &)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

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: THSVColor::operator>>=

virtual TStream & operator >>=(TStream &) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

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: THSVColor::SetHue

void SetHue (GIntensity aHue)

Interface Category:

API.

Purpose:

Sets the hue component of this THSVColor.

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: THSVColor::~THSVColor

virtual ~ THSVColor ()

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: THSVColor::ClampOpacity

void ClampOpacity ()

Interface Category:

API.

Purpose:

Pins the opacity of this THSVColor 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: THSVColor::SetOpacity

void SetOpacity (GIntensity opacity =1.0)

Interface Category:

API.

Purpose:

Sets the opacity of this THSVColor to the specified value.

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: THSVColor::GetClampedOpacity

GIntensity GetClampedOpacity () const

Interface Category:

API.

Purpose:

Returns the opacity of this THSVColor 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: THSVColor::GetOpacity

GIntensity GetOpacity () const

Interface Category:

API.

Purpose:

Returns the opacity of this THSVColor.

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.