@chriscodesthings/css-hex-color-to-rgba
v1.1.1
Published
Converts a CSS hex color code to RGBA values
Downloads
19
Readme
css-hex-color-to-rgba
Converts a CSS hex color code to RGBA values
Description
Converts a CSS hex color code to an array containing red, green, blue and alpha values.
See...
Install
npm install --save @chriscodesthings/css-hex-color-to-rgba
Use
import cssHexColorToRGBA from '@chriscodesthings/css-hex-color-to-rgba';
console.log(cssHexColorToRGBA("#6495ed"));
// => [ 100, 149, 237, 1 ]
Types
This package uses types from:
Syntax
cssHexColorToRGBA(color);
Parameters
- color: a CSS hex color code
Return Value
Returns an array containing the [red, green, blue, alpha]
values of color.
Red, green and blue values are in the range 0-255. Alpha value is in the range 0-1.
Examples
// switch colour to rgba
const rgba = cssHexColorToRGBA(color);
See Also...
- rgba-color-to-css-hex: Converts an RGB or RGBA color to a CSS hex color code
- random-css-hex-color: Generates a random color in CSS hex format
- is-css-hex-color: Determine if a string is a CSS hex color code
- color-object: Simple, lightweight class to store and manipulate a color, and convert between formats