color-normalize

Convert any color argument (string, color, number, object etc.) to an array with channels data of desired output format.
Usage

const rgba = require('color-normalize')
rgba('red')
rgba('rgb(80, 120, 160)', 'uint8')
rgba('rgba(255, 255, 255, .5)', 'float64')
rgba('hsla(109, 50%, 50%, .75)', 'uint8')
rgba(new Float32Array([0, 0.25, 0, 1]), 'uint8_clamped')
rgba(new Uint8Array([0, 72, 0, 255]), 'array')
rgba([0,0,0])
rgba([.5,.5,.5])
rgba([1,1,1])
rgba([127,127,127])
rgba([255,255,255])
Output format can be any dtype: uint8, uint8_clamped, array, float32, float64 etc. By default it converts to array with 0..1 range values.
Related
License
(c) 2017 Dima Yv. MIT License