Skip to main content

colorBrightness

Callable

  • colorBrightness(color: Rgb): number

  • Returns the brightness of a color (from 0 to 255).

    @example
    const color = hexToRgb('#ffffff')
    const brightness = colorBrightness(color) // 255
    const backgroundColor = brightness >= 128 ? '#000' : '#fff'

    Parameters

    • color: Rgb

      An object that represents an RGB color.

    Returns number

    The brightness of the color.