@f/to-rgba
v1.0.1
Published
Convert any color string to an RGBA array
Downloads
91
Readme
to-rgba
Convert any color string to an RGBA array
Installation
$ npm install @f/to-rgba
Usage
var toRgba = require('@f/to-rgba')
toRgba('hsl(214, 1, 0.5)') // -> [0, 110, 255, 1]
toRgba('hsv(74, 0.19, 0.41)') // -> [100, 105, 85, 1]
toRgba('rgba(128, 20, 30, 50%)') // -> [128, 20, 30, .50]
Recognized color encodings
Percentages
Where appropriate, values may be expressed as a percentage. They will be translated to their corresponding decimal equivalent. I.e. 20% -> .20.
API
toRgba(str)
str
- A CSS color string.
Returns: An array of [red, green, blue, alpha]
.
License
MIT