Methods
ColorUtils.HSLToRGB(hue: number, saturation: number, lightness: number)
Converts HSL values to RGB values. Both HSL and RGB should be values between 0 and 1.
@param hue
— The hue value of the HSL color.
@param saturation
— The saturation value of the HSL color.
@param lightness
— The lightness value of the HSL color.
@return r
— The red value of the converted color.
@return g
— The green value of the converted color.
@return b
— The blue value of the converted color.
Arguments:
hue: number | The hue value of the HSL color. |
saturation: number | The saturation value of the HSL color. |
lightness: number | The lightness value of the HSL color. |
Returns:
r: number | The red value of the converted color. |
g: number | The green value of the converted color. |
b: number | The blue value of the converted color. |
ColorUtils.HSVToRGB(hue: number, saturation: number, value: number)
Converts HSV values to RGB values. Both HSV and RGB should be values between 0 and 1.
@param hue
— The hue value of the HSV color.
@param saturation
— The saturation value of the HSV color.
@param value
— The 'value' value of the HSV color.
@return r
— The red value of the converted color.
@return g
— The green value of the converted color.
@return b
— The blue value of the converted color.
Arguments:
hue: number | The hue value of the HSV color. |
saturation: number | The saturation value of the HSV color. |
value: number | The 'value' value of the HSV color. |
Returns:
r: number | The red value of the converted color. |
g: number | The green value of the converted color. |
b: number | The blue value of the converted color. |
ColorUtils.RGBToHSL(red: number, green: number, blue: number)
Converts RGB values to HSL values. Both RGB and HSL should be values between 0 and 1.
@param red
— The red value of the RGB color.
@param green
— The green value of the RGB color.
@param blue
— The blue value of the RGB color.
@return hue
— The hue value of the converted color.
@return saturation
— The saturation value of the converted color.
@return lightness
— The lightness value of the converted color.
Arguments:
red: number | The red value of the RGB color. |
green: number | The green value of the RGB color. |
blue: number | The blue value of the RGB color. |
Returns:
hue: number | The hue value of the converted color. |
saturation: number | The saturation value of the converted color. |
lightness: number | The lightness value of the converted color. |
ColorUtils.RGBToHSV(red: number, green: number, blue: number)
Converts RGB values to HSV values. Both RGB and HSV should be values between 0 and 1.
@param red
— The red value of the RGB color.
@param green
— The green value of the RGB color.
@param blue
— The blue value of the RGB color.
@return hue
— The hue value of the converted color.
@return saturation
— The saturation value of the converted color.
@return value
— The 'value' value of the converted color.
Source: https://github.com/iskolbin/lhsx/blob/master/hsx.lua
Arguments:
red: number | The red value of the RGB color. |
green: number | The green value of the RGB color. |
blue: number | The blue value of the RGB color. |
Returns:
hue: number | The hue value of the converted color. |
saturation: number | The saturation value of the converted color. |
value: number | The 'value' value of the converted color. |
ColorUtils.RGBToHex(red: number, blue: number, green: number)
Converts a color to a hex color string.
@param red
— The red value of the color, between 0 and 1.
@param blue
— The blue value of the color, between 0 and 1.
@param green
— The green value of the color, between 0 and 1.
@return hex
— The converted hex string. Formatted with a # at the start, eg. "#ff00ff".
Arguments:
red: number | The red value of the color, between 0 and 1. |
blue: number | The blue value of the color, between 0 and 1. |
green: number | The green value of the color, between 0 and 1. |
Returns:
hex: string | The converted hex string. Formatted with a # at the start, eg. "#ff00ff". |
ColorUtils.ensureAlpha(color: number[])
Ensures a color has an alpha value. If the color already has an alpha value, it is returned unchanged. If it does not have an alpha value, an alpha value of 1 is added.
@param color
— The color to ensure has an alpha value.
@return rgba
— The color, with an alpha value.
Arguments:
color: number[] | The color to ensure has an alpha value. |
Returns:
rgba: number[] | The color, with an alpha value. |
ColorUtils.hexToRGB(color: string)
Converts a hex color string to an RGBA color table.
@param color
— The hex string to convert to RGBA.
@return rgba
— The converted RGBA table.
Arguments:
color: string | The hex string to convert to RGBA. |
Returns:
rgba: number[] | The converted RGBA table. |
ColorUtils.mergeColor(start_color: number[], end_color: number[], amount: number)
Merges two colors based on a percentage between 0 and 1.
@param start_color
— The first color to merge.
@param end_color
— The second color to merge.
@param amount
— A percentage (from 0 to 1) that determines how much of the second color to merge into the first.
@return result_color
— The two colors, merged together.
Arguments:
start_color: number[] | The first color to merge. |
end_color: number[] | The second color to merge. |
amount: number | A percentage (from 0 to 1) that determines how much of the second color to merge into the first. |
Returns:
result_color: number[] | The two colors, merged together. |