Color¶
The Color
library offers utilities for working with colors, either through RGB, decimal, or hex.
The constructor methods create an RGBColor
table.
The library also contains constants for common colors used by Larian.
ColorLib Class¶
Methods¶
Clone¶
Clones a color instance.
@param color RGBColor
Create¶
Alias for creating an RGBColor from RGBA values.
@param red integer?
@param green integer?
@param blue integer?
@param alpha integer?
CreateFromDecimal¶
Creates a color from a decimal value.
Does not support alpha.
@param num integer
CreateFromHex¶
Creates a color from an html-format hex color code.
Does not support alpha.
@param hex string
CreateFromRGB¶
Creates a color from RGBA values. Expected range of values is [0-255].
@param red integer?
@param green integer?
@param blue integer?
@param alpha integer?
Lerp¶
Creates a new color whose RGB components are linearly interpolated from one to another.
Uses the alpha of the target color.
@param startColor RGBColor
@param targetColor RGBColor
@param progress number
Expected values are from 0.0 to 1.0.
RGBColor Class¶
Methods¶
Clone¶
Returns a new instance of RGBColor with the same values.
Create¶
Creates a color from RGBA values.
Expected range is [0-255] and will be clamped.
@param r integer?
@param g integer?
@param b integer?
@param a integer?
Defaults to 255.
CreateFromDecimal¶
Creates a color from a decimal value.
Does not support alpha.
@param num integer
CreateFromHex¶
Creates a color from a hexadecimal value.
Does not support alpha.
@param hex string
Equals¶
Returns whether 2 colors have the same RGBA values.
@param color RGBColor
ToDecimal¶
Returns the decimal representation of the color.
Actionscript expects colors to be represented in this way.
@param addAlpha boolean?
Defaults to false.
ToFloats¶
Returns the RGBA values as floats in the range[0.0 - 1.0]
ToHex¶
Returns the hexadecimal representation of the color.
@param prefix boolean?
Prefix the string with #. Defaults to false.
@param addAlpha boolean?
Defaults to false. If enabled, resulting color will be in the format `#RRGGBBAA`
Unpack¶
Unpacks the color's RGB values, alpha included.
__add¶
__add overload. Adds the RGB values of both colors.
@param color1 RGBColor
@param color2 RGBColor
__eq¶
__eq overload. Equivalent to calling RGBColor:Equals()
@param color1 RGBColor
@param color2 RGBColor
__sub¶
__sub overload. Subtracts the RGB values.
@param color1 RGBColor
@param color2 RGBColor