Function toRGBAString

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

    Example

    toRGBAString('#fff', 0.5) // Returns 'rgba(255,255,255,0.5)'
    toRGBAString('0x000', 1, '0x') // Returns 'rgba(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 string

    RGBA string.