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
CreateFromHSV¶
Creates a color from HSV values.
@param hue integer
In degrees.
@param saturation number
As percentage.
@param value number
As percentage.
CreateFromHex¶
Creates a color from an html-format hex color code.
Does not support alpha.
@param hex htmlcolor
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?
IsHexColorCode¶
Returns whether a string is a valid hex color code.
@param text string
May be prefixed with "#".
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
CreateFromHSV¶
function RGBColor.CreateFromHSV(hue, saturation, value)
-> RGBColor, number, number, number -- Color and RGB values as floats.
Creates a color from HSV values.
@param hue integer
In degrees.
@param saturation number
As fraction.
@param value number
As fraction.
CreateFromHex¶
Creates a color from a hexadecimal value.
Does not support alpha.
@param hex htmlcolor
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]
ToHSV¶
Converts RGB values to HSV.
Ignores alpha.
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