Function rgbToHex

  • Converts RGB values to a hex color code.

    Parameters

    • rgb: RGB

      An object with r, g, and b properties, and an optional a property.

    • OptionalincludeAlpha: boolean = false

      Whether to include the alpha channel in the hex string.

    Returns string

    The hex color code.

    If the input is not a valid RGB object or if RGB values are out of range.