rgb-color-utils
A simple utils library for RGB colors which provides some convenient methods such as color interpolation, gradient generation, etc.
Installation
npm install rgb-color-utils
or
yarn add rgb-color-utils
Example Usage
import { parseColor, interpolate, gradientColor } from 'rgb-color-utils';
const colorList = parseColor('#cdab85');
const newColor = interpolate('rgb(0, 23, 148)', '#febab5', 0.5);
const colorMap = gradientColor('#bca380', '#00f', 4);
API
parseColor(color)
color
one RGB/HEX color string (rgba(0, 23, 148)
or #bf0081
)
interpolate(from, to, step)
from
the starting position RGB/HEX color string (rgba(0, 23, 148)
or #bf0081
)to
the end position color stringstep
the normalized value (between 0 and 1) of the interpolation. A step of 0.5
would be the middle of from
and to
gradientColor(from, to, length)
from
the starting position RGB/HEX color string (rgba(0, 23, 148)
or #bf0081
)to
the end position color stringlength
the length of the gradient colors array.
License
MIT License