I have a fixed width div with gradient applied using css. I want to build slider based color picker based on this gradient.
When i drag the slider i calculate the pe
There is a nice lib that handles variety of color manipulations chroma.js
yarn add chroma-js
And then
import chroma from 'chroma-js';
const f = chroma.scale(['yellow', 'red', 'black']);
console.log( f(0.25).toString() ); // #ff8000
console.log( f(0.5).css('rgba') ); // rgba(255,0,0,1)
console.log( f(0.75).css() ); // rgb(128,0,0)
console.log( f(1).css() ); // rgb(0,0,0)