Module color

A collection of types and utilities for color spaces.

Functions

rgb (r, g, b, a) Generate an rgba color.

Tables

rgb RGBA

Class rgb

rgb:copy () Create a duplicate of this color object
rgb:hex (str, a) Set or return this color expressed as a hexadecimal string.
rgb:hsv (h, s, v, a) Set or return this color expressed as HSV.
rgb:hsl (h, s, l, a) Set or return this color expressed as HSL.
rgb:hsi (h, s, i, a) Set or return this color expressed as HSI.
rgb:xyz (x, y, z, a) Set or return this color expressed as CIE XYZ.
rgb:lab (l, a, b, alpha) Set or return this color expressed as L*a*b.
rgb:lch (l, c, h, a) Set or return this color expressed as Lch.
rgb:luminance () Return the perceptual luminance of this color.


Functions

rgb (r, g, b, a)
Generate an rgba color. This function takes many different forms: rgb(1, 0, 0, 0.2) generates red at 20% alpha rgb(1, 0, 0) generates red rgb(0.5, 0.2) generates 50% greyscale at 20% alpha rgb(0.5) generates 50% greyscale rgb("#FF0000"), rgb("#f00"), rgb("red") generate red rgb("#FF0000", 0.2), rgb("#f00", 0.2), rgb("red", 0.2) generate red at 20% alpha

Parameters:

  • r
  • g
  • b
  • a

Tables

rgb
RGBA

Class rgb

A color expressed as red, green, blue and alpha components.
rgb:copy ()
Create a duplicate of this color object

Returns:

    rgba
rgb:hex (str, a)
Set or return this color expressed as a hexadecimal string. e.g. c:hex() -> "FF0000" e.g. c:hex("FF0000")

Parameters:

  • str hex string
  • a alpha value
rgb:hsv (h, s, v, a)
Set or return this color expressed as HSV. also accepts optional alpha argument

Parameters:

  • h hue
  • s saturation
  • v value
  • a alpha value
rgb:hsl (h, s, l, a)
Set or return this color expressed as HSL. also accepts optional alpha argument

Parameters:

  • h hue
  • s saturation
  • l luminance
  • a alpha value
rgb:hsi (h, s, i, a)
Set or return this color expressed as HSI. also accepts optional alpha argument

Parameters:

  • h hue
  • s saturation
  • i intensity
  • a alpha value
rgb:xyz (x, y, z, a)
Set or return this color expressed as CIE XYZ. also accepts optional alpha argument

Parameters:

  • x
  • y
  • z
  • a alpha value
rgb:lab (l, a, b, alpha)
Set or return this color expressed as L*a*b. also accepts optional alpha argument

Parameters:

  • l
  • a
  • b
  • alpha alpha value
rgb:lch (l, c, h, a)
Set or return this color expressed as Lch. also accepts optional alpha argument

Parameters:

  • l luminance
  • c chroma
  • h hue
  • a alpha value
rgb:luminance ()
Return the perceptual luminance of this color. (does not take into account alpha value)
generated by LDoc 1.3.12