vanillajs-helpers

Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS

View the Project on GitHub Tokimon/vanillajs-helpers

vanillajs-helpers > “hexToRGB”

External module: “hexToRGB”

Index

Functions


Functions

hexToRGB

hexToRGB(hex: string): number[]

Defined in hexToRGB.ts:20

Converts a Hexadecimal color to a RGB(A) color array

hexToRGB('#2fd466'); // -> [47, 212, 102]

// And with alpha channel
hexToRGB('#2fd46680'); // -> [47, 212, 102, 0.5]

Parameters:

Param Type Description
hex string Hex color to convert to RGB

Returns: number[]