color-effects

A javascript class to generate color effects

Usage no npm install needed!

<script type="module">
  import colorEffects from 'https://cdn.skypack.dev/color-effects';
</script>

README

Color Effects

Codacy Badge Coverage Status npm npm npm

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.

Precondition

The library is implemented in ECMAScript 2015, so your project should support at least this version.

Installation

Install it via npm:

$ npm install color-effects

Usage

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)

Supported Effects

Rainbow

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)

Fade

Generate a color gradient from a color to another color:

// from red to blue
var colors = effects.fade('#ff0000', 'rgb(0, 0, 255)')

Random

Generate a collection of random colors:

var chaos = effects.random()

API

Check out the documentation for details.

License

MIT