@rdshah/colors

1.1.3 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i @rdshah/colors

Weekly Downloads

0

Version

1.1.3

License

MIT

Unpacked Size

3.23 kB

Total Files

4

Last publish

Collaborators

  • rdshah