HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Color Class Reference

#include <UT_Color.h>

Public Member Functions

 UT_Color ()
 
 UT_Color (UT_ColorType t)
 
 UT_Color (UT_ColorType t, fpreal x, fpreal y, fpreal z)
 
 UT_Color (const UT_Color &c)
 
 UT_Color (const char *colorname)
 
 ~UT_Color ()
 
UT_ColorType getType () const
 
void getValue (float &x, float &y, float &z) const
 
void getValue (fpreal64 &x, fpreal64 &y, fpreal64 &z) const
 
void getRGB (float *r, float *g, float *b) const
 
void getHSV (float *h, float *s, float *v) const
 
void getHSL (float *h, float *s, float *l) const
 
void getXYZ (float *x, float *y, float *z) const
 
void getLAB (float *l, float *a, float *b) const
 
void getTMI (float *t, float *m, float *i) const
 
void getColor (UT_Color &c) const
 
UT_Vector3F rgb () const
 
void setRGB (UT_Vector3F c)
 
void setRGB (UT_Vector3D c)
 
fpreal luminance () const
 
fpreal relativeLuminance () const
 
void setType (UT_ColorType t)
 
void setValue (fpreal x, fpreal y, fpreal z)
 
void setRGB (fpreal r, fpreal g, fpreal b)
 
void setHSV (fpreal h, fpreal s, fpreal v)
 
void setHSL (fpreal h, fpreal s, fpreal l)
 
void setXYZ (fpreal x, fpreal y, fpreal z)
 
void setLAB (fpreal l, fpreal a, fpreal b)
 
void setLABluminance (fpreal l)
 
void setTMI (fpreal t, fpreal m, fpreal i)
 
void setUnique (int64 idx)
 
void setColorByName (const char *colorname)
 
void clampToLegal ()
 
void ghost (fpreal gfactor=0.75f)
 
UT_Color copyGhosted (fpreal gfactor=0.75f) const
 
void operator= (const UT_Color &c)
 
int operator== (const UT_Color &color) const
 
int operator!= (const UT_Color &c) const
 
bool operator< (const UT_Color &b) const
 
uint32 hash () const
 
void brighten (fpreal amount)
 
void tintRGB (const UT_Color &clr)
 
void addHSV (const UT_Color &clr)
 
void addRGB (const UT_Color &clr)
 
void subRGB (const UT_Color &clr)
 
UT_Color copyWithGamma (fpreal gamma) const
 
void gamma (fpreal gamma)
 
void blendRGB (const UT_Color &clr, fpreal bias=0.5)
 
int save (std::ostream &os, int binary) const
 
void saveMinimalAsText (std::ostream &os) const
 
bool load (UT_IStream &is)
 
const char * className () const
 
bool save (UT_JSONWriter &w) const
 
bool save (UT_JSONValue &v) const
 
bool load (UT_JSONParser &p)
 

Static Public Member Functions

static void getRampColor (UT_ColorRamp ramp, fpreal val, float *r, float *g, float *b)
 Computes a ramp colour from the predefined ramp enums. More...
 
static const char * getRampColorName (UT_ColorRamp ramp)
 Return the name of the ramp colour. More...
 
static UT_RampbuildRamp (UT_ColorRamp ramp)
 Builds a UT_Ramp to correspond to the given internal ramp. More...
 
static UT_RampbuildMonoRamp (UT_MonoRamp ramp)
 
static void getUniqueColor (int64 idx, float *r, float *g, float *b)
 
static const UT_ColorgetConstantColor (int i)
 
static void getRandomContrastingColor (const UT_Vector3 *contrast_to, unsigned color_index, UT_Vector3 &color)
 

Protected Member Functions

void convertToType (UT_ColorType type)
 
void convertToHSL ()
 
void convertToHSV ()
 
void convertToRGB ()
 
void convertToXYZ ()
 
void convertToLAB ()
 
void convertToTMI ()
 
void getRGBConvert (float *r, float *g, float *b) const
 

Static Protected Member Functions

static void assignRandomLuminance (UT_Vector3 &color)
 

Protected Attributes

UT_ColorType type
 
float u
 
float v
 
float w
 

Friends

UT_API std::ostream & operator<< (std::ostream &os, const UT_Color &color)
 

Detailed Description

Constructor & Destructor Documentation

UT_Color::UT_Color ( )
UT_Color::UT_Color ( UT_ColorType  t)
UT_Color::UT_Color ( UT_ColorType  t,
fpreal  x,
fpreal  y,
fpreal  z 
)
UT_Color::UT_Color ( const UT_Color c)
UT_Color::UT_Color ( const char *  colorname)
explicit
UT_Color::~UT_Color ( )

Member Function Documentation

void UT_Color::addHSV ( const UT_Color clr)
void UT_Color::addRGB ( const UT_Color clr)
static void UT_Color::assignRandomLuminance ( UT_Vector3 color)
staticprotected
void UT_Color::blendRGB ( const UT_Color clr,
fpreal  bias = 0.5 
)
void UT_Color::brighten ( fpreal  amount)
static UT_Ramp* UT_Color::buildMonoRamp ( UT_MonoRamp  ramp)
static
static UT_Ramp* UT_Color::buildRamp ( UT_ColorRamp  ramp)
static

Builds a UT_Ramp to correspond to the given internal ramp.

void UT_Color::clampToLegal ( )
const char* UT_Color::className ( void  ) const
inline

Definition at line 182 of file UT_Color.h.

void UT_Color::convertToHSL ( )
protected
void UT_Color::convertToHSV ( )
protected
void UT_Color::convertToLAB ( )
protected
void UT_Color::convertToRGB ( )
protected
void UT_Color::convertToTMI ( )
protected
void UT_Color::convertToType ( UT_ColorType  type)
protected
void UT_Color::convertToXYZ ( )
protected
UT_Color UT_Color::copyGhosted ( fpreal  gfactor = 0.75f) const
UT_Color UT_Color::copyWithGamma ( fpreal  gamma) const
void UT_Color::gamma ( fpreal  gamma)
void UT_Color::getColor ( UT_Color c) const
inline

Definition at line 113 of file UT_Color.h.

static const UT_Color& UT_Color::getConstantColor ( int  i)
static
void UT_Color::getHSL ( float *  h,
float *  s,
float *  l 
) const
void UT_Color::getHSV ( float *  h,
float *  s,
float *  v 
) const
void UT_Color::getLAB ( float *  l,
float *  a,
float *  b 
) const
static void UT_Color::getRampColor ( UT_ColorRamp  ramp,
fpreal  val,
float *  r,
float *  g,
float *  b 
)
static

Computes a ramp colour from the predefined ramp enums.

static const char* UT_Color::getRampColorName ( UT_ColorRamp  ramp)
static

Return the name of the ramp colour.

static void UT_Color::getRandomContrastingColor ( const UT_Vector3 contrast_to,
unsigned  color_index,
UT_Vector3 color 
)
static

Obtain a random color that is contrasting to the specified other color. If null is passed for other color, a random color is returned.

void UT_Color::getRGB ( float *  r,
float *  g,
float *  b 
) const
inline
Examples:
GUI/GUI_PolySoupBox.C.

Definition at line 101 of file UT_Color.h.

void UT_Color::getRGBConvert ( float *  r,
float *  g,
float *  b 
) const
protected
void UT_Color::getTMI ( float *  t,
float *  m,
float *  i 
) const
UT_ColorType UT_Color::getType ( void  ) const
inline

Definition at line 95 of file UT_Color.h.

static void UT_Color::getUniqueColor ( int64  idx,
float *  r,
float *  g,
float *  b 
)
static

A mapping from integers to colours that tries to ensure that the chosen colours are well separated and aesthetically pleasing.

void UT_Color::getValue ( float &  x,
float &  y,
float &  z 
) const
inline

Definition at line 97 of file UT_Color.h.

void UT_Color::getValue ( fpreal64 x,
fpreal64 y,
fpreal64 z 
) const
inline

Definition at line 99 of file UT_Color.h.

void UT_Color::getXYZ ( float *  x,
float *  y,
float *  z 
) const
void UT_Color::ghost ( fpreal  gfactor = 0.75f)
uint32 UT_Color::hash ( ) const
bool UT_Color::load ( UT_IStream is)
bool UT_Color::load ( UT_JSONParser p)

Methods to serialize to a JSON stream. The color is stored as a map:

"type" : "color space",
"data" : [ x, y, z, ... ]
fpreal UT_Color::luminance ( ) const

luminance() actually returns "luma", an approximation of luminance derived from the gamma corrected rgb values. So if you have linear rgb values and call this function, you will get the wrong result.

int UT_Color::operator!= ( const UT_Color c) const
inline

Definition at line 149 of file UT_Color.h.

bool UT_Color::operator< ( const UT_Color b) const
void UT_Color::operator= ( const UT_Color c)
int UT_Color::operator== ( const UT_Color color) const
fpreal UT_Color::relativeLuminance ( ) const

relativeLuminance() returns relative luminance [0,1] assuming the color is in linear RGB.

UT_Vector3F UT_Color::rgb ( ) const
int UT_Color::save ( std::ostream &  os,
int  binary 
) const
bool UT_Color::save ( UT_JSONWriter w) const

Methods to serialize to a JSON stream. The color is stored as a map:

"type" : "color space",
"data" : [ x, y, z, ... ]
bool UT_Color::save ( UT_JSONValue v) const

Methods to serialize to a JSON stream. The color is stored as a map:

"type" : "color space",
"data" : [ x, y, z, ... ]
void UT_Color::saveMinimalAsText ( std::ostream &  os) const
void UT_Color::setColorByName ( const char *  colorname)
void UT_Color::setHSL ( fpreal  h,
fpreal  s,
fpreal  l 
)
void UT_Color::setHSV ( fpreal  h,
fpreal  s,
fpreal  v 
)
void UT_Color::setLAB ( fpreal  l,
fpreal  a,
fpreal  b 
)
void UT_Color::setLABluminance ( fpreal  l)
void UT_Color::setRGB ( UT_Vector3F  c)
void UT_Color::setRGB ( UT_Vector3D  c)
void UT_Color::setRGB ( fpreal  r,
fpreal  g,
fpreal  b 
)
void UT_Color::setTMI ( fpreal  t,
fpreal  m,
fpreal  i 
)
void UT_Color::setType ( UT_ColorType  t)
void UT_Color::setUnique ( int64  idx)
void UT_Color::setValue ( fpreal  x,
fpreal  y,
fpreal  z 
)
inline

Definition at line 129 of file UT_Color.h.

void UT_Color::setXYZ ( fpreal  x,
fpreal  y,
fpreal  z 
)
void UT_Color::subRGB ( const UT_Color clr)
void UT_Color::tintRGB ( const UT_Color clr)

Friends And Related Function Documentation

UT_API std::ostream& operator<< ( std::ostream &  os,
const UT_Color color 
)
friend

Member Data Documentation

UT_ColorType UT_Color::type
protected

Definition at line 220 of file UT_Color.h.

float UT_Color::u
protected

Definition at line 221 of file UT_Color.h.

float UT_Color::v
protected

Definition at line 222 of file UT_Color.h.

float UT_Color::w
protected

Definition at line 223 of file UT_Color.h.


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