UNPKG

fast-color-generator

Version:

Super fast and efficient pseudo-random color generator, powered by a Linear Congruential Generator (LCG).

46 lines 1.19 kB
//#region src/index.d.ts interface RGB { r: number; g: number; b: number; } declare class FastColorGenerator { private state; /** * Creates an instance of FastColorGenerator. * @param seed - The seed value for the generator. Defaults to the current timestamp. */ constructor(seed?: number); /** * Generates the next pseudo-random color state. */ next(): void; /** * Gets the current color as a hex string (e.g., #rrggbb). */ get hex(): string; /** * Sets the color using a hex string (e.g., #rrggbb). * @param value - The hex color string to set. * @throws {Error} - If invalid hex color format was passed. */ set hex(value: string); /** * Gets the current color as an RGB object. */ get rgb(): RGB; /** * Sets the color using an RGB object. * @param value - The RGB object to set. */ set rgb(value: RGB); /** * Validates if a color channel value is between 0 and 255. * @param value - The channel value to validate. * @returns True if the value is valid, false otherwise. */ private isValidChannel; } //#endregion export { RGB, FastColorGenerator as default }; //# sourceMappingURL=index.d.mts.map