color-rainbow

0.0.0 • Public • Published

color-rainbow

Rainbow!

Easily generate rainbow colors.

npm install color-rainbow

Example

var Rainbow = require('color-rainbow');
 
var numColors = 100;
var rainbowColors = Rainbow.create(numColors);
 
var html = '';
for (var i = 0; i < numColors; ++i) {
  var color = rainbowColors[i].hexString()
  html += '<div style:"background-color:"' + color + '"/>';
}

This generated the image above. (Source)

Docs

Note: All colors are stored using color.

Rainbow.create(numberOfColors)

Gets a list of colors that creates a full rainbow cycle (red to red).

numberOfColors: The number of colors that make up a full rainbow cycle.

var Rainbow = require('color-rainbow');
 
var colors = Rainbow.create(100);
 
for (var i = 0; i < colors.length; ++i) {
  console.log(colors[i].rgb());
}

new Rainbow(numberOfColors)

Creates a new rainbow object. This is useful when we want to store individual states of a rainbow and get the next color in the rainbow on demand.

numberOfColors: The number of colors that make up a full rainbow cycle.

.next()

Gets the next color of the rainbow wave

var Rainbow = require('color-rainbow');
 
var myRainbow = new Rainbow(6);
 
var red = myRainbow.next()
var orange = myRainbow.next()
var yellow = myRainbow.next()
var green = myRainbow.next()
var blue = myRainbow.next()
var purple = myRainbow.next()
// The next myRainbow.next() would be red

Testing

Run npm test.

Readme

Keywords

Package Sidebar

Install

npm i color-rainbow

Weekly Downloads

46

Version

0.0.0

License

MIT

Last publish

Collaborators

  • grant