JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 364943
  • Score
    100M100P100Q175478F
  • License MIT

Convert any color data to sanitized output format

Package Exports

  • color-normalize

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (color-normalize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

color-normalize Build Status

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

Usage

npm install color-normalize

const rgba = require('color-normalize')

rgba('red') // [1, 0, 0, 1]
rgba('rgb(80, 120, 160)', 'uint8') // Uint8Array<[80, 120, 160, 255]>
rgba('rgba(255, 255, 255, .5)', 'float64') // Float64Array<[1, 1, 1, .5]>
rgba('hsla(109, 50%, 50%, .75)', 'uint8') // Uint8Array<[87, 191, 64, 191]>
rgba(new Float32Array([0, 0.25, 0, 1]), 'uint8_clamped') // Uint8ClampedArray<[0, 64, 0, 255]>
rgba(new Uint8Array([0, 72, 0, 255]), 'array') // [0, 0.2823529411764706, 0, 1]

Output format can be any dtype: uint8, uint8_clamped, array, float32, float64 etc.

License

(c) 2017 Dima Yv. MIT License