Socket
Socket
Sign inDemoInstall

color-rainbow

Package Overview
Dependencies
3
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    color-rainbow

Easily generate rainbow colors


Version published
Weekly downloads
78
decreased by-18.75%
Maintainers
1
Install size
190 kB
Created
Weekly downloads
 

Readme

Source

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.

Keywords

FAQs

Last updated on 29 Jun 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc