Function toRGBATuple

  • Converts a hex number/string representing a color and an alpha value to an RGBA tuple.

    Example

    toRGBATuple('#fff', 0.5) // Returns '[255,255,255,0.5]'
    toRGBATuple('0x000', 1, '0x') // Returns '[0,0,0,1]'

    Parameters

    • val: string | number

      Hex number/string representing a color.

    • alpha: number

      The alpha level, between 0.0 - 1.0, inclusive.

    • prefix: HexStringPrefix = '#'

      Prefix of hex if using a string.

    Returns RGBATuple

    RGBA tuple in the format of [r, g, b, a].