This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GfColor Class Reference

Represents a color in a specific color space. More...

#include <color.h>

Public Member Functions

GF_API GfColor ()
 The default constructor creates black, in the "lin_rec709" color space.
 
GF_API GfColor (const GfColorSpace &colorSpace)
 Construct a black color in the given color space.
 
GF_API GfColor (const GfVec3f &rgb, const GfColorSpace &colorSpace)
 Construct a color from an RGB tuple and color space.
 
GF_API GfColor (const GfColor &color, const GfColorSpace &colorSpace)
 Construct a color by converting the source color into the specified color space.
 
GF_API void SetFromPlanckianLocus (float kelvin, float luminance)
 Set the color from the Planckian locus (blackbody radiation) temperature in Kelvin, in the existing color space.
 
GfVec3f GetRGB () const
 Get the RGB tuple.
 
GfColorSpace GetColorSpace () const
 Get the color space.
 
bool operator== (const GfColor &rh) const
 Equality operator.
 
bool operator!= (const GfColor &rh) const
 Inequality operator.
 

Protected Member Functions

GF_API GfVec2f _GetChromaticity () const
 
GF_API void _SetFromChromaticity (const GfVec2f &xy)
 

Protected Attributes

GfColorSpace _colorSpace
 The color space.
 
GfVec3f _rgb
 The RGB tuple.
 

Detailed Description

Represents a color in a specific color space.

Basic type: Color

The GfColor class represents a color in a specific color space. It provides various methods for constructing, manipulating, and retrieving color values.

The color values are stored as an RGB tuple and are associated with a color space. The color space determines the interpretation of the RGB values. The values are colorimetric, but not photometric as there is no normalizing constant (such as a luminance factor).

This class provides methods for setting and getting color values, converting between color spaces, normalizing luminance, and comparing colors.

Definition at line 41 of file color.h.

Constructor & Destructor Documentation

◆ GfColor() [1/4]

GF_API GfColor ( )

The default constructor creates black, in the "lin_rec709" color space.

◆ GfColor() [2/4]

GF_API GfColor ( const GfColorSpace colorSpace)
explicit

Construct a black color in the given color space.

Parameters
colorSpaceThe color space.

◆ GfColor() [3/4]

GF_API GfColor ( const GfVec3f rgb,
const GfColorSpace colorSpace 
)

Construct a color from an RGB tuple and color space.

Parameters
rgbThe RGB tuple (red, green, blue), in the color space provided.
colorSpaceThe color space.

◆ GfColor() [4/4]

GF_API GfColor ( const GfColor color,
const GfColorSpace colorSpace 
)

Construct a color by converting the source color into the specified color space.

Parameters
colorThe color to convert, in its color space.
colorSpaceThe desired color space.

Member Function Documentation

◆ GetColorSpace()

GfColorSpace GetColorSpace ( ) const
inline

Get the color space.

Returns
The color space.

Definition at line 79 of file color.h.

◆ GetRGB()

GfVec3f GetRGB ( ) const
inline

Get the RGB tuple.

Returns
The RGB tuple.

Definition at line 75 of file color.h.

◆ operator!=()

bool operator!= ( const GfColor rh) const
inline

Inequality operator.

Parameters
rThe right-hand side color.
Returns
True if the colors are not equal, false otherwise.

Definition at line 91 of file color.h.

◆ operator==()

bool operator== ( const GfColor rh) const
inline

Equality operator.

Parameters
rhThe right-hand side color.
Returns
True if the colors are equal, false otherwise.

Definition at line 84 of file color.h.

◆ SetFromPlanckianLocus()

GF_API void SetFromPlanckianLocus ( float  kelvin,
float  luminance 
)

Set the color from the Planckian locus (blackbody radiation) temperature in Kelvin, in the existing color space.

Values are computed for temperatures between 1000K and 15000K. Note that temperatures below 1900K are out of gamut for Rec709.

Parameters
kelvinThe temperature in Kelvin.
luminanceThe desired luminance.

Member Data Documentation

◆ _colorSpace

GfColorSpace _colorSpace
protected

The color space.

Definition at line 94 of file color.h.

◆ _rgb

GfVec3f _rgb
protected

The RGB tuple.

Definition at line 95 of file color.h.


The documentation for this class was generated from the following file: