![]() |
Murl Engine Lua Addon API
Version 1.0 beta
|
A color class.
This class holds four individual 32bit floating point values representing an RGBA color, each of them with a "regular" range of 0.0 (black) to 1.0 (full color). Actual values may lie beyond that range (in both directions), to define over saturated colors or even "negative" ones.
When specified as an attribute value in an XML file, there exist a number of different notations. For specifying multiple components in one value, the following ones can be used:
For these, a trailing 'h' character defines the hex notation. For specifying individual values, either 3 (RGB) or 4 (RGBA) values must be given as a comma-separated string. Each of these values must be post-fixed by one of the following characters:
String-to-color conversion in the described way can also be done from code, by using the Util::StringToColor() function.
Examples:
Enumeration of the components raw data.
Murl.Color.RED | Index to the red component |
Murl.Color.GREEN | Index to the green component |
Murl.Color.BLUE | Index to the blue component |
Murl.Color.ALPHA | Index to the alpha component |
Murl.Color.NUM_COMPONENTS | Number of components |
The default constructor.
Murl.Color new()
Constructor to set all color components to a given value.
Murl.Color new(Number value)
value | The value for the red, green, blue and alpha component. |
Constructor to initialize a color with given component values.
Murl.Color new(Number red, Number green, Number blue, Number alpha)
red | The red component. |
green | The green component. |
blue | The blue component. |
alpha | The alpha component. |
Named constructor to set all components to a set of given integer component values. The integer values are divided by 255.
Murl.Color FromInt(Integer red, Integer green, Integer blue, Integer alpha)
red | The red integer component. |
green | The green integer component. |
blue | The blue integer component. |
alpha | The alpha integer component. |
Get the red component's weight for luminance conversion, according to the ITU-R BT.601 standard.
Number GetLuminanceRedWeight()
Get the green component's weight for luminance conversion, according to the ITU-R BT.601 standard.
Number GetLuminanceGreenWeight()
Get the blue component's weight for luminance conversion, according to the ITU-R BT.601 standard.
Number GetLuminanceBlueWeight()
Set all components of the color instance to a set of given component values.
Set(Number red, Number green, Number blue, Number alpha)
red | The red component. |
green | The green component. |
blue | The blue component. |
alpha | The alpha component. |
Set all components of the color instance to a set of given integer component values. The integer values are divided by 255.
SetInt(Integer red, Integer green, Integer blue, Integer alpha)
red | The red integer component. |
green | The green integer component. |
blue | The blue integer component. |
alpha | The alpha integer component. |
Get the red component.
Number GetRed()
Set the red component.
SetRed(Number red)
red | The red component. |
Get the red integer component. The component is multiplied by 255.
Integer GetRedInt()
Set the red integer component. The component is divided by 255.
SetRedInt(Integer red)
red | The red integer component. |
Get the green component.
Number GetGreen()
Set the green component.
SetGreen(Number green)
green | The green component. |
Get the green integer component. The component is multiplied by 255.
Integer GetGreenInt()
Set the green integer component. The component is divided by 255.
SetGreenInt(Integer green)
green | The green integer component. |
Get the blue component.
Number GetBlue()
Set the blue component.
SetBlue(Number blue)
blue | The blue component. |
Get the blue integer component. The component is multiplied by 255.
Integer GetBlueInt()
Set the blue integer component. The component is divided by 255.
SetBlueInt(Integer blue)
blue | The blue integer component. |
Get the alpha component.
Number GetAlpha()
Set the alpha component.
SetAlpha(Number alpha)
alpha | The alpha component. |
Get the alpha integer component. The component is multiplied by 255.
Integer GetAlphaInt()
Set the alpha integer component. The component is divided by 255.
SetAlphaInt(Integer alpha)
alpha | The alpha integer component. |
Get the luminance (gray scale) value calculated from R, G and B. Luminance calculation uses the standard conversion factors defined by the Rec 601 standard which can be found in PAL and NTSC color models.
Number GetLuminance()
Get the luminance (gray scale) integer value calculated from R, G and B. Luminance calculation uses the standard conversion factors defined by the Rec 601 standard which can be found in PAL and NTSC color models, multiplied by 255.
Integer GetLuminanceInt()
Get the 32 bit ABGR value of the color instance components.
Integer ToUInt32()
Get the 32 bit ABGR value of the color instance components, clamped to the range [0..255].
Integer ToUInt32Clamped()
Set the color instance components from a 32 bit ABGR value.
FromUInt32(Integer color)
color | The 32 bit ABGR value. |
Set the color instance components from a 32 bit ARGB value.
FromUInt32ARGB(Integer color)
color | The 32 bit ARBG value. |
Blend a given foreground color over this color using alpha blending in place.
BlendSelf(Murl.Color foregroundColor)
foregroundColor | The foreground color to blend. |
Blend a given foreground color over this color using alpha blending and return the blended color.
Murl.Color Blend(Murl.Color foregroundColor)
foregroundColor | The foreground color to blend. |
Check if the color instance is equal to a given second color. Compares all values within the default epsilon range Limits::Epsilon().
Boolean IsEqual(Murl.Color color)
color | The color to compare. |
Check if the color instance is equal to a given second color. Compares all values within a given epsilon range.
Boolean IsEqual(Murl.Color color, Number epsilon)
color | The color to compare. |
epsilon | The epsilon to compare. |
Get the string representation of the object.
String ToString()
Converts the object content to a string in a reasonable format.
Addition operator.
Subtraction operator.
Multiplication operator.
Multiplication operator.
Division operator.
Division operator.
Equal to comparison operator. Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Color> class. To compare within an epsilon range use Color::IsEqual().