Converts an RGB or RGBA color to a CSS hex color code
npm install --save @chriscodesthings/rgba-color-to-css-hex
import rgbaColorToCSSHex from '@chriscodesthings/rgba-color-to-css-hex';
console.log(rgbaColorToCSSHex([100, 149, 237, 0.5])); // cornflowerblue with 50% transparency
// => #6495ed7f
rgbaColorToCSSHex([r, g, b, a]);
- r, g, b: red, green and blue values in the range 0-255
- a (optional): alpha value in the range 0-1
Returns a string containing a CSS hex color code converted from the RGBA values.
Does what it says on the tin.