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.
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.
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.
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.
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.
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, [2]? })
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.
Arguments:
| color: number, [2]? } | The color to ensure has an alpha value. |
Returns:
| rgba: number, [2]? } | The color, with an alpha value. |
ColorUtils.hexToRGB(color: string)
Converts a hex color string to an RGBA color table.
Arguments:
| color: string | The hex string to convert to RGBA. |
Returns:
| rgba: number, [2]? } | 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.
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. |
ColorUtils.unpackColor(color: number, [2]? })
Returns the values of an RGB table individually.
Arguments:
| color: number, [2]? } | An RGB(A) table. |
Returns:
| r: number | The red value of the color. |
| g: number | The green value of the color. |
| b: number | The blue value of the color. |
| a: number | The alpha value of the color, or 1 if it was not specified. |