Module color

Color utilities

Functions

new (x, g, b, a) The public constructor.
from_hsv (h, s, v) Convert hue,saturation,value to color object.
from_hsva (h, s, v, a) Convert hue,saturation,value to color object.
invert (to) Invert a color.
lighten (to, amount) Lighten a color by a component-wise fixed amount (alpha unchanged)
lerp (at, at, s) Interpolate between two colors.
unpack (to) Unpack a color into individual components in 0-1.
as_255 (to) Unpack a color into individual components in 0-255.
darken (to, amount) Darken a color by a component-wise fixed amount (alpha unchanged)
multiply (to, to) Multiply a color's components by a value (alpha unchanged)
opacity (to, to) Multiply a color's alpha by a value
hue (to, to) Set a color's hue (saturation, value, alpha unchanged)
saturation (to, to) Set a color's saturation (hue, value, alpha unchanged)
value (to, to) Set a color's value (saturation, hue, alpha unchanged)
is_color (to) Check if color is valid
to_string (a) Return a formatted string.

Fields

hsv_to_color_table Convert hue,saturation,value table to color object.
color_to_hsv_table Convert color to hue,saturation,value table


Functions

new (x, g, b, a)
The public constructor.

Parameters:

  • x Can be of three types:
    number red component 0-1 table {r, g, b, a} nil for {0,0,0,0}
  • g number Green component 0-1
  • b number Blue component 0-1
  • a number Alpha component 0-1

Returns:

    color out
from_hsv (h, s, v)
Convert hue,saturation,value to color object.

Parameters:

  • h number hue 0-1
  • s number saturation 0-1
  • v number value 0-1

Returns:

    color out
from_hsva (h, s, v, a)
Convert hue,saturation,value to color object.

Parameters:

  • h number hue 0-1
  • s number saturation 0-1
  • v number value 0-1
  • a number alpha 0-1

Returns:

    color out
invert (to)
Invert a color.

Parameters:

  • to color invert

Returns:

    color out
lighten (to, amount)
Lighten a color by a component-wise fixed amount (alpha unchanged)

Parameters:

  • to color lighten
  • amount number to increase each component by, 0-1 scale

Returns:

    color out
lerp (at, at, s)
Interpolate between two colors.

Parameters:

  • at color end
  • at color end
  • s number in 0-1 progress between the two colors

Returns:

    color out
unpack (to)
Unpack a color into individual components in 0-1.

Parameters:

  • to color unpack

Returns:

  1. number r in 0-1
  2. number g in 0-1
  3. number b in 0-1
  4. number a in 0-1
as_255 (to)
Unpack a color into individual components in 0-255.

Parameters:

  • to color unpack

Returns:

  1. number r in 0-255
  2. number g in 0-255
  3. number b in 0-255
  4. number a in 0-255
darken (to, amount)
Darken a color by a component-wise fixed amount (alpha unchanged)

Parameters:

  • to color darken
  • amount number to decrease each component by, 0-1 scale

Returns:

    color out
multiply (to, to)
Multiply a color's components by a value (alpha unchanged)

Parameters:

  • to number multiply each component by
  • to number multiply each component by

Returns:

    color out
opacity (to, to)
Multiply a color's alpha by a value

Parameters:

  • to number multiply alpha by
  • to number multiply alpha by

Returns:

    color out
hue (to, to)
Set a color's hue (saturation, value, alpha unchanged)

Parameters:

  • to hue set 0-1
  • to hue set 0-1

Returns:

    color out
saturation (to, to)
Set a color's saturation (hue, value, alpha unchanged)

Parameters:

Returns:

    color out
value (to, to)
Set a color's value (saturation, hue, alpha unchanged)

Parameters:

Returns:

    color out
is_color (to)
Check if color is valid

Parameters:

  • to color test

Returns:

    boolean is color
to_string (a)
Return a formatted string.

Parameters:

  • a color color to be turned into a string

Returns:

    string formatted

Fields

hsv_to_color_table
Convert hue,saturation,value table to color object.
  • hsva table {hue 0-1, saturation 0-1, value 0-1, alpha 0-1}
color_to_hsv_table
Convert color to hue,saturation,value table
  • in color
generated by LDoc 1.4.6 Last updated 2022-05-07 22:53:35