Color paints

TColorPaint has static Get functions that give you access to various colors. This code uses the TColorPaint::GetWhite function to flush the view with a white fill color.

      void DrawContents( TGrafPort& thePort ) const
      {
          TGArea area;
          GetAllocatedArea( area );
      
          TGrafBundle aBundle( Copy ( TColorPaint::GetWhite() ), TAttributeState::kFill );
          thePort.Draw( area.GetBounds(), aBundle );
      }

Colors

TColor is the parent class to all colors in the Color framework. The color classes of greatest interest to graphics programmers are TRGBColor, TGrayColor, TXYZColor, and THSVColor.

RGB color space

So far, this manual has used TRGBColor in the examples. TRGBColor represents the red, green, and blue (RGB) color space, which is a fairly common color space that is used for most color monitors and color raster graphics systems.

The color values are type GIntensity, which gives you 32-bit precision for creating colors. You make the colors by combining red, green, and blue in various proportions as follows:

XYZ color space

TXYZ is a universal,
device-independent color space whose values are understood by everyone who works in color. All other Color framework color classes can transform into and out of this color space. Every color class has the ability to set itself equal to any other color class, and this ability enforces the transformation out of TXYZColor.

Gray scale

TGrayColor can take a single gray value such as 0.7 (which represents 70 percent gray), or you can map the values specified in any TColor instance passed to it to gray scale colors by taking the color values and converting them to a gray level.

HSV color space

THSVColor defines colors in terms of hue, saturation, and value (brightness). The hue, saturation, and value settings relate to the artistic concepts of tint, shade, and tone. You can adjust only one of the values and create different color effects. Values of THSVColor( 0,0,0 ) provide the least hue, saturation, and value (black); and values of THSVColor( 1,1,1 ) provide the greatest hue, saturation, and value (white). The values are all type GIntensity to give you 32-bit precision.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker