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

Returns a copy of the color with a different alpha.
Returns a darker copy of the color.
Returns a less saturated copy of the color.
Returns a lighter copy of the color.
Returns a more saturated copy of the color.
Returns a copy of the color with its saturation multiplied by a factor.

Methods

Color:alpha(amt)

shared lib/stdlib/sh_color.lua:296

Returns a copy of the color with a different alpha.

Parameters

  • amt Number optional, defaults to 255 new alpha, 0-255

Returns

  • Color

Color:darken(amt)

shared lib/stdlib/sh_color.lua:272

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

Color:desaturate(percentage)

shared lib/stdlib/sh_color.lua:264

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

Color:lighten(amt)

shared lib/stdlib/sh_color.lua:284

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

Color:saturate(percentage)

shared lib/stdlib/sh_color.lua:256

Returns a more saturated copy of the color.

Parameters

  • percentage Number how much saturation to add, in percent

Returns

  • Color

See also

Color:saturation(amt)

shared lib/stdlib/sh_color.lua:240

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

Defined in