npm.io
1.1.3 • Published 4 years ago

@rdshah/colors

Licence
MIT
Version
1.1.3
Deps
0
Size
3 kB
Vulns
0
Weekly
0

colors

Generates a stream of colors that roughly maximizes contrast regardless of how many colors are generated.

getGenerator(format: "hex" | "rgb" | "rgba" | "raw")

Returns an object which generates colors in the specified format. Object has two methods

  • next // returns the next color and increments the state of the generator
  • peek // returns the next color without changing the state of the generator

Example usage

import { getGenerator } from "@rdshah/colors";

myGenerator = getGenerator('hex');
myGenerator.next(); // '#ff0000'
myGenerator.next(); // '#00ccff'
myGenerator.next(); // '#98ff00'
myGenerator.peek(); // '#ff0064'
myGenerator.next(); // '#ff0064'

myGenerator2 = getGenerator('hex');
myGenerator2.next(); // '#ff0000'

globalGenerator

Is an instatiation of getGenerator in the rgb format.

Keywords