@runejs/common
Version:
Common logging, networking, compression, and other miscellaneous functionality for RuneJS.
107 lines (106 loc) • 3.62 kB
TypeScript
import { Color } from './color';
export declare abstract class RGBValues extends Color<RGBValues> {
r: number;
g: number;
b: number;
abstract toString(): any;
}
/**
* A color within the RGB color space.
*/
export declare class RGB extends RGBValues {
/**
* Creates a new RGB(A) color instance from the given ARGB integer value.
* @param argb The ARGB integer to convert to RGB(A).
*/
constructor(argb: number);
/**
* Creates a new RGB(A) color instance from the given red, green, and blue values.
* @param red The amount of red in the color, from 0-255.
* @param green The amount of green in the color, from 0-255.
* @param blue The amount of blue in the color, from 0-255.
* @param alpha [optional] The alpha value of the color, from 0-255. Defaults to 255, fully opaque.
*/
constructor(red: number, green: number, blue: number, alpha?: number);
/**
* Checks to see if the given color matches this color.
* @param other The new color to check against the current color.
*/
equals(other: RGB): boolean;
/**
* Calculates the difference between two colors.
* @param other The new color to check against the current color.
*/
difference(other: RGB): number;
/**
* Adds the given color to the current one, creating a new color that is a mixture of the two.
* R + R, G + G, B + B. If any value exceeds 255, it will wrap back around to 0 and start over.
* @param other The color to add to the current color.
*/
add(other: RGB): void;
/**
* Calculates the hue value of this RGB(A) color.
*/
calculateHue(): number;
/**
* Calculates the saturation value of this RGB(A) color.
*/
calculateSaturation(): number;
toString(): string;
/**
* The minimum value found between R, G, and B.
*/
get min(): number;
/**
* The maximum value found between R, G, and B.
*/
get max(): number;
/**
* The RGBA integer representation of this color.
* Differing from `get argb()`, this variation places the alpha value at the end of the int instead of the front.<br>
* `int[red << 24, green << 16, blue << 8, alpha]`
*/
get rgba(): number;
/**
* The ARGB integer representation of this color.
* Differing from `get rgba()`, this variation places the alpha value at the front of the int instead of the end.<br>
* `int[alpha << 24, red << 16, green << 8, blue]`
*/
get argb(): number;
/**
* The decimal representations of R, G, and B within this color.<br>
* `R:G:B / 255`
*/
get decimalValues(): RGBValues;
/**
* The percentage representations of R, G, and B within this color.<br>
* `R:G:B / 255 * 100`
*/
get percentValues(): RGBValues;
/**
* Average of the R+G+B values within this color.<br>
* `(this.r + this.g + this.b) / 3`
*/
get value(): number;
/**
* Average of the R+G+B percentages within this color.<br>
* `(percentR + percentG + percentB) / 3`
*/
get intensity(): number;
/**
* The total value of R+G+B within this color.
*/
get total(): number;
/**
* The color's luminosity.
*/
get luminance(): number;
/**
* The color's grayscale rating.
*/
get grayscale(): number;
/**
* Whether or not the color is pure non-transparent black, hex `#000000`.
*/
get isPureBlack(): boolean;
}