iPlug2 - C++ Audio Plug-in Framework
|
Used to manage color data, independent of draw class/platform. More...
#include <IGraphicsStructs.h>
Public Member Functions | |
IColor (int a=255, int r=0, int g=0, int b=0) | |
Create an IColor. More... | |
bool | operator== (const IColor &rhs) |
bool | operator!= (const IColor &rhs) |
void | Set (int a=255, int r=0, int g=0, int b=0) |
Set the color parts. More... | |
bool | Empty () const |
void | Clamp () |
Keep the member int variables within the range 0-255. | |
void | Randomise (int alpha=255) |
Randomise the color parts, with optional alpha. More... | |
void | SetOpacity (float alpha) |
Set the color's opacity/alpha component with a float. More... | |
IColor | WithOpacity (float alpha) const |
Returns a new IColor with a different opacity. More... | |
void | Contrast (float c) |
Contrast the color. More... | |
IColor | WithContrast (float c) const |
Returns a new contrasted IColor based on this one. More... | |
void | GetRGBf (float *rgbf) const |
Get the color as a 3 float array. More... | |
void | GetRGBAf (float *rgbaf) const |
Get the color as a 4 float array. More... | |
void | GetHSLA (float &h, float &s, float &l, float &a) const |
Get the Hue, Saturation and Luminance of the color. More... | |
int | GetLuminosity () const |
int | ToColorCode () const |
Convert the IColor to a single int (no alpha) | |
void | ToColorCodeStr (WDL_String &str) const |
Convert the IColor to a hex string e.g. More... | |
Static Public Member Functions | |
static IColor | GetRandomColor (bool randomAlpha=false) |
Get a random IColor. More... | |
static IColor | FromRGBf (float *rgbf) |
Create an IColor from a 3 float RGB array. More... | |
static IColor | FromRGBAf (float *rgbaf) |
Create an IColor from a 4 float RGBA array. More... | |
static IColor | FromColorCode (int colorCode, int A=0xFF) |
Create an IColor from a color code. More... | |
static IColor | FromColorCodeStr (const char *hexStr) |
Create an IColor from a color code in a CString. More... | |
static IColor | FromHSLA (float h, float s, float l, float a=1.f) |
Create an IColor from Hue Saturation and Luminance values. More... | |
static IColor | LinearInterpolateBetween (const IColor &start, const IColor &dest, float progress) |
Helper function to linear interpolate between two IColors. More... | |
Public Attributes | |
int | A |
int | R |
int | G |
int | B |
Used to manage color data, independent of draw class/platform.
Definition at line 227 of file IGraphicsStructs.h.
|
inline |
Create an IColor.
a | Alpha value (valid range 0-255) |
r | Red value (valid range 0-255) |
g | Green value (valid range 0-255) |
b | Blue value (valid range 0-255) |
Definition at line 236 of file IGraphicsStructs.h.
|
inline |
Contrast the color.
c | Contrast value in the range -1.f to 1.f |
Definition at line 277 of file IGraphicsStructs.h.
References Clip().
Referenced by WithContrast().
|
inline |
true
if all color parts are zero Definition at line 249 of file IGraphicsStructs.h.
|
inlinestatic |
Create an IColor from a color code.
Can be used to convert a hex code into an IColor object.
colorCode | Integer representation of the color. Use with hexadecimal numbers, e.g. 0xff38a2 |
A | Integer representation of the alpha channel |
Definition at line 405 of file IGraphicsStructs.h.
|
inlinestatic |
Create an IColor from a color code in a CString.
Can be used to convert a hex code into an IColor object.
hexStr | CString representation of the color code (no alpha). Use with hex numbers, e.g. "#ff38a2". WARNING: This does very little error checking |
Definition at line 417 of file IGraphicsStructs.h.
|
inlinestatic |
Create an IColor from Hue Saturation and Luminance values.
h | hue value in the range 0.f-1.f |
s | saturation value in the range 0.f-1.f |
l | luminance value in the range 0.f-1.f |
a | alpha value in the range 0.f-1.f |
Definition at line 452 of file IGraphicsStructs.h.
References Clip().
Referenced by ILEDControl::Draw(), and TestColorControl::OnResize().
|
inlinestatic |
Create an IColor from a 4 float RGBA array.
rgbaf | ptr to array of 3 floats |
Definition at line 386 of file IGraphicsStructs.h.
|
inlinestatic |
Create an IColor from a 3 float RGB array.
rgbf | ptr to array of 3 floats |
Definition at line 373 of file IGraphicsStructs.h.
|
inline |
Get the Hue, Saturation and Luminance of the color.
h | hue value to set, output in the range 0. to 1. |
s | saturation value to set, output in the range 0. to 1. |
l | luminance value to set, output in the range 0. to 1. |
a | alpha value to set, output in the range 0. to 1. |
Definition at line 319 of file IGraphicsStructs.h.
|
inline |
Definition at line 350 of file IGraphicsStructs.h.
Referenced by IVKeyboardControl::Draw().
|
inlinestatic |
Get a random IColor.
randomAlpha | Set true if you want a random alpha value too |
Definition at line 360 of file IGraphicsStructs.h.
Referenced by TestTextControl::OnMouseDblClick(), TestAnimationControl::OnMouseDown(), and TestGradientControl::OnResize().
|
inline |
Get the color as a 4 float array.
rgbaf | ptr to array of 4 floats |
Definition at line 306 of file IGraphicsStructs.h.
|
inline |
Get the color as a 3 float array.
rgbf | ptr to array of 3 floats |
Definition at line 297 of file IGraphicsStructs.h.
|
inlinestatic |
Helper function to linear interpolate between two IColors.
Definition at line 484 of file IGraphicsStructs.h.
|
inline |
Randomise the color parts, with optional alpha.
alpha | Set the alpha of the new random color |
Definition at line 256 of file IGraphicsStructs.h.
Referenced by IGraphics::BeginFrame().
|
inline |
Set the color parts.
a | Alpha value (valid range 0-255) |
r | Red value (valid range 0-255) |
g | Green value (valid range 0-255) |
b | Blue value (valid range 0-255) |
Definition at line 246 of file IGraphicsStructs.h.
Referenced by IVectorBase::GetColor().
|
inline |
Set the color's opacity/alpha component with a float.
alpha | float in the range 0. to 1. |
Definition at line 260 of file IGraphicsStructs.h.
References Clip().
Referenced by WithOpacity().
|
inline |
Convert the IColor to a hex string e.g.
"#ffffffff"
Definition at line 441 of file IGraphicsStructs.h.
|
inline |
Returns a new contrasted IColor based on this one.
c | Contrast value in the range -1. to 1. |
Definition at line 288 of file IGraphicsStructs.h.
References Contrast().
Referenced by IVKeyboardControl::Draw(), and IWheelControl::Draw().
|
inline |
Returns a new IColor with a different opacity.
alpha | float in the range 0. to 1. |
Definition at line 268 of file IGraphicsStructs.h.
References SetOpacity().
Referenced by TestFlexBoxControl::Draw(), and IWheelControl::Draw().