ledutils v0.1.2
ledutils
A small collection of utilities to make it easier to work with node-pixel, including mapping an array of onecolor objects to the strip, color range generation, gradient generation (soon).
Many of these functions are javascript ports of the functions that exist in FastLED.
examples
See the examples directory.
usage
fill_solid
fill_solid fills the entire array with a specific color
fill_rainbow
fill_rainbow generates a rainbow of color by manipulating the hue with a delta degree between them.
var leds = require('ledutils');
var colors = new Array(5);
leds.fill_rainbow({
arr: colors,
initialHue: 0,
hueDelta: 45
});
The previous code will generate the following colors in the array:
fill_gradient
fill_gradient fills the entire array with a gradient [startColor,endColor)
var leds = require('ledutils');
var colors = new Array(5);
leds.fill_gradient({
arr: colors,
startColor: 'blue',
endColor: 'orange'
});
The previous code will generate the following colors in the array:
led_map
led_map takes an array of colors and maps it into a node-pixel strip. It can be offset so that the strip can be represented by multiple arrays that you then map into the strip.
// Assume a node-pixel strip exists
var leds = require('ledutils');
var colors = new Array(5);
leds.fill_rainbow({arr: colors, initialHue: 0, hueDelta: 45);
leds.led_map({arr: colors, strip: strip, offset: 3});
The above example will display the rainbow in colors starting on led 3 of the strip. If the strip is less then 8 leds, the rainbow will not be complete.