1.0.2 • Published 5 years ago

palettee v1.0.2

Weekly downloads
9
License
ISC
Repository
github
Last release
5 years ago

palettee

Generates a random colour palette.

Check out the demo!

Installation

npm install palettee

Usage

Basic Usage

const Palettee = require("palettee"); 
const palettee = new Palettee();
palettee.palette(); // ["#000000", "#000000", "#000000", "#000000", "#000000"]
palettee.color(); // "#000000"

Configuration

You can pass a configuration object into the constructor:

const palettee = new Palettee({
      size: 3,
      format: "hex",
  });
palettee.palette(); // ["#000000", "#000000", "#000000"]
palettee.palette(); // ["#000000", "#000000", "#000000"]
palettee.palette(); // ["#000000", "#000000", "#000000"]

Or you can pass the configuration object into each palette() call. This will overwrite any configurations passed into the constructor for that single palette generator call:

const palettee = new Palettee();
const palette = palettee.palette(3); // ["#000000", "#000000", "#000000"]
const palette = palettee.palette({
    scheme: ["monochrome"],
    size: 3,
    format: "hex",
}); // ["#000000", "#000000", "#000000"]

Reference

Configuration Object

KeyTypeDefaultDescription
sizeNumber5Number of colors in the returned palette.
schemeString or Array[String]"monochrome", "contrast", "gradient", "gradient-multi"Schemes that are allowed to be used for generating palettes. The generated palette will choose a random scheme out of the ones supplied.
formatString"hex"Format of the returned palette. Possible values are: hex array of hex codes as stringspalettee Palettee's Palette class

Palettee

MethodReturnDescription
palette(config = 5)Array[String] or PaletteGenerates a random palette.
color(config = {})String or ColorGenerates a random color.

Palette

Class variableTypeDescription
colorsArray[Color]Array of colors in the palette.
schemeStringThe scheme the palette was generated with.

Color

Class variableTypeDescription
hsvArray[Number]Color in hsv form.
hNumberHue as a value between 0 and 360.
sNumberSaturation as a value between 0 and 100.
vNumberValue as a value between 0 and 100.
hexStringColor in hex form (string).
MethodReturnDescription
isDark()BooleanWhether color is dark (value < 50).
isLight()BooleanWhether color is light (value > 50).
clone()ColorReturns a clone.
Static MethodReturnDescription
generateRandom()ColorGives a random color.
generateComplement(color, variation = 0)ColorReturns the complement color as a Color object. variation reflects the amount of variation permitted in hue.
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago