Rhino C++ API  8.14
Public Member Functions | Static Public Attributes | Friends | List of all members
CRhRdkColor Class Referencefinal

#include <RhRdkColor.h>

Public Member Functions

 CRhRdkColor ()
 
 CRhRdkColor (const CRhRdkColor &c)
 
 CRhRdkColor (const float *d)
 
 CRhRdkColor (const ON_4fColor &c)
 
 CRhRdkColor (const ON_Color &c)
 
 CRhRdkColor (float fRed, float fGreen, float fBlue, float fAlpha=1.0f)
 
 CRhRdkColor (int iRed, int iGreen, int iBlue, int iAlpha=255)
 
void Add (const CRhRdkColor &c)
 
RDK_DEPRECATED bool ApplyLinearWorkflowGamma (const class IRhRdkLinearWorkflow &lw, bool bForTexture)
 
RDK_DEPRECATED bool ApplyLinearWorkflowGamma (const CRhinoDoc *pDoc)
 
bool ApplyLinearWorkflowGamma (const ON_LinearWorkflow &lw, bool bForTexture)
 
void BlendTo (float t, const CRhRdkColor &col, bool bClampAlpha=false)
 
void Clamp (void)
 
COLORREF ColorRef (void) const
 
COLORREF ColorRefAlpha (void) const
 
void * EF (const wchar_t *wszFunc, void *pvData)
 
float FAlpha (void) const
 
float FBlue (void) const
 
float FGreen (void) const
 
float * FloatArray (void)
 
const float * FloatArray (void) const
 
float FRed (void) const
 
void GetHSL (float &h, float &s, float &l) const
 
float Hue (void) const
 
UINT IAlpha (void) const
 
UINT IBlue (void) const
 
UINT IGreen (void) const
 
UINT IRed (void) const
 
bool IsEqualWithinTolerance (const CRhRdkColor &col, double dTolerance) const
 
float Luminance (void) const
 
void MultiplyBy (float f, bool bAffectAlpha)
 
ON_4fColor On4fColor (void) const
 
ON_Color OnColor (void) const
 
bool operator!= (const CRhRdkColor &c) const
 
const CRhRdkColoroperator*= (const CRhRdkColor &c)
 
const CRhRdkColoroperator*= (float d)
 
const CRhRdkColoroperator+= (const CRhRdkColor &c)
 
const CRhRdkColoroperator+= (float d)
 
const CRhRdkColoroperator-= (const CRhRdkColor &c)
 
const CRhRdkColoroperator-= (float d)
 
const CRhRdkColoroperator/= (const CRhRdkColor &c)
 
const CRhRdkColoroperator/= (float d)
 
CRhRdkColoroperator= (const CRhRdkColor &c)
 
CRhRdkColoroperator= (const ON_4fColor &c)
 
CRhRdkColoroperator= (const ON_Color &c)
 
bool operator== (const CRhRdkColor &c) const
 
float Saturation (void) const
 
void Set (COLORREF c)
 
void Set (const float *d)
 
void Set (double dRed, double dGreen, double dBlue, double dAlpha=1.0)
 
void Set (float fRed, float fGreen, float fBlue, float fAlpha=1.0f)
 
void Set (int iRed, int iGreen, int iBlue, int iAlpha=255)
 
void SetAlpha (float fAlpha)
 
void SetAlpha (int iAlpha)
 
void SetHSL (float h, float s, float l)
 
void Subtract (const CRhRdkColor &c)
 

Static Public Attributes

static CRhRdkColor black
 
static CRhRdkColor white
 

Friends

CRhRdkColor operator* (const CRhRdkColor &c1, const CRhRdkColor &c2)
 
CRhRdkColor operator* (const CRhRdkColor &c1, float d)
 
CRhRdkColor operator* (float d, const CRhRdkColor &c1)
 
CRhRdkColor operator+ (const CRhRdkColor &c1, const CRhRdkColor &c2)
 
CRhRdkColor operator- (const CRhRdkColor &c1, const CRhRdkColor &c2)
 
CRhRdkColor operator/ (const CRhRdkColor &c1, const CRhRdkColor &c2)
 
CRhRdkColor operator/ (const CRhRdkColor &c1, float d)
 
CRhRdkColor operator/ (float d, const CRhRdkColor &c1)
 

Constructor & Destructor Documentation

◆ CRhRdkColor() [1/7]

CRhRdkColor::CRhRdkColor ( )

Construct as solid black (0, 0, 0, 1).

◆ CRhRdkColor() [2/7]

CRhRdkColor::CRhRdkColor ( const float *  d)

Construct from float array.

Note
There must be four floats in the array.

◆ CRhRdkColor() [3/7]

CRhRdkColor::CRhRdkColor ( float  fRed,
float  fGreen,
float  fBlue,
float  fAlpha = 1.0f 
)

Construct from floats (0.0f to MAX_FLOAT).

◆ CRhRdkColor() [4/7]

CRhRdkColor::CRhRdkColor ( int  iRed,
int  iGreen,
int  iBlue,
int  iAlpha = 255 
)

Construct from integers (0 to 255).

◆ CRhRdkColor() [5/7]

CRhRdkColor::CRhRdkColor ( const ON_Color c)
explicit

Construct from ON_Color.

◆ CRhRdkColor() [6/7]

CRhRdkColor::CRhRdkColor ( const ON_4fColor c)
explicit

Construct from ON_4fColor.

◆ CRhRdkColor() [7/7]

CRhRdkColor::CRhRdkColor ( const CRhRdkColor c)

Construct from another instance.

Member Function Documentation

◆ Add()

void CRhRdkColor::Add ( const CRhRdkColor c)

Add another color to this color with no clamping of alpha.

◆ ApplyLinearWorkflowGamma() [1/3]

RDK_DEPRECATED bool CRhRdkColor::ApplyLinearWorkflowGamma ( const class IRhRdkLinearWorkflow lw,
bool  bForTexture 
)

This method is deprecated in favor of the one below.

◆ ApplyLinearWorkflowGamma() [2/3]

RDK_DEPRECATED bool CRhRdkColor::ApplyLinearWorkflowGamma ( const CRhinoDoc pDoc)

This method is deprecated in favor of the other one which is faster.

◆ ApplyLinearWorkflowGamma() [3/3]

bool CRhRdkColor::ApplyLinearWorkflowGamma ( const ON_LinearWorkflow lw,
bool  bForTexture 
)

Adjust the color for linear workflow gamma. If linear workflow is enabled, color is adjusted and the function returns true. Otherwise the function returns false.

◆ BlendTo()

void CRhRdkColor::BlendTo ( float  t,
const CRhRdkColor col,
bool  bClampAlpha = false 
)

Blend this color to col using t from 0.0 to 1.0

Note
Does not clamp 't' or rgb result unless bClampAlpha is true, in which case alpha is clamped.

◆ Clamp()

void CRhRdkColor::Clamp ( void  )

Clamp each of the RGBA color components to be between 0.0 and 1.0.

◆ ColorRef()

COLORREF CRhRdkColor::ColorRef ( void  ) const

Get color as COLORREF (ignores alpha).

◆ ColorRefAlpha()

COLORREF CRhRdkColor::ColorRefAlpha ( void  ) const

Get color as COLORREF (with alpha in high byte).

◆ EF()

void* CRhRdkColor::EF ( const wchar_t *  wszFunc,
void *  pvData 
)

Emergency function for future expansion.

◆ FAlpha()

float CRhRdkColor::FAlpha ( void  ) const

Get alpha value as float (0.0 to MAX_FLOAT).

◆ FBlue()

float CRhRdkColor::FBlue ( void  ) const

Get blue value as float (0.0 to MAX_FLOAT).

◆ FGreen()

float CRhRdkColor::FGreen ( void  ) const

Get green value as float (0.0 to MAX_FLOAT).

◆ FloatArray() [1/2]

float* CRhRdkColor::FloatArray ( void  )

Direct read/write access to array of four floats.

Warning
If you access the array beyond the 4th element, the function may crash Rhino.

◆ FloatArray() [2/2]

const float* CRhRdkColor::FloatArray ( void  ) const

Direct read access to array of four floats.

Warning
If you access the array beyond the 4th element, the function may crash Rhino.

◆ FRed()

float CRhRdkColor::FRed ( void  ) const

Get red value as float (0.0 to MAX_FLOAT).

◆ GetHSL()

void CRhRdkColor::GetHSL ( float &  h,
float &  s,
float &  l 
) const

Get the hue (0 to 360), saturation (0 to 1) and luminance (0 to 1).

◆ Hue()

float CRhRdkColor::Hue ( void  ) const

Get the hue (0 to 360).

◆ IAlpha()

UINT CRhRdkColor::IAlpha ( void  ) const

Get alpha value as integer (0 to 255). Clamped.

◆ IBlue()

UINT CRhRdkColor::IBlue ( void  ) const

Get blue value as integer (0 to 255). Clamped.

◆ IGreen()

UINT CRhRdkColor::IGreen ( void  ) const

Get green value as integer (0 to 255). Clamped.

◆ IRed()

UINT CRhRdkColor::IRed ( void  ) const

Get red value as integer (0 to 255).

◆ IsEqualWithinTolerance()

bool CRhRdkColor::IsEqualWithinTolerance ( const CRhRdkColor col,
double  dTolerance 
) const
Returns
true if this color is equal to another color within the specified tolerance.

◆ Luminance()

float CRhRdkColor::Luminance ( void  ) const

Get the luminance (0 to 1).

◆ MultiplyBy()

void CRhRdkColor::MultiplyBy ( float  f,
bool  bAffectAlpha 
)

Multiply this color by a value with optional alpha.

◆ On4fColor()

ON_4fColor CRhRdkColor::On4fColor ( void  ) const

Get color as ON_4fColor.

◆ OnColor()

ON_Color CRhRdkColor::OnColor ( void  ) const

Get color as ON_Color.

◆ operator!=()

bool CRhRdkColor::operator!= ( const CRhRdkColor c) const

Check if colors are not exactly equal.

◆ operator*=() [1/2]

const CRhRdkColor& CRhRdkColor::operator*= ( const CRhRdkColor c)

Multiply this color by another color.

Note
Alpha IS multiplied.

◆ operator*=() [2/2]

const CRhRdkColor& CRhRdkColor::operator*= ( float  d)

Multiply this color by a value.

Note
Alpha is NOT multiplied.

◆ operator+=() [1/2]

const CRhRdkColor& CRhRdkColor::operator+= ( const CRhRdkColor c)

Add another color to this color.

Note
Alpha is clamped.

◆ operator+=() [2/2]

const CRhRdkColor& CRhRdkColor::operator+= ( float  d)

Add a value to this color.

Note
Alpha is clamped.

◆ operator-=() [1/2]

const CRhRdkColor& CRhRdkColor::operator-= ( const CRhRdkColor c)

Subtract another color from this color.

Note
Alpha is clamped.

◆ operator-=() [2/2]

const CRhRdkColor& CRhRdkColor::operator-= ( float  d)

Subtract a value from this color.

Note
Alpha is clamped.

◆ operator/=() [1/2]

const CRhRdkColor& CRhRdkColor::operator/= ( const CRhRdkColor c)

Divide this color by another color.

Note
Alpha IS divided.

◆ operator/=() [2/2]

const CRhRdkColor& CRhRdkColor::operator/= ( float  d)

Divide this color by a value.

Note
Alpha is NOT divided.

◆ operator=() [1/3]

CRhRdkColor& CRhRdkColor::operator= ( const CRhRdkColor c)

Copy color from another instance.

◆ operator=() [2/3]

CRhRdkColor& CRhRdkColor::operator= ( const ON_4fColor c)

Copy color from an ON_4fColor instance.

◆ operator=() [3/3]

CRhRdkColor& CRhRdkColor::operator= ( const ON_Color c)

Copy color from an ON_Color instance.

◆ operator==()

bool CRhRdkColor::operator== ( const CRhRdkColor c) const

Check if colors are exactly equal.

◆ Saturation()

float CRhRdkColor::Saturation ( void  ) const

Get the saturation (0 to 1).

◆ Set() [1/5]

void CRhRdkColor::Set ( COLORREF  c)

Set color from lowest 24 bits of a COLORREF. Alpha is set to 1.0f.

◆ Set() [2/5]

void CRhRdkColor::Set ( const float *  d)

Set color from float array.

Note
There must be four floats in the array

◆ Set() [3/5]

void CRhRdkColor::Set ( double  dRed,
double  dGreen,
double  dBlue,
double  dAlpha = 1.0 
)

Set color as doubles (0.0 to MAX_FLOAT).

◆ Set() [4/5]

void CRhRdkColor::Set ( float  fRed,
float  fGreen,
float  fBlue,
float  fAlpha = 1.0f 
)

Set color as floats (0.0 to MAX_FLOAT).

◆ Set() [5/5]

void CRhRdkColor::Set ( int  iRed,
int  iGreen,
int  iBlue,
int  iAlpha = 255 
)

Set color as ints (0 to 255).

◆ SetAlpha() [1/2]

void CRhRdkColor::SetAlpha ( float  fAlpha)

Set alpha channel only.

◆ SetAlpha() [2/2]

void CRhRdkColor::SetAlpha ( int  iAlpha)

Set alpha channel only.

◆ SetHSL()

void CRhRdkColor::SetHSL ( float  h,
float  s,
float  l 
)

Set the hue (0 to 360), saturation (0 to 1) and luminance (0 to 1).

◆ Subtract()

void CRhRdkColor::Subtract ( const CRhRdkColor c)

Subtract another color from this color with no clamping of alpha.

Friends And Related Function Documentation

◆ operator* [1/3]

CRhRdkColor operator* ( const CRhRdkColor c1,
const CRhRdkColor c2 
)
friend

Multiply two colors.

◆ operator* [2/3]

CRhRdkColor operator* ( const CRhRdkColor c1,
float  d 
)
friend

Multiply a color by a value.

◆ operator* [3/3]

CRhRdkColor operator* ( float  d,
const CRhRdkColor c1 
)
friend

Multiply a value by a color.

◆ operator+

CRhRdkColor operator+ ( const CRhRdkColor c1,
const CRhRdkColor c2 
)
friend

Add two colors.

◆ operator-

CRhRdkColor operator- ( const CRhRdkColor c1,
const CRhRdkColor c2 
)
friend

Subtract two colors.

◆ operator/ [1/3]

CRhRdkColor operator/ ( const CRhRdkColor c1,
const CRhRdkColor c2 
)
friend

Divide a color by a color.

◆ operator/ [2/3]

CRhRdkColor operator/ ( const CRhRdkColor c1,
float  d 
)
friend

Divide a color by a value.

◆ operator/ [3/3]

CRhRdkColor operator/ ( float  d,
const CRhRdkColor c1 
)
friend

Divide a value by a color.

Member Data Documentation

◆ black

CRhRdkColor CRhRdkColor::black
static

◆ white

CRhRdkColor CRhRdkColor::white
static