interpolate-rgb
v0.0.2
Published
Interpolate RGB colors.
Downloads
13
Maintainers
Readme
interpolate-rgb
Interpolate RGB colors.
Install
npm install interpolate-rgb
bower install interpolate-rgb
Usage
var interpolateRGB = require('interpolate-rgb');
// Get RGB color in middle of white and black colors
console.log(interpolateRGB([0, 0, 0], [255, 255, 255], 0.5)); // [127.5, 127.5, 127.5]
// with alpha channels
console.log(interpolateRGB([0, 0, 0, 0], [255, 255, 255, 1], 0.5)); // [127.5, 127.5, 127.5, 0.5]
// Using partial application
var interpolator = interpolateRGB([0, 0, 0], [255, 255, 255]);
console.log(interpolator(0.5)); // [127.5, 127.5, 127.5]
API
interpolateRGB(rgb1 /* array of rgb(a) values */, rgb2, t /* target value 0-1 */)
Test
npm test
License
MIT