the-world-engine
Version:
three.js based, unity like game engine for browser
129 lines (128 loc) • 3.52 kB
TypeScript
import { Matrix3 } from "three/src/Three";
import type { ReadonlyMatrix3 } from "../math/ReadonlyMatrix3";
import type { ReadonlyColor } from "./ReadonlyColor";
/**
* represents a color by its red, green, blue and alpha components in the range [0, 1]
*/
export declare class Color implements ReadonlyColor {
private _r;
private _g;
private _b;
private _a;
constructor();
constructor(r: number, g: number, b: number);
constructor(r: number, g: number, b: number, a: number);
/**
* set the color
* @param r red component
* @param g green component
* @param b blue component
* @param a alpha component
*/
set(r: number, g: number, b: number, a?: number): Color;
/**
* copy the color to this color
* @param color colot that copy to this color
*/
copy(color: ReadonlyColor): Color;
/**
* clone the color
*/
clone(): Color;
/**
* get the red component of the color
*/
get r(): number;
/**
* set the red component of the color
* value will be clamped between 0 and 1
*/
set r(value: number);
/**
* get the green component of the color
*/
get g(): number;
/**
* set the green component of the color
* value will be clamped between 0 and 1
*/
set g(value: number);
/**
* get the blue component of the color
*/
get b(): number;
/**
* set the blue component of the color
* value will be clamped between 0 and 1
*/
set b(value: number);
/**
* get the alpha component of the color
*/
get a(): number;
/**
* set the alpha component of the color
* value will be clamped between 0 and 1
*/
set a(value: number);
/**
* get the color as a string with the format rgb(r, g, b)
* r, g, b values is range [0, 255]
* @returns
*/
toString(): string;
/**
* get the color as a string with the format rgba(r, g, b, a)
* r, g, b values is range [0, 255]
* a value is range [0, 1]
* @returns
*/
toStringWithAlpha(): string;
/**
* get the color as a hex string with the format #rrggbb it loses alpha information
* @returns
*/
toHex(): string;
/**
* get the color as a hex string with the format #rrggbbaa
* @returns
*/
toHexWithAlpha(): string;
/**
* get the color as an array with the format [r, g, b, a]
* @returns
*/
toArray(): number[];
/**
* build a color from a hex string with the format #rrggbb alpha is set to 1
* @param hex
* @returns
*/
static fromHex(hex: string): Color;
/**
* build a color from an array with the format [r, g, b, a]
* @param array
* @returns
*/
static fromArray(array: number[]): Color;
/**
* build a color from a string with the format rgba(r, g, b, a)
* @param str
* @returns
*/
static fromString(str: string): Color;
hueRotate(angle?: number, buffer?: Matrix3): void;
grayscale(value?: number, buffer?: Matrix3): void;
sepia(value?: number, buffer?: Matrix3): void;
saturate(value?: number, buffer?: Matrix3): void;
brightness(value?: number): void;
contrast(value?: number): void;
invert(value?: number): void;
multiplyMatrix(matrix: ReadonlyMatrix3): Color;
linear(slope?: number, intercept?: number): Color;
hsl(): {
h: number;
s: number;
l: number;
};
}