gl2d
Version:
2D graphics package for WebGL
451 lines (450 loc) • 14.2 kB
TypeScript
import { ColorLike } from "./color";
import { Struct } from "gulp-structify/struct";
import { StructBuffer } from "gulp-structify/buffer";
/**
* A 32-bit (r,g,b,a) color.
*/
export declare class ColorF {
static random(): ColorF;
static fromColor(src: ColorLike): ColorF;
static fromArgbString(argb: string): ColorF;
static fromRgbaInt(rgba: number): ColorF;
static create(other: ColorFLike): ColorF;
/**
* The red component of this ColorF.
*/
r: number;
/**
* The green component of this ColorF.
*/
g: number;
/**
* The blue component of this ColorF.
*/
b: number;
/**
* The alpha component of this ColorF.
*/
a: number;
/**
* A 32-bit (r,g,b,a) color.
*/
constructor(r?: number, g?: number, b?: number, a?: number);
/**
* Checks if this ColorF is fully opaque.
*/
isOpaque(): boolean;
/**
* Checks if this Color is fully transparent.
*/
isTransparent(): boolean;
/**
* Randomly sets the (r,g,b) components of this Color.
*/
setRandom(): void;
/**
* Extracts the (r,g,b,a) components of the specified Color into this ColorF.
*/
setFromColor(src: any): void;
/**
* Extracts the (r,g,b,a) components of the specified ARGB string into this ColorF.
* @param argb hexadecimal string of the form #aarrggbb.
*/
setFromArgbString(argb: string): void;
/**
* Creates an ARGB string from this specified ColorF's (r,g,b,a) components.
* @returns string of the form #aarrggbb
*/
toArgbString(): string;
/**
* Extracts the (r,g,b,a) components of the specified RGBA int into this ColorF.
* @param rgba integer of the form 0xrrggbbaa.
*/
setFromRgbaInt(rgba: number): void;
/**
* Creates an RGBA int with values extracted from this ColorF.
* @returns int of the form 0xrrggbbaa
*/
toRgbaInt(): number;
/**
* Premultiplies the (r,g,b) components of this ColorF by it's alpha component.
*/
premultiplyAlpha(): void;
/**
* Sets each component of this ColorF to that of the other ColorF.
*/
set(other: ColorFLike): void;
/**
* Sets each component of this ColorF.
*/
set$(r: number, g: number, b: number, a: number): void;
/**
* Sets each component of this ColorF to the specified scalar.
*/
setScalar(k: number): void;
/**
* Adds the other ColorF to this ColorF componentwise.
*/
add(other: ColorFLike): void;
/**
* Adds the specified values to this ColorF componentwise.
*/
add$(r: number, g: number, b: number, a: number): void;
/**
* Subtracts the other ColorF from this ColorF componentwise.
*/
subtract(other: ColorFLike): void;
/**
* Subtracts the specified values from this ColorF componentwise.
*/
subtract$(r: number, g: number, b: number, a: number): void;
/**
* Multiplies each component of this ColorF by the specified scalar.
*/
mulScalar(k: number): void;
/**
* Divides each component of this ColorF by the specified scalar.
*/
divScalar(k: number): void;
/**
* Checks if each component of this ColorF is exactly equal to that of the other ColorF.
*/
equals(other: ColorFLike): boolean;
/**
* Checks if each component of this ColorF is exactly equal to the specified scalar.
*/
equalsScalar(k: number): boolean;
/**
* Checks if each component of this ColorF is approximately equal to that of the other ColorF.
*/
epsilonEquals(other: ColorFLike, e: number): boolean;
/**
* Checks if each component of this ColorF is approximately equal to the specified scalar.
*/
epsilonEqualsScalar(k: number, e: number): boolean;
/**
* Returns a string representation of this ColorF.
*/
toString(): string;
}
/**
* A 32-bit (r,g,b,a) color.
*/
export interface ColorFLike {
/**
* The red component of this ColorF.
*/
r: number;
/**
* The green component of this ColorF.
*/
g: number;
/**
* The blue component of this ColorF.
*/
b: number;
/**
* The alpha component of this ColorF.
*/
a: number;
}
/**
* A ColorF backed by a Float32Array.
*/
export declare class ColorFStruct extends Struct<Float32Array> {
static random(): ColorFStruct;
static fromColor(src: ColorLike): ColorFStruct;
static fromArgbString(argb: string): ColorFStruct;
static fromRgbaInt(rgba: number): ColorFStruct;
static create(other: ColorFLike): ColorFStruct;
static create$(r: number, g: number, b: number, a: number): ColorFStruct;
/**
* Checks if this ColorF is fully opaque.
*/
isOpaque: () => boolean;
/**
* Checks if this Color is fully transparent.
*/
isTransparent: () => boolean;
/**
* Randomly sets the (r,g,b) components of this Color.
*/
setRandom: () => void;
/**
* Extracts the (r,g,b,a) components of the specified Color into this ColorF.
*/
setFromColor: (src: any) => void;
/**
* Extracts the (r,g,b,a) components of the specified ARGB string into this ColorF.
* @param argb hexadecimal string of the form #aarrggbb.
*/
setFromArgbString: (argb: string) => void;
/**
* Creates an ARGB string from this specified ColorF's (r,g,b,a) components.
* @returns string of the form #aarrggbb
*/
toArgbString: () => string;
/**
* Extracts the (r,g,b,a) components of the specified RGBA int into this ColorF.
* @param rgba integer of the form 0xrrggbbaa.
*/
setFromRgbaInt: (rgba: number) => void;
/**
* Creates an RGBA int with values extracted from this ColorF.
* @returns int of the form 0xrrggbbaa
*/
toRgbaInt: () => number;
/**
* Premultiplies the (r,g,b) components of this ColorF by it's alpha component.
*/
premultiplyAlpha: () => void;
/**
* Sets each component of this ColorF to that of the other ColorF.
*/
set: (other: ColorFLike) => void;
/**
* Sets each component of this ColorF.
*/
set$: (r: number, g: number, b: number, a: number) => void;
/**
* Sets each component of this ColorF to the specified scalar.
*/
setScalar: (k: number) => void;
/**
* Adds the other ColorF to this ColorF componentwise.
*/
add: (other: ColorFLike) => void;
/**
* Adds the specified values to this ColorF componentwise.
*/
add$: (r: number, g: number, b: number, a: number) => void;
/**
* Subtracts the other ColorF from this ColorF componentwise.
*/
subtract: (other: ColorFLike) => void;
/**
* Subtracts the specified values from this ColorF componentwise.
*/
subtract$: (r: number, g: number, b: number, a: number) => void;
/**
* Multiplies each component of this ColorF by the specified scalar.
*/
mulScalar: (k: number) => void;
/**
* Divides each component of this ColorF by the specified scalar.
*/
divScalar: (k: number) => void;
/**
* Checks if each component of this ColorF is exactly equal to that of the other ColorF.
*/
equals: (other: ColorFLike) => boolean;
/**
* Checks if each component of this ColorF is exactly equal to the specified scalar.
*/
equalsScalar: (k: number) => boolean;
/**
* Checks if each component of this ColorF is approximately equal to that of the other ColorF.
*/
epsilonEquals: (other: ColorFLike, e: number) => boolean;
/**
* Checks if each component of this ColorF is approximately equal to the specified scalar.
*/
epsilonEqualsScalar: (k: number, e: number) => boolean;
/**
* Returns a string representation of this ColorF.
*/
toString: () => string;
/**
* Creates a ColorF struct backed by the specified data.
*/
constructor(data?: Float32Array);
/**
* The red component of this ColorF.
*/
/**
* The red component of this ColorF.
*/
r: number;
/**
* The green component of this ColorF.
*/
/**
* The green component of this ColorF.
*/
g: number;
/**
* The blue component of this ColorF.
*/
/**
* The blue component of this ColorF.
*/
b: number;
/**
* The alpha component of this ColorF.
*/
/**
* The alpha component of this ColorF.
*/
a: number;
}
/**
* A ColorF buffer backed by a Float32Array.
*/
export declare class ColorFBuffer extends StructBuffer<Float32Array> {
/**
* Creates an empty ColorF buffer with the specified ColorF capacity.
*/
static create(capacity: number): ColorFBuffer;
/**
* Checks if this ColorF is fully opaque.
*/
isOpaque: () => boolean;
/**
* Checks if this Color is fully transparent.
*/
isTransparent: () => boolean;
/**
* Randomly sets the (r,g,b) components of this Color.
*/
setRandom: () => void;
/**
* Extracts the (r,g,b,a) components of the specified Color into this ColorF.
*/
setFromColor: (src: any) => void;
/**
* Extracts the (r,g,b,a) components of the specified ARGB string into this ColorF.
* @param argb hexadecimal string of the form #aarrggbb.
*/
setFromArgbString: (argb: string) => void;
/**
* Creates an ARGB string from this specified ColorF's (r,g,b,a) components.
* @returns string of the form #aarrggbb
*/
toArgbString: () => string;
/**
* Extracts the (r,g,b,a) components of the specified RGBA int into this ColorF.
* @param rgba integer of the form 0xrrggbbaa.
*/
setFromRgbaInt: (rgba: number) => void;
/**
* Creates an RGBA int with values extracted from this ColorF.
* @returns int of the form 0xrrggbbaa
*/
toRgbaInt: () => number;
/**
* Premultiplies the (r,g,b) components of this ColorF by it's alpha component.
*/
premultiplyAlpha: () => void;
/**
* Sets each component of this ColorF to that of the other ColorF.
*/
set: (other: ColorFLike) => void;
/**
* Sets each component of this ColorF.
*/
set$: (r: number, g: number, b: number, a: number) => void;
/**
* Sets each component of this ColorF to the specified scalar.
*/
setScalar: (k: number) => void;
/**
* Adds the other ColorF to this ColorF componentwise.
*/
add: (other: ColorFLike) => void;
/**
* Adds the specified values to this ColorF componentwise.
*/
add$: (r: number, g: number, b: number, a: number) => void;
/**
* Subtracts the other ColorF from this ColorF componentwise.
*/
subtract: (other: ColorFLike) => void;
/**
* Subtracts the specified values from this ColorF componentwise.
*/
subtract$: (r: number, g: number, b: number, a: number) => void;
/**
* Multiplies each component of this ColorF by the specified scalar.
*/
mulScalar: (k: number) => void;
/**
* Divides each component of this ColorF by the specified scalar.
*/
divScalar: (k: number) => void;
/**
* Checks if each component of this ColorF is exactly equal to that of the other ColorF.
*/
equals: (other: ColorFLike) => boolean;
/**
* Checks if each component of this ColorF is exactly equal to the specified scalar.
*/
equalsScalar: (k: number) => boolean;
/**
* Checks if each component of this ColorF is approximately equal to that of the other ColorF.
*/
epsilonEquals: (other: ColorFLike, e: number) => boolean;
/**
* Checks if each component of this ColorF is approximately equal to the specified scalar.
*/
epsilonEqualsScalar: (k: number, e: number) => boolean;
/**
* Returns a string representation of this ColorF.
*/
toString: () => string;
/**
* The red component of the current ColorF.
*/
/**
* The red component of the current ColorF.
*/
r: number;
/**
* The green component of the current ColorF.
*/
/**
* The green component of the current ColorF.
*/
g: number;
/**
* The blue component of the current ColorF.
*/
/**
* The blue component of the current ColorF.
*/
b: number;
/**
* The alpha component of the current ColorF.
*/
/**
* The alpha component of the current ColorF.
*/
a: number;
/**
* Gets the number of properties in a ColorF, namely 4.
*/
structLength(): number;
/**
* Gets the components of the ColorF at the specified position of this buffer.
*/
aget(position: number, dst?: ColorFLike): ColorFLike;
/**
* Gets the components of the current ColorF, then moves to the next position of this buffer.
*/
rget(dst?: ColorFLike): ColorFLike;
/**
* Sets each component of the ColorF at the specified position to that of the src ColorF.
*/
aset(position: number, src: ColorFLike): void;
/**
* Sets each component of the ColorF at the specified position.
*/
aset$(position: number, r: number, g: number, b: number, a: number): void;
/**
* Sets each component of the current ColorF to that of the src ColorF, then moves to the next position of this buffer.
*/
rset(src: ColorFLike): void;
/**
* Sets each component of the current ColorF, then moves to the next position of this buffer.
*/
rset$(r: number, g: number, b: number, a: number): void;
}