1.0.2 • Published 6 years ago
Share package palettee Generates a random colour palette.
Check out the demo!
Installation npm install paletteeUsage 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 Key Type Default Description sizeNumber5 Number 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 Method Return Description palette(config = 5)Array[String] or PaletteGenerates a random palette. color(config = {})String or ColorGenerates a random color.
Palette Class variable Type Description colorsArray[Color]Array of colors in the palette. schemeStringThe scheme the palette was generated with.
Color Class variable Type Description 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).
Method Return Description isDark()BooleanWhether color is dark (value < 50). isLight()BooleanWhether color is light (value > 50). clone()ColorReturns a clone.
Static Method Return Description 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.