/** * A color manipulation object. * @category Math */ export declare class Color { private normalizedRGBA; /** * Creates a new Color instance. * @param r - A Color object or the red component [0 .. 255]. Defaults to 0. * @param g - The green component [0 .. 255]. Defaults to 0. * @param b - The blue component [0 .. 255]. Defaults to 0. * @param alpha - The alpha value [0.0 .. 1.0]. Defaults to 1. */ constructor(r?: Color | string | number, g?: number, b?: number, alpha?: number); /** * Gets the red component of the color. * @returns The red component [0 .. 255]. */ get r(): number; /** * Sets the red component of the color. * @param value - The red component [0 .. 255]. */ set r(value: number); /** * Gets the green component of the color. * @returns The green component [0 .. 255]. */ get g(): number; /** * Sets the green component of the color. * @param value - The green component [0 .. 255]. */ set g(value: number); /** * Gets the blue component of the color. * @returns The blue component [0 .. 255]. */ get b(): number; /** * Sets the blue component of the color. * @param value - The blue component [0 .. 255]. */ set b(value: number); /** * Gets the alpha component of the color. * @returns The alpha component [0.0 .. 1.0]. */ get alpha(): number; /** * Sets the alpha component of the color. * @param value - The alpha component [0.0 .. 1.0]. */ set alpha(value: number); /** * Sets the color to the specified values. * @param r - The red component [0 .. 255]. * @param g - The green component [0 .. 255]. * @param b - The blue component [0 .. 255]. * @param [alpha] - The alpha value [0.0 .. 1.0]. Defaults to 1. * @returns Reference to this object for method chaining. */ setColor(r?: number, g?: number, b?: number, alpha?: number): this; /** * Sets the color to the specified normalized float values. * @param r - The red component [0.0 .. 1.0]. * @param g - The green component [0.0 .. 1.0]. * @param b - The blue component [0.0 .. 1.0]. * @param [alpha=1.0] - The alpha value [0.0 .. 1.0]. Defaults to 1. * @returns Reference to this object for method chaining. */ setFloat(r: number, g: number, b: number, alpha?: number): this; /** * Sets the color to the specified HSV values. * @param h - The hue [0 .. 1]. * @param s - The saturation [0 .. 1]. * @param v - The value [0 .. 1]. * @returns Reference to this object for method chaining. */ setHSV(h: number, s: number, v: number): this; /** * Sets the color from HSL values, **with hue in `[0..1]`** (the * GLSL / WebGL shader convention — `0 = red`, `1/3 = green`, * `2/3 = blue`, `1` = back to red). If you're coming from CSS / * Photoshop / D3 and have a hue in degrees (`0..360`), divide by * 360 first — or call {@link Color#setHSLDeg} which does it for you. * * Hue wraps at integer boundaries, so `h = 1` and `h = 0` produce * the same red. Saturation `0` short-circuits to a grey at the * requested lightness, ignoring hue. Lightness `0` or `1` produce * pure black or pure white regardless of the other two. * @param h - The hue, normalized to `[0..1]` (NOT degrees). * @param s - The saturation `[0..1]`. * @param l - The lightness `[0..1]`. * @returns Reference to this object for method chaining. * @see {@link Color#setHSLDeg} for the degrees-based variant. * @example * // pure green (hue 1/3, full saturation, mid lightness) * color.setHSL(1 / 3, 1, 0.5); * // CSS hsl(200deg, 80%, 60%) — divide hue by 360 first * color.setHSL(200 / 360, 0.8, 0.6); */ setHSL(h: number, s: number, l: number): this; /** * Sets the color from HSL values with **hue in degrees `[0..360]`** * — the CSS / Photoshop / D3 convention. Thin convenience wrapper * over {@link Color#setHSL}: divides `hDeg` by 360 and delegates. * Saturation and lightness stay in `[0..1]` (the same units CSS * percentages would normalize to). * * Use this when you're working from CSS color values, color-picker * output, or any standard color reference. Prefer {@link Color#setHSL} * when your hue is already normalized (e.g. from `Math.random()`, * a noise function, or a shader uniform). * @param hDeg - The hue in degrees `[0..360]`. Values outside the * range are accepted (the underlying hue calc wraps). * @param s - The saturation `[0..1]`. * @param l - The lightness `[0..1]`. * @returns Reference to this object for method chaining. * @example * // CSS hsl(200deg, 80%, 60%) * color.setHSLDeg(200, 0.8, 0.6); * // 360° wraps back to red — same as setHSLDeg(0, ...) * color.setHSLDeg(360, 1, 0.5); */ setHSLDeg(hDeg: number, s: number, l: number): this; /** * Creates a new copy of this color object. * @returns Reference to the newly cloned object. */ clone(): Color; /** * Copies a color object or CSS color into this one. * @param color - The color to copy. * @returns Reference to this object for method chaining. */ copy(color: Color | string): this; /** * Blends this color with the given one using addition. * @param color - The color to blend with. * @returns Reference to this object for method chaining. */ add(color: Color): this; /** * Darkens this color value by a given scale. * @param scale - The scale to darken the color by [0 .. 1]. * @returns Reference to this object for method chaining. */ darken(scale: number): this; /** * Linearly interpolates between this color and the given one. * @param color - The color to interpolate with. * @param alpha - The interpolation factor, with alpha = 0 being this color, and alpha = 1 being the given one. * @returns Reference to this object for method chaining. */ lerp(color: Color, alpha: number): this; /** * Lightens this color value by a given scale * @param scale - The scale to lighten the color by [0 .. 1]. * @returns Reference to this object for method chaining. */ lighten(scale: number): this; /** * Generate random r,g,b values for this color object * @param [min] - minimum value for the random range * @param [max] - maxmium value for the random range * @returns Reference to this object for method chaining */ random(min?: number, max?: number): this; /** * Checks if this color is equal to another. * @param color - The color to compare with. * @returns True if the colors are equal, otherwise false. */ equals(color: Color): boolean; /** * Parse a CSS color name and set this color to the corresponding r,g,b values * @param cssColor - The CSS color name * @returns Reference to this object for method chaining */ parseCSS(cssColor: string): this; /** * Parse an RGB or RGBA CSS color string * @param rgbColor - The RGB or RGBA color string to parse * @returns Reference to this object for method chaining */ parseRGB(rgbColor: string): this; /** * Parse a Hex color ("#RGB", "#RGBA" or "#RRGGBB", "#RRGGBBAA" format) and set this color to * the corresponding r,g,b,a values * @param hexColor - The Hex color string to parse * @param [argb] - true if format is #ARGB, or #AARRGGBB (as opposed to #RGBA or #RGGBBAA) * @returns Reference to this object for method chaining */ parseHex(hexColor: `#${string}`, argb?: boolean): this; /** * Pack this color RGB components into a Uint32 ARGB representation * @param [alpha] - alpha value [0.0 .. 1.0] * @returns A Uint32 ARGB representation of this color */ toUint32(alpha?: number): number; /** * return a Float Array representation of this object * @returns A Float Array representation of this color */ toArray(): Float32Array; /** * return the color in "#RRGGBB" format * @returns The color in "#RRGGBB" format */ toHex(): string; /** * Get the color in "#RRGGBBAA" format * @param alpha - The alpha value [0.0 .. 1.0] to use in the output string. * @returns The color in "#RRGGBBAA" format */ toHex8(alpha?: number): string; /** * Get the color in "rgb(R,G,B)" format * @returns The color in "rgb(R,G,B)" format */ toRGB(): `rgb(${number},${number},${number})`; /** * Get the color in "rgba(R,G,B,A)" format * @param [alpha] - alpha value [0.0 .. 1.0] * @returns The color in "rgba(R,G,B,A)" format */ toRGBA(alpha?: number): `rgba(${number},${number},${number},${number})`; } export declare const colorPool: import("../system/pool.ts").Pool; //# sourceMappingURL=color.d.ts.map