goldies
    Preparing search index...

    Function hexToRgb

    • Converts a hex color to its red, green and blue values.

      Parameters

      • hexCode: string

        A 3- or 6-digit hex color, such as #f80 or #ff8800. The leading # is optional, and case doesn't matter.

      Returns { b: number; g: number; r: number }

      The color's channels, each from 0 to 255.

      If hexCode isn't a 3- or 6-digit hex color.

      hexToRgb('#ff8000'); // { r: 255, g: 128, b: 0 }
      hexToRgb('fff'); // { r: 255, g: 255, b: 255 }