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.
- TGrayColor ()
- TGrayColor (GIntensity graylevel, GIntensity opacity =1.0)
- TGrayColor (const TGrayColor & color)
- TGrayColor (const TRGBColor & color)
- TGrayColor (const TColor & aColor)
- TGrayColor (TColorProfile * theDeviceColorProfile)
- TGrayColor (TColorProfile * theDeviceColorProfile, GIntensity graylevel, GIntensity opacity =1.0)
Interface Category:
API.
Purpose:
- Default constructor.
- Creates a TGrayColor with the specified gray level and opacity.
- Copy constructor.
- Creates a TGrayColor from the specified TRGBColor.
- Creates a TGrayColor from the specified TColor.
- Creates a TGrayColor with the specified color profile. The color components are not initialized.
- Creates a TGrayColor with the specified color profile and gray level.
Calling Context:
- Called by the stream-in operators. You can also call this function directly.
- Call this function directly.
- Called to copy an object. You can also call this function directly.
- Call this function directly.
- Call this function directly.
- Call this function directly.
- Call this function directly.
Parameters:
- Takes no parameters.
- GIntensity graylevel -The gray level of the new gray color.
- GIntensity opacity =1.0 -The opacity of the new gray color.
- const TGrayColor & color -The gray color to be copied.
- const TRGBColor & color -The color to be converted.
- const TColor & aColor -The color to be converted.
- TColorProfile * theDeviceColorProfile -The color profile of the new gray color.
- const TColorProfile * theDeviceColorProfile -The color profile of the new gray color.
- GIntensity graylevel -The gray level of the new gray color.
- GIntensity opacity =1.0 -The opacity of the new gray color.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
None.
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:
- GIntensity & graylevel -The gray level of the gray color.
- GIntensity & opacity -The opacity of the gray color.
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:
- GIntensity & graylevel -The gray level 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: 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:
- GIntensity graylevel -The new value for the gray level.
- 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: 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:
- GIntensity graylevel -The new value for the gray level.
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=
- TGrayColor & operator =(const TGrayColor & aSource)
- TColor & operator =(const TColor & aSource)
Interface Category:
API.
Purpose:
- Assignment operator.
- Assignment operator that casts the specified operand to a TGrayColor.
Calling Context:
- Called when an object is assigned to another compatible object.
- Called when an object is assigned to another compatible object.
Parameters:
- const TGrayColor & aSource -The gray color to be copied.
- const TColor & aSource -The gray color 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: 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:
- const TGrayColor & aGrayColor -The gray color that is compared to this one.
- float acceptableErrorPerComponent =0.0001 -The tolerance with which the two gray colors are compared.
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:
- TStream & towhere -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: TGrayColor::operator<<=
virtual TStream & operator <<= (TStream & fromwhere)
Interface Category:
API.
Purpose:
Stream-in operator.
Calling Context:
Called to stream in data.
Parameters:
- TStream & fromwhere -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: TGrayColor::operator+
- TGrayColor operator + (const TGrayColor & aColor2)
- TGrayColor operator + (const float aScalar)
Interface Category:
API.
Purpose:
- Adds the components of the two TGrayColors together.
- Adds a scalar to the components of this TGrayColor.
Calling Context:
- Call this function directly.
- Call this function directly.
Parameters:
- const TGrayColor & aColor2 -The color to be added to this one.
- const float aScalar -The scalar to be added to each component of this gray 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: TGrayColor::operator-
- TGrayColor operator -(const TGrayColor & aColor2)
- TGrayColor operator -(const float aScalar)
Interface Category:
API.
Purpose:
- Subtracts the components of the specified color from the components of this TGrayColor.
- Subtracts the specified scalar from the components of this TGrayColor.
Calling Context:
- Call this operator directly.
- Call this operator directly.
Parameters:
- const TGrayColor & 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: TGrayColor::operator*
- TGrayColor operator * (const float aScalar)
- TGrayColor operator * (const TGrayColor & aColor2)
Interface Category:
API.
Purpose:
- Multiplies the components of this TGrayColor by each of the components of the specified color.
- Multiplies the components of this TGrayColor by the specified scalar.
Calling Context:
- Call this operator directly.
- Call this operator directly.
Parameters:
- const float aScalar -The multiplier.
- const TGrayColor & aColor2 -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: 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:
- 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: TGrayColor::operator+=
- TGrayColor & operator += (const float aScalar)
- TGrayColor & operator += (const TGrayColor & aColor2)
Interface Category:
API.
Purpose:
- Adds the specified scalar to the components of this TGrayColor.
- Adds the components of specified color and this TGrayColor together.
Calling Context:
- Call this operator directly.
- Call this operator directly.
Parameters:
- const float aScalar -The number to be added to the components of this color.
- const TGrayColor & aColor2 -The gray color whose components are to be added to the components of this color.
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)
- TGrayColor & operator -=(const TGrayColor & aColor2)
Interface Category:
API.
Purpose:
- Subtracts the specified scalar from the components of this TGrayColor.
- Subtracts the components of the specified gray color from the components of this TGrayColor.
Calling Context:
- Call this operator directly.
- Call this operator directly.
Parameters:
- const float aScalar -The subtrahend.
- const TGrayColor & aColor2 -The subtrahend.
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:
- 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: 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:
- 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: 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:
- const float Weight -The weight to use.
- const TGrayColor & Color2 -The gray color to be interpolated with this one.
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:
- const TGrayColor & Color2 -The gray 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: 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:
- const TGrayColor & Color2 -The gray 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: 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:
- const TGrayColor & Color2 -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: 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:
- const TGrayColor & Color2 -The gray color whose components are blended with this one.
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:
- 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: 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.