Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
G3D::Color3 Class Reference


Do not subclass– this implementation makes assumptions about the memory layout. More...

Public Member Functions

 Color3 ()
 
Initializes to all zero. More...
 
 Color3 (DoNotInitialize dni)
 
 Color3 (const Any &any)
 
 Color3 (class BinaryInput &bi)
 
 Color3 (float r, float g, float b)
 
 Color3 (float v)
 Initializes all channels to v. More...
 
 Color3 (const class Vector3 &v)
 
 Color3 (const float value[3])
 
 Color3 (const Color3 &other)
 
Initialize from another color. More...
 
 Color3 (const class Color3unorm8 &other)
 
float average () const
 
Color3 bgr () const
 
Color3 clamp (float low, float high) const
 
Color3 cross (const Color3 &rkVector) const
 
void deserialize (class BinaryInput &bi)
 
Color3 direction () const
 
float dot (const Color3 &rkVector) const
 
bool fuzzyEq (const Color3 &other) const
 
bool fuzzyNe (const Color3 &other) const
 
size_t hashCode () const
 
bool isFinite () const
 
bool isOne () const
 
bool isZero () const
 
float length () const
 
Color3 lerp (const Color3 &other, float a) const
 
Color3 max (const Color3 &other) const
 
float max () const
 Largest element. More...
 
Color3 min (const Color3 &other) const
 
float min () const
 Smallest element. More...
 
bool nonZero () const
 
bool operator!= (const Color3 &rkVector) const
 
Color3 operator* (float s) const
 
Color3 operator* (const Color3 &rkVector) const
 
Color3operator*= (const Color3 &rkVector)
 
Color3operator*= (float fScalar)
 
Color3 operator+ (const Color3 &rkVector) const
 
Color3operator+= (const Color3 &rkVector)
 
Color3 operator- (const Color3 &rkVector) const
 
Color3 operator- () const
 
Color3operator-= (const Color3 &rkVector)
 
Color3 operator/ (const Color3 &rkVector) const
 
Color3 operator/ (float fScalar) const
 
Color3operator/= (float fScalar)
 
Color3operator= (const Any &a)
 
Color3operator= (const Color3 &rkVector)
 
bool operator== (const Color3 &rkVector) const
 
const float & operator[] (int i) const
 
float & operator[] (int i)
 
Color3 pow (const Color3 &other) const
 
Color3 pow (float other) const
 
const Color3rgb () const
 Returns this color. More...
 
Color3 RGBTosRGB () const
 Converts an RGB color to sRGB. More...
 
Color3 scaleSaturation (float factor) const
 Scales "saturation". More...
 
void serialize (class BinaryOutput &bo) const
 
float squaredLength () const
 
Color3 sRGBToRGB () const
 Converts a sRGB color to RGB. More...
 
float sum () const
 
Any toAny () const
 Converts the Color3 to an Any. More...
 
String toString () const
 
Color3 unitCross (const Color3 &rkVector) const
 
float unitize (float fTolerance=1e-06)
 

Static Public Member Functions

static Color3 ansiMap (uint32 i)
 Generate colors according to the ANSI color set, mod 16. More...
 
static const Color3black ()
 
static const Color3blue ()
 
static const Color3brown ()
 
static const Color3cyan ()
 
static Color3 fromARGB (uint32)
 
Initialize from an HTML-style color (e.g. More...
 
static Color3 fromASRGB (uint32)
 
Initialize from an HTML-style color (e.g. More...
 
static Color3 fromHSV (const Vector3 &_hsv)
 Converts from HSV to RGB , note: toHSV(fromHSV(_hsv)) may not be _hsv, if it is at a grey point or black point. More...
 
static Color3 fromWavelengthNanometers (float lambda)
 A radiance value that will look approximately like the stimulus based on the wavelength of light in nanometers. More...
 
static const Color3gray ()
 
static const Color3green ()
 
static Color3 jetColorMap (const float &val)
 Duplicates the matlab jet colormap maps [0,1] –> (r,g,b) where blue is close to 0 and red is close to 1. More...
 
static const Color3nan ()
 
static Color3 neonGradient (float t)
 
static const Color3one ()
 
static const Color3orange ()
 
static Color3 pastelMap (uint32 i)
 Generate colors using a hash such that adjacent values are unlikely to have similar colors. More...
 
static const Color3purple ()
 
static Color3 rainbowColorMap (float hue)
 Returns colors with maximum saturation and value. More...
 
static Color3 random ()
 Random unit vector. More...
 
static const Color3red ()
 
static Vector3 toHSV (const Color3 &_rgb)
 
static const Color3wheelRandom ()
 Returns one of the color wheel colors (e.g. More...
 
static const Color3white ()
 
static const Color3yellow ()
 
static const Color3zero ()
 

Public Attributes

float b
 
float g
 
float r
 Channel value. More...
 

Detailed Description


Do not subclass– this implementation makes assumptions about the memory layout.

Constructor & Destructor Documentation

◆ Color3() [1/10]

G3D::Color3::Color3 ( )
inline


Initializes to all zero.

Referenced by bgr(), clamp(), cross(), max(), min(), neonGradient(), operator*(), operator+(), operator-(), operator/(), and pow().

◆ Color3() [2/10]

G3D::Color3::Color3 ( DoNotInitialize  dni)
inline

◆ Color3() [3/10]

G3D::Color3::Color3 ( const Any any)
explicit
Parameters
anyMust be in one of the following forms:

In the current implementation, G3D::Power3, G3D::Radiance3, and G3D::Irradiance3 are typedefs for Color3, so Color3 accepts "Power3" and "Radiance3" as a prefixes as well, e.g., Power3(1,0,0).

◆ Color3() [4/10]

G3D::Color3::Color3 ( class BinaryInput bi)
explicit

◆ Color3() [5/10]

G3D::Color3::Color3 ( float  r,
float  g,
float  b 
)
inline

◆ Color3() [6/10]

G3D::Color3::Color3 ( float  v)
inlineexplicit

Initializes all channels to v.

◆ Color3() [7/10]

G3D::Color3::Color3 ( const class Vector3 v)
explicit

◆ Color3() [8/10]

G3D::Color3::Color3 ( const float  value[3])
inlineexplicit

◆ Color3() [9/10]

G3D::Color3::Color3 ( const Color3 other)
inline


Initialize from another color.

◆ Color3() [10/10]

G3D::Color3::Color3 ( const class Color3unorm8 other)

Member Function Documentation

◆ ansiMap()

static Color3 G3D::Color3::ansiMap ( uint32  i)
static

Generate colors according to the ANSI color set, mod 16.

See also
pastelMap

◆ average()

float G3D::Color3::average ( ) const
inline

◆ bgr()

Color3 G3D::Color3::bgr ( ) const
inline

◆ black()

static const Color3& G3D::Color3::black ( )
static

◆ blue()

static const Color3& G3D::Color3::blue ( )
static

◆ brown()

static const Color3& G3D::Color3::brown ( )
static

◆ clamp()

Color3 G3D::Color3::clamp ( float  low,
float  high 
) const
inline

◆ cross()

Color3 G3D::Color3::cross ( const Color3 rkVector) const
inline

◆ cyan()

static const Color3& G3D::Color3::cyan ( )
static

◆ deserialize()

void G3D::Color3::deserialize ( class BinaryInput bi)

◆ direction()

Color3 G3D::Color3::direction ( ) const
inline

Referenced by unitCross().

◆ dot()

float G3D::Color3::dot ( const Color3 rkVector) const
inline

◆ fromARGB()

static Color3 G3D::Color3::fromARGB ( uint32  )
static


Initialize from an HTML-style color (e.g.

0xFF0000 == RED)

◆ fromASRGB()

static Color3 G3D::Color3::fromASRGB ( uint32  )
static


Initialize from an HTML-style color (e.g.

0xFF0000 == RED) by converting from sRGB to RGB. The alpha channel is linear.

◆ fromHSV()

static Color3 G3D::Color3::fromHSV ( const Vector3 _hsv)
static

Converts from HSV to RGB , note: toHSV(fromHSV(_hsv)) may not be _hsv, if it is at a grey point or black point.

The components of _hsv should lie in the unit interval.

Referenced Code: Alvy Ray Smith SIGGRAPH 1978 "Color Gamut Transform Pairs"

◆ fromWavelengthNanometers()

static Color3 G3D::Color3::fromWavelengthNanometers ( float  lambda)
static

A radiance value that will look approximately like the stimulus based on the wavelength of light in nanometers.

Remember to convert to sRGB if displaying directly.

Referenced Code: http://www.physics.sfasu.edu/astro/color/spectra.html

◆ fuzzyEq()

bool G3D::Color3::fuzzyEq ( const Color3 other) const
inline

◆ fuzzyNe()

bool G3D::Color3::fuzzyNe ( const Color3 other) const
inline

◆ gray()

static const Color3& G3D::Color3::gray ( )
static

◆ green()

static const Color3& G3D::Color3::green ( )
static

◆ hashCode()

size_t G3D::Color3::hashCode ( ) const

◆ isFinite()

bool G3D::Color3::isFinite ( ) const

◆ isOne()

bool G3D::Color3::isOne ( ) const
inline

◆ isZero()

bool G3D::Color3::isZero ( ) const
inline

◆ jetColorMap()

static Color3 G3D::Color3::jetColorMap ( const float &  val)
static

Duplicates the matlab jet colormap maps [0,1] –> (r,g,b) where blue is close to 0 and red is close to 1.

◆ length()

float G3D::Color3::length ( ) const
inline

◆ lerp()

Color3 G3D::Color3::lerp ( const Color3 other,
float  a 
) const
inline

Referenced by G3D::lerp().

◆ max() [1/2]

Color3 G3D::Color3::max ( const Color3 other) const
inline

Referenced by G3D::max().

◆ max() [2/2]

float G3D::Color3::max ( ) const
inline

Largest element.

◆ min() [1/2]

Color3 G3D::Color3::min ( const Color3 other) const
inline

Referenced by G3D::min().

◆ min() [2/2]

float G3D::Color3::min ( ) const
inline

Smallest element.

◆ nan()

static const Color3& G3D::Color3::nan ( )
static

◆ neonGradient()

static Color3 G3D::Color3::neonGradient ( float  t)
inlinestatic

◆ nonZero()

bool G3D::Color3::nonZero ( ) const
inline

◆ one()

static const Color3& G3D::Color3::one ( )
static

◆ operator!=()

bool G3D::Color3::operator!= ( const Color3 rkVector) const
inline

◆ operator*() [1/2]

Color3 G3D::Color3::operator* ( float  s) const
inline

◆ operator*() [2/2]

Color3 G3D::Color3::operator* ( const Color3 rkVector) const
inline

◆ operator*=() [1/2]

Color3 & G3D::Color3::operator*= ( const Color3 rkVector)
inline

◆ operator*=() [2/2]

Color3 & G3D::Color3::operator*= ( float  fScalar)
inline

◆ operator+()

Color3 G3D::Color3::operator+ ( const Color3 rkVector) const
inline

◆ operator+=()

Color3 & G3D::Color3::operator+= ( const Color3 rkVector)
inline

◆ operator-() [1/2]

Color3 G3D::Color3::operator- ( const Color3 rkVector) const
inline

◆ operator-() [2/2]

Color3 G3D::Color3::operator- ( ) const
inline

◆ operator-=()

Color3 & G3D::Color3::operator-= ( const Color3 rkVector)
inline

◆ operator/() [1/2]

Color3 G3D::Color3::operator/ ( const Color3 rkVector) const
inline

◆ operator/() [2/2]

Color3 G3D::Color3::operator/ ( float  fScalar) const
inline

◆ operator/=()

Color3& G3D::Color3::operator/= ( float  fScalar)

◆ operator=() [1/2]

Color3& G3D::Color3::operator= ( const Any a)

◆ operator=() [2/2]

Color3 & G3D::Color3::operator= ( const Color3 rkVector)
inline

◆ operator==()

bool G3D::Color3::operator== ( const Color3 rkVector) const
inline

◆ operator[]() [1/2]

const float & G3D::Color3::operator[] ( int  i) const
inline

◆ operator[]() [2/2]

float & G3D::Color3::operator[] ( int  i)
inline

◆ orange()

static const Color3& G3D::Color3::orange ( )
static

◆ pastelMap()

static Color3 G3D::Color3::pastelMap ( uint32  i)
static

Generate colors using a hash such that adjacent values are unlikely to have similar colors.

Useful for rendering with stable but arbitrary colors, e.g., when debugging a mesh algorithm.

See also
ansiMap

◆ pow() [1/2]

Color3 G3D::Color3::pow ( const Color3 other) const
inline

Referenced by pow().

◆ pow() [2/2]

Color3 G3D::Color3::pow ( float  other) const
inline

◆ purple()

static const Color3& G3D::Color3::purple ( )
static

◆ rainbowColorMap()

static Color3 G3D::Color3::rainbowColorMap ( float  hue)
static

Returns colors with maximum saturation and value.

Parameters
hue[0, 1]

◆ random()

static Color3 G3D::Color3::random ( )
static

Random unit vector.

◆ red()

static const Color3& G3D::Color3::red ( )
static

◆ rgb()

const Color3& G3D::Color3::rgb ( ) const
inline

Returns this color.

◆ RGBTosRGB()

Color3 G3D::Color3::RGBTosRGB ( ) const

Converts an RGB color to sRGB.

◆ scaleSaturation()

Color3 G3D::Color3::scaleSaturation ( float  factor) const

Scales "saturation".

Technically, this should be applied to only sRGB color space values.

◆ serialize()

void G3D::Color3::serialize ( class BinaryOutput bo) const

◆ squaredLength()

float G3D::Color3::squaredLength ( ) const
inline

Referenced by fuzzyEq(), and fuzzyNe().

◆ sRGBToRGB()

Color3 G3D::Color3::sRGBToRGB ( ) const

Converts a sRGB color to RGB.

◆ sum()

float G3D::Color3::sum ( ) const
inline

Referenced by average().

◆ toAny()

Any G3D::Color3::toAny ( ) const

Converts the Color3 to an Any.

◆ toHSV()

static Vector3 G3D::Color3::toHSV ( const Color3 _rgb)
static

◆ toString()

String G3D::Color3::toString ( ) const

◆ unitCross()

Color3 G3D::Color3::unitCross ( const Color3 rkVector) const
inline

◆ unitize()

float G3D::Color3::unitize ( float  fTolerance = 1e-06)

◆ wheelRandom()

static const Color3& G3D::Color3::wheelRandom ( )
static

Returns one of the color wheel colors (e.g.

RED, GREEN, CYAN). Does not include white, black, or gray.

◆ white()

static const Color3& G3D::Color3::white ( )
static

◆ yellow()

static const Color3& G3D::Color3::yellow ( )
static

◆ zero()

static const Color3& G3D::Color3::zero ( )
static

Member Data Documentation

◆ b

float G3D::Color3::b

◆ g

float G3D::Color3::g

◆ r

float G3D::Color3::r

documentation generated on Wed Nov 24 2021 08:01:54 using doxygen 1.8.15