Log inGet started

color

The color namespace — the engine's Luau API reference for color.

The color namespace — 21 functions.

globals/color/complementary

globals/color/complementary(c: Color) -> Color

Complementary color — rotate hue 180° in Oklch space.

globals/color/darken

globals/color/darken(c: Color, amount: number) -> Color

Decrease the lightness of a color in Oklch perceptual space.

globals/color/desaturate

globals/color/desaturate(c: Color, amount: number) -> Color

Decrease the chroma (saturation) of a color in Oklch space.

globals/color/hex

globals/color/hex(hexString: string) -> Color?

Parse a hex color string into an sRGB color table. Accepts 3, 4, 6, or 8 hex digits with or without a leading # (e.g. "#f00", "f00f", "#ff0000", "ff000080"). Returns nil on parse failure.

globals/color/hsl

globals/color/hsl(h: number, s: number, l: number) -> Color

Build a color from HSL (h: 0-360, s: 0-1, l: 0-1). Returned as sRGB.

globals/color/hsla

globals/color/hsla(h: number, s: number, l: number, a: number) -> Color

Build a color from HSLA, returned as sRGB.

globals/color/hsv

globals/color/hsv(h: number, s: number, v: number) -> Color

Build a color from HSV (h: 0-360, s: 0-1, v: 0-1).

globals/color/lighten

globals/color/lighten(c: Color, amount: number) -> Color

Increase the lightness of a color in Oklch perceptual space.

globals/color/linear

globals/color/linear(r: number, g: number, b: number, a: number?) -> Color

Build a color from linear RGB values (not gamma-corrected), output converted to sRGB. Useful for GPU-correct blending. Alpha defaults to 1.

globals/color/mix

globals/color/mix(c1: Color, c2: Color, t: number) -> Color

Perceptually blend two colors in Oklch space — better than RGB mixing for gradients.

globals/color/mixRgb

globals/color/mixRgb(c1: Color, c2: Color, t: number) -> Color

Linearly blend two colors in sRGB space — simple, but not perceptually uniform. Prefer color.mix for natural gradients.

globals/color/oklch

globals/color/oklch(l: number, c: number, h: number) -> Color

Build a color from Oklch perceptual color space (l: 0-1, c: 0-0.4, h: 0-360). Ideal for perceptually uniform gradients and color manipulation.

globals/color/rgb

globals/color/rgb(r: number, g: number, b: number) -> Color

Build an sRGB color from CSS-style 0-255 RGB channels. Alpha defaults to 1. Channels are normalised to 0-1 on the way out so the result composes with every other color helper.

globals/color/rgba

globals/color/rgba(r: number, g: number, b: number, a: number) -> Color

Build an sRGB color from CSS-style 0-255 RGB channels with explicit alpha. RGB are normalised to 0-1; alpha is taken as-is in the 0-1 range.

globals/color/rotateHue

globals/color/rotateHue(c: Color, degrees: number) -> Color

Rotate the hue of a color by a given number of degrees in Oklch space.

globals/color/saturate

globals/color/saturate(c: Color, amount: number) -> Color

Increase the chroma (saturation) of a color in Oklch space.

globals/color/toHex

globals/color/toHex(c: Color) -> string

Convert a color to a hex string. Returns "#rrggbb" or "#rrggbbaa" if alpha is not 1.

globals/color/toHsl

globals/color/toHsl(c: Color) -> HslColor

Convert a color to HSL.

globals/color/toLinear

globals/color/toLinear(c: Color) -> Color

Convert a color from sRGB to linear RGB space — useful for GPU calculations that need linear-space values.

globals/color/toOklch

globals/color/toOklch(c: Color) -> OklchColor

Convert a color to Oklch perceptual color space.

globals/color/withAlpha

globals/color/withAlpha(c: Color, a: number) -> Color

Return a copy of a color with a different alpha value.

  • api
  • reference