UNPKG

gl2d

Version:

2D graphics package for WebGL

451 lines (450 loc) 14 kB
import { ColorFLike } from "./colorF"; import { Struct } from "gulp-structify/struct"; import { StructBuffer } from "gulp-structify/buffer"; /** * An 8-bit (r,g,b,a) color. */ export declare class Color { static random(): Color; static fromColorF(src: ColorFLike): Color; static fromArgbString(argb: string): Color; static fromRgbaInt(rgba: number): Color; static create(other: ColorLike): Color; /** * The red component of this Color. */ r: number; /** * The green component of this Color. */ g: number; /** * The blue component of this Color. */ b: number; /** * The alpha component of this Color. */ a: number; /** * An 8-bit (r,g,b,a) color. */ constructor(r?: number, g?: number, b?: number, a?: number); /** * Checks if this Color 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 ColorF into this color. */ setFromColorF(src: ColorFLike): void; /** * Extracts the (r,g,b,a) components of the specified ARGB string into this Color. * @param argb hexadecimal string of the form #aarrggbb. */ setFromArgbString(argb: string): void; /** * Creates an ARGB string from this Color'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 color. * @param rgba integer of the form 0xrrggbbaa. */ setFromRgbaInt(rgba: number): void; /** * Creates an RGBA int with this Color's (r,g,b,a) components. * @returns int of the form 0xrrggbbaa */ toRgbaInt(): number; /** * Blends the source color into this color using (src.alpha, 1-src.alpha) blend mode. */ blend(src: ColorLike): void; /** * Sets each component of this Color to that of the other Color. */ set(other: ColorLike): void; /** * Sets each component of this Color. */ set$(r: number, g: number, b: number, a: number): void; /** * Sets each component of this Color to the specified scalar. */ setScalar(k: number): void; /** * Adds the other Color to this Color componentwise. */ add(other: ColorLike): void; /** * Adds the specified values to this Color componentwise. */ add$(r: number, g: number, b: number, a: number): void; /** * Subtracts the other Color from this Color componentwise. */ subtract(other: ColorLike): void; /** * Subtracts the specified values from this Color componentwise. */ subtract$(r: number, g: number, b: number, a: number): void; /** * Multiplies each component of this Color by the specified scalar. */ mulScalar(k: number): void; /** * Divides each component of this Color by the specified scalar. */ divScalar(k: number): void; /** * Checks if each component of this Color is exactly equal to that of the other Color. */ equals(other: ColorLike): boolean; /** * Checks if each component of this Color is exactly equal to the specified scalar. */ equalsScalar(k: number): boolean; /** * Checks if each component of this Color is approximately equal to that of the other Color. */ epsilonEquals(other: ColorLike, e: number): boolean; /** * Checks if each component of this Color is approximately equal to the specified scalar. */ epsilonEqualsScalar(k: number, e: number): boolean; /** * Returns a string representation of this Color. */ toString(): string; } /** * An 8-bit (r,g,b,a) color. */ export interface ColorLike { /** * The red component of this Color. */ r: number; /** * The green component of this Color. */ g: number; /** * The blue component of this Color. */ b: number; /** * The alpha component of this Color. */ a: number; } /** * A Color backed by a Uint8Array. */ export declare class ColorStruct extends Struct<Uint8Array> { static random(): ColorStruct; static fromColorF(src: ColorFLike): ColorStruct; static fromArgbString(argb: string): ColorStruct; static fromRgbaInt(rgba: number): ColorStruct; static create(other: ColorLike): ColorStruct; static create$(r: number, g: number, b: number, a: number): ColorStruct; /** * Checks if this Color 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 ColorF into this color. */ setFromColorF: (src: ColorFLike) => void; /** * Extracts the (r,g,b,a) components of the specified ARGB string into this Color. * @param argb hexadecimal string of the form #aarrggbb. */ setFromArgbString: (argb: string) => void; /** * Creates an ARGB string from this Color'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 color. * @param rgba integer of the form 0xrrggbbaa. */ setFromRgbaInt: (rgba: number) => void; /** * Creates an RGBA int with this Color's (r,g,b,a) components. * @returns int of the form 0xrrggbbaa */ toRgbaInt: () => number; /** * Blends the source color into this color using (src.alpha, 1-src.alpha) blend mode. */ blend: (src: ColorLike) => void; /** * Sets each component of this Color to that of the other Color. */ set: (other: ColorLike) => void; /** * Sets each component of this Color. */ set$: (r: number, g: number, b: number, a: number) => void; /** * Sets each component of this Color to the specified scalar. */ setScalar: (k: number) => void; /** * Adds the other Color to this Color componentwise. */ add: (other: ColorLike) => void; /** * Adds the specified values to this Color componentwise. */ add$: (r: number, g: number, b: number, a: number) => void; /** * Subtracts the other Color from this Color componentwise. */ subtract: (other: ColorLike) => void; /** * Subtracts the specified values from this Color componentwise. */ subtract$: (r: number, g: number, b: number, a: number) => void; /** * Multiplies each component of this Color by the specified scalar. */ mulScalar: (k: number) => void; /** * Divides each component of this Color by the specified scalar. */ divScalar: (k: number) => void; /** * Checks if each component of this Color is exactly equal to that of the other Color. */ equals: (other: ColorLike) => boolean; /** * Checks if each component of this Color is exactly equal to the specified scalar. */ equalsScalar: (k: number) => boolean; /** * Checks if each component of this Color is approximately equal to that of the other Color. */ epsilonEquals: (other: ColorLike, e: number) => boolean; /** * Checks if each component of this Color is approximately equal to the specified scalar. */ epsilonEqualsScalar: (k: number, e: number) => boolean; /** * Returns a string representation of this Color. */ toString: () => string; /** * Creates a Color struct backed by the specified data. */ constructor(data?: Uint8Array); /** * The red component of this Color. */ /** * The red component of this Color. */ r: number; /** * The green component of this Color. */ /** * The green component of this Color. */ g: number; /** * The blue component of this Color. */ /** * The blue component of this Color. */ b: number; /** * The alpha component of this Color. */ /** * The alpha component of this Color. */ a: number; } /** * A Color buffer backed by a Uint8Array. */ export declare class ColorBuffer extends StructBuffer<Uint8Array> { /** * Creates an empty Color buffer with the specified Color capacity. */ static create(capacity: number): ColorBuffer; /** * Checks if this Color 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 ColorF into this color. */ setFromColorF: (src: ColorFLike) => void; /** * Extracts the (r,g,b,a) components of the specified ARGB string into this Color. * @param argb hexadecimal string of the form #aarrggbb. */ setFromArgbString: (argb: string) => void; /** * Creates an ARGB string from this Color'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 color. * @param rgba integer of the form 0xrrggbbaa. */ setFromRgbaInt: (rgba: number) => void; /** * Creates an RGBA int with this Color's (r,g,b,a) components. * @returns int of the form 0xrrggbbaa */ toRgbaInt: () => number; /** * Blends the source color into this color using (src.alpha, 1-src.alpha) blend mode. */ blend: (src: ColorLike) => void; /** * Sets each component of this Color to that of the other Color. */ set: (other: ColorLike) => void; /** * Sets each component of this Color. */ set$: (r: number, g: number, b: number, a: number) => void; /** * Sets each component of this Color to the specified scalar. */ setScalar: (k: number) => void; /** * Adds the other Color to this Color componentwise. */ add: (other: ColorLike) => void; /** * Adds the specified values to this Color componentwise. */ add$: (r: number, g: number, b: number, a: number) => void; /** * Subtracts the other Color from this Color componentwise. */ subtract: (other: ColorLike) => void; /** * Subtracts the specified values from this Color componentwise. */ subtract$: (r: number, g: number, b: number, a: number) => void; /** * Multiplies each component of this Color by the specified scalar. */ mulScalar: (k: number) => void; /** * Divides each component of this Color by the specified scalar. */ divScalar: (k: number) => void; /** * Checks if each component of this Color is exactly equal to that of the other Color. */ equals: (other: ColorLike) => boolean; /** * Checks if each component of this Color is exactly equal to the specified scalar. */ equalsScalar: (k: number) => boolean; /** * Checks if each component of this Color is approximately equal to that of the other Color. */ epsilonEquals: (other: ColorLike, e: number) => boolean; /** * Checks if each component of this Color is approximately equal to the specified scalar. */ epsilonEqualsScalar: (k: number, e: number) => boolean; /** * Returns a string representation of this Color. */ toString: () => string; /** * The red component of the current Color. */ /** * The red component of the current Color. */ r: number; /** * The green component of the current Color. */ /** * The green component of the current Color. */ g: number; /** * The blue component of the current Color. */ /** * The blue component of the current Color. */ b: number; /** * The alpha component of the current Color. */ /** * The alpha component of the current Color. */ a: number; /** * Gets the number of properties in a Color, namely 4. */ structLength(): number; /** * Gets the components of the Color at the specified position of this buffer. */ aget(position: number, dst?: ColorLike): ColorLike; /** * Gets the components of the current Color, then moves to the next position of this buffer. */ rget(dst?: ColorLike): ColorLike; /** * Sets each component of the Color at the specified position to that of the src Color. */ aset(position: number, src: ColorLike): void; /** * Sets each component of the Color at the specified position. */ aset$(position: number, r: number, g: number, b: number, a: number): void; /** * Sets each component of the current Color to that of the src Color, then moves to the next position of this buffer. */ rset(src: ColorLike): void; /** * Sets each component of the current Color, then moves to the next position of this buffer. */ rset$(r: number, g: number, b: number, a: number): void; }