Class: TGrayColor

Declaration: GrayColor.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TColor

Inherited By:

None.

Purpose:

TGrayColor, derived from TColor, defines the grayscale model. Values of gray should be constrained to the range between 0.0 and 1.0, inclusive, where 0.0 is black and 1.0 is white. Member functions are provided to clamp the gray values to this range. The grayscale color model is uncalibrated; therefore, gray 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: TGrayColor::TGrayColor

  1. TGrayColor ()
  2. TGrayColor (GIntensity graylevel, GIntensity opacity =1.0)
  3. TGrayColor (const TGrayColor & color)
  4. TGrayColor (const TRGBColor & color)
  5. TGrayColor (const TColor & aColor)
  6. TGrayColor (TColorProfile * theDeviceColorProfile)
  7. TGrayColor (TColorProfile * theDeviceColorProfile, GIntensity graylevel, GIntensity opacity =1.0)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Creates a TGrayColor with the specified gray level and opacity.
  3. Copy constructor.
  4. Creates a TGrayColor from the specified TRGBColor.
  5. Creates a TGrayColor from the specified TColor.
  6. Creates a TGrayColor with the specified color profile. The color components are not initialized.
  7. Creates a TGrayColor with the specified color profile and gray level.

Calling Context:

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

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TGrayColor::~TGrayColor

virtual ~ TGrayColor ()

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: TGrayColor::GetComponents

void GetComponents (GIntensity & graylevel, GIntensity & opacity) const

Interface Category:

API.

Purpose:

Gets the components of this TGrayColor and returns them in the specified parameters.

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

void GetClampedComponents (GIntensity & graylevel, GIntensity & opacity) const

Interface Category:

API.

Purpose:

Gets the components of this TGrayColor 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: TGrayColor::GetGrayLevel

GIntensity GetGrayLevel () const

Interface Category:

API.

Purpose:

Gets the gray level of this TGrayColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the gray level of the gray color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TGrayColor::SetComponents

void SetComponents (GIntensity graylevel, GIntensity opacity =1.0)

Interface Category:

API.

Purpose:

Sets the gray level and the opacity of this TGrayColor to 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: TGrayColor::SetGrayLevel

void SetGrayLevel (GIntensity graylevel)

Interface Category:

API.

Purpose:

Sets the gray level of this TGrayColor 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: TGrayColor::operatorTRGBColor

virtual operator TRGBColor () const

Interface Category:

API.

Purpose:

Casts this TGrayColor to a TRGBColor.

Calling Context:

Call this operator directly.

Parameters:

Return Value:

Returns a TRGBColor that corresponds to this gray color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TGrayColor::operatorTXYZColor

virtual operator TXYZColor () const

Interface Category:

API.

Purpose:

Casts this TGrayColor to a TXYZColor.

Calling Context:

Call this operator directly.

Parameters:

Return Value:

Returns a TXYZColor that corresponds to this gray color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TGrayColor::operator=

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

Interface Category:

API.

Purpose:

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

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: TGrayColor::FuzzyCompare

bool FuzzyCompare (const TGrayColor & aGrayColor, float acceptableErrorPerComponent =0.0001) const

Interface Category:

API.

Purpose:

Compares this TGrayColor and the specified gray color with reference to the specified tolerance. It takes the absolute difference between the gray level of the color and compares it to the tolerance.

Calling Context:

Call this function directly.

Parameters:

Return Value:

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

virtual TStream & operator >>=(TStream & towhere) 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: TGrayColor::operator<<=

virtual TStream & operator <<= (TStream & fromwhere)

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

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

Interface Category:

API.

Purpose:

  1. Adds the components of the two TGrayColors together.
  2. Adds a scalar to the components of this TGrayColor.

Calling Context:

  1. Call this function directly.
  2. Call this function 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: TGrayColor::operator-

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

Interface Category:

API.

Purpose:

  1. Subtracts the components of the specified color from the components of this TGrayColor.
  2. Subtracts the specified scalar from the components of this TGrayColor.

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: TGrayColor::operator*

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

Interface Category:

API.

Purpose:

  1. Multiplies the components of this TGrayColor by each of the components of the specified color.
  2. Multiplies the components of this TGrayColor 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: TGrayColor::operator/

TGrayColor operator / (const float aScalar)

Interface Category:

API.

Purpose:

Divides the components of this TGrayColor by the specified scalar.

Calling Context:

Call this operator directly.

Parameters:

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

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

Interface Category:

API.

Purpose:

  1. Adds the specified scalar to the components of this TGrayColor.
  2. Adds the components of specified color and this TGrayColor together.

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

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

Interface Category:

API.

Purpose:

  1. Subtracts the specified scalar from the components of this TGrayColor.
  2. Subtracts the components of the specified gray color from the components of this TGrayColor.

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: TGrayColor::operator*=

TGrayColor & operator *= (const float aScalar)

Interface Category:

API.

Purpose:

Multiplies the components of this TGrayColor 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 color's opacity is set to 1.0.

Member Function: TGrayColor::operator/=

TGrayColor & operator /= (const float aScalar)

Interface Category:

API.

Purpose:

Divides components of this TGrayColor 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 color's opacity is set to 1.0.

Member Function: TGrayColor::LinearInterpolate

void LinearInterpolate (const float Weight, const TGrayColor & Color2)

Interface Category:

API.

Purpose:

Makes a weighted linear interpolation of the components of this TGrayColor. The interpolation is returned in this gray color. The interpolation that is done for each components (using GL as an example for gray level) given by GL1 =GL1 + (GL2 -GL1) * Weight.

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

void AddAndPin (const TGrayColor & Color2)

Interface Category:

API.

Purpose:

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

void SubtractAndPin (const TGrayColor & Color2)

Interface Category:

API.

Purpose:

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

void Maximum (const TGrayColor & Color2)

Interface Category:

API.

Purpose:

Determines the maximum of individual components of this TGrayColor 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: TGrayColor::Minimum

void Minimum (const TGrayColor & Color2)

Interface Category:

API.

Purpose:

Determines the minimum of individual components of this TGrayColor 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: TGrayColor::Blend

void Blend (const TGrayColor & Color2)

Interface Category:

API.

Purpose:

Averages the individual components of this TGrayColor and the specified color. It sets the components of this color to the resulting blend.

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

void Invert ()

Interface Category:

API.

Purpose:

Inverts this TGrayColor.

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

void Clamp ()

Interface Category:

API.

Purpose:

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

void Scale ()

Interface Category:

API.

Purpose:

Scales this TGrayColor 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:

None.

Member Function: TGrayColor::TemporaryTypeID

virtual TemporaryColorClassID TemporaryTypeID () const

Interface Category:

API.

Purpose:

Returns TColor::kGrayColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns TColor::kGrayColor.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TGrayColor::ClampOpacity

void ClampOpacity ()

Interface Category:

API.

Purpose:

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

void SetOpacity (GIntensity opacity =1.0)

Interface Category:

API.

Purpose:

Sets the opacity of this TGrayColor 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: TGrayColor::GetClampedOpacity

GIntensity GetClampedOpacity () const

Interface Category:

API.

Purpose:

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

GIntensity GetOpacity () const

Interface Category:

API.

Purpose:

Returns the opacity of this TGrayColor.

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.