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.