Color class
Extensions of the Color metatable and of the global Color function.
Color also accepts hexadecimal strings and CSS color names here, and colors gain methods
that return adjusted copies: Color:darken, Color:lighten, Color:saturate,
Color:desaturate and Color:alpha. LerpColor interpolates between two colors, and the
util library gets util.hex_to_color and util.text_color_from_base.
Summary
Methods
alpha(amt)shared
Returns a copy of the color with a different alpha.
darken(amt)shared
Returns a darker copy of the color.
desaturate(percentage)shared
Returns a less saturated copy of the color.
lighten(amt)shared
Returns a lighter copy of the color.
saturate(percentage)shared
Returns a more saturated copy of the color.
saturation(amt)shared
Returns a copy of the color with its saturation multiplied by a factor.
Methods
Returns a copy of the color with a different alpha.
Parameters
- amt Number optional, defaults to
255new alpha, 0-255
Returns
- Color
Returns a darker copy of the color. Alpha is kept as-is.
Parameters
- amt Number amount to subtract from the red, green and blue channels
Returns
- Color
Returns a less saturated copy of the color.
Parameters
- percentage Number how much saturation to remove, in percent (clamped to 0-100)
Returns
- Color
See also
Returns a lighter copy of the color. Alpha is kept as-is.
Parameters
- amt Number amount to add to the red, green and blue channels
Returns
- Color
Returns a more saturated copy of the color.
Parameters
- percentage Number how much saturation to add, in percent
Returns
- Color
See also
Returns a copy of the color with its saturation multiplied by a factor.
Parameters
- amt Number saturation factor: 1 changes nothing, 0 removes all color, more than 1 saturates
Returns
- Color