
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
color-normalize
Advanced tools
Convert any color argument (string, color, number, object etc.) to an array with channels data of desired output format.
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]
// ambivalent input
rgba([0,0,0]) // [0,0,0]
rgba([.5,.5,.5]) // [.5,.5,.5]
rgba([1,1,1]) // [1,1,1]
rgba([127,127,127]) // [.5,.5,.5]
rgba([255,255,255]) // [1,1,1]
Output format can be any dtype: uint8
, uint8_clamped
, array
, float32
, float64
etc. By default it converts to array
with 0..1
range values.
(c) 2017 Dima Yv. MIT License
FAQs
Convert any color data to sanitized output format
The npm package color-normalize receives a total of 245,553 weekly downloads. As such, color-normalize popularity was classified as popular.
We found that color-normalize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.