1.0.0 • Published 8 years ago
rgb-color-utils v1.0.0
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-utilsor
yarn add rgb-color-utilsExample Usage
import { parseColor, interpolate, gradientColor } from 'rgb-color-utils';
const colorList = parseColor('#cdab85'); // [205, 171, 133]
const newColor = interpolate('rgb(0, 23, 148)', '#febab5', 0.5); // '#7f69a5'
const colorMap = gradientColor('#bca380', '#00f', 4); // ['#bca380', '#8d7aa0', '#5e52c0', '#2f29df']API
parseColor(color)
colorone RGB/HEX color string (rgba(0, 23, 148)or#bf0081)
interpolate(from, to, step)
fromthe starting position RGB/HEX color string (rgba(0, 23, 148)or#bf0081)tothe end position color stringstepthe normalized value (between 0 and 1) of the interpolation. A step of0.5would be the middle offromandto
gradientColor(from, to, length)
fromthe starting position RGB/HEX color string (rgba(0, 23, 148)or#bf0081)tothe end position color stringlengththe length of the gradient colors array.
License
MIT License
1.0.0
8 years ago