This library contains a javascript class. The class provides several color effect generations and provides always an array with colors, whereby the color itself is an array containing a red, green and blue value.
The library is implemented in ECMAScript 2015, so your project should support at least this version.
Install it via npm:
$ npm install color-effects
Start with importing the module via:
var ColorEffects = require('color-effects')
Create an instance providing the number of pixels (lights, leds). This will be the number of colors in the returned array of each effect method.
// 32 pixels
var effects = new ColorEffects(32)
Generate a rainbow:
// generated array starts with red and ends with violet
var rainbow = effects.rainbow()
// reversed rainbow (from violet to red)
var rainbowReverse = effects.rainbow(true)
Generate a color gradient from a color to another color:
// from red to blue
var colors = effects.fade('#ff0000', 'rgb(0, 0, 255)')
Generate a collection of random colors:
var chaos = effects.random()
Check out the documentation for details.
MIT