UNPKG

gl2d

Version:

2D graphics package for WebGL

389 lines (388 loc) 11.5 kB
import { PointLike } from "./point"; import { Struct } from "gulp-structify/struct"; import { StructBuffer } from "gulp-structify/buffer"; /** * A two-dimensional vector with (x,y) components. */ export declare class Vec2 { static fromPointToPoint(initial: PointLike, terminal: PointLike): Vec2; static create(other: Vec2Like): Vec2; /** * The X component of this Vec2. */ x: number; /** * The Y component of this Vec2. */ y: number; /** * A two-dimensional vector with (x,y) components. */ constructor(x?: number, y?: number); /** * Computes the length of this Vec2. */ length(): number; /** * Computes the length squared of this Vec2. */ length2(): number; /** * Sets this Vec2 to a vector from the initial point to the terminal point. */ setFromPointToPoint(initial: PointLike, terminal: PointLike): void; /** * Computes the dot product of this Vec2 with the other Vec2. */ dot(other: Vec2Like): number; /** * Computes the cross product of this Vec2 with the other Vec2. */ cross(other: Vec2Like): number; /** * Inverts this Vec2. */ invert(): void; /** * Normalizes this Vec2 so that it has a length of one. */ normalize(): void; /** * Rotates this Vec2 90 degrees to the left (CCW). */ rotateLeft(): void; /** * Rotates this Vec2 90 degrees to the right (CW). */ rotateRight(): void; /** * Sets each component of this Vec2 to that of the other Vec2. */ set(other: Vec2Like): void; /** * Sets each component of this Vec2. */ set$(x: number, y: number): void; /** * Sets each component of this Vec2 to the specified scalar. */ setScalar(k: number): void; /** * Adds the other Vec2 to this Vec2 componentwise. */ add(other: Vec2Like): void; /** * Adds the specified values to this Vec2 componentwise. */ add$(x: number, y: number): void; /** * Subtracts the other Vec2 from this Vec2 componentwise. */ subtract(other: Vec2Like): void; /** * Subtracts the specified values from this Vec2 componentwise. */ subtract$(x: number, y: number): void; /** * Multiplies each component of this Vec2 by the specified scalar. */ mulScalar(k: number): void; /** * Divides each component of this Vec2 by the specified scalar. */ divScalar(k: number): void; /** * Checks if each component of this Vec2 is exactly equal to that of the other Vec2. */ equals(other: Vec2Like): boolean; /** * Checks if each component of this Vec2 is exactly equal to the specified scalar. */ equalsScalar(k: number): boolean; /** * Checks if each component of this Vec2 is approximately equal to that of the other Vec2. */ epsilonEquals(other: Vec2Like, e: number): boolean; /** * Checks if each component of this Vec2 is approximately equal to the specified scalar. */ epsilonEqualsScalar(k: number, e: number): boolean; /** * Returns a string representation of this Vec2. */ toString(): string; } /** * A two-dimensional vector with (x,y) components. */ export interface Vec2Like { /** * The X component of this Vec2. */ x: number; /** * The Y component of this Vec2. */ y: number; } /** * A Vec2 backed by a Float32Array. */ export declare class Vec2Struct extends Struct<Float32Array> { static fromPointToPoint(initial: PointLike, terminal: PointLike): Vec2Struct; static create(other: Vec2Like): Vec2Struct; static create$(x: number, y: number): Vec2Struct; /** * Computes the length of this Vec2. */ length: () => number; /** * Computes the length squared of this Vec2. */ length2: () => number; /** * Sets this Vec2 to a vector from the initial point to the terminal point. */ setFromPointToPoint: (initial: PointLike, terminal: PointLike) => void; /** * Computes the dot product of this Vec2 with the other Vec2. */ dot: (other: Vec2Like) => number; /** * Computes the cross product of this Vec2 with the other Vec2. */ cross: (other: Vec2Like) => number; /** * Inverts this Vec2. */ invert: () => void; /** * Normalizes this Vec2 so that it has a length of one. */ normalize: () => void; /** * Rotates this Vec2 90 degrees to the left (CCW). */ rotateLeft: () => void; /** * Rotates this Vec2 90 degrees to the right (CW). */ rotateRight: () => void; /** * Sets each component of this Vec2 to that of the other Vec2. */ set: (other: Vec2Like) => void; /** * Sets each component of this Vec2. */ set$: (x: number, y: number) => void; /** * Sets each component of this Vec2 to the specified scalar. */ setScalar: (k: number) => void; /** * Adds the other Vec2 to this Vec2 componentwise. */ add: (other: Vec2Like) => void; /** * Adds the specified values to this Vec2 componentwise. */ add$: (x: number, y: number) => void; /** * Subtracts the other Vec2 from this Vec2 componentwise. */ subtract: (other: Vec2Like) => void; /** * Subtracts the specified values from this Vec2 componentwise. */ subtract$: (x: number, y: number) => void; /** * Multiplies each component of this Vec2 by the specified scalar. */ mulScalar: (k: number) => void; /** * Divides each component of this Vec2 by the specified scalar. */ divScalar: (k: number) => void; /** * Checks if each component of this Vec2 is exactly equal to that of the other Vec2. */ equals: (other: Vec2Like) => boolean; /** * Checks if each component of this Vec2 is exactly equal to the specified scalar. */ equalsScalar: (k: number) => boolean; /** * Checks if each component of this Vec2 is approximately equal to that of the other Vec2. */ epsilonEquals: (other: Vec2Like, e: number) => boolean; /** * Checks if each component of this Vec2 is approximately equal to the specified scalar. */ epsilonEqualsScalar: (k: number, e: number) => boolean; /** * Returns a string representation of this Vec2. */ toString: () => string; /** * Creates a Vec2 struct backed by the specified data. */ constructor(data?: Float32Array); /** * The X component of this Vec2. */ /** * The X component of this Vec2. */ x: number; /** * The Y component of this Vec2. */ /** * The Y component of this Vec2. */ y: number; } /** * A Vec2 buffer backed by a Float32Array. */ export declare class Vec2Buffer extends StructBuffer<Float32Array> { /** * Creates an empty Vec2 buffer with the specified Vec2 capacity. */ static create(capacity: number): Vec2Buffer; /** * Computes the length of this Vec2. */ length: () => number; /** * Computes the length squared of this Vec2. */ length2: () => number; /** * Sets this Vec2 to a vector from the initial point to the terminal point. */ setFromPointToPoint: (initial: PointLike, terminal: PointLike) => void; /** * Computes the dot product of this Vec2 with the other Vec2. */ dot: (other: Vec2Like) => number; /** * Computes the cross product of this Vec2 with the other Vec2. */ cross: (other: Vec2Like) => number; /** * Inverts this Vec2. */ invert: () => void; /** * Normalizes this Vec2 so that it has a length of one. */ normalize: () => void; /** * Rotates this Vec2 90 degrees to the left (CCW). */ rotateLeft: () => void; /** * Rotates this Vec2 90 degrees to the right (CW). */ rotateRight: () => void; /** * Sets each component of this Vec2 to that of the other Vec2. */ set: (other: Vec2Like) => void; /** * Sets each component of this Vec2. */ set$: (x: number, y: number) => void; /** * Sets each component of this Vec2 to the specified scalar. */ setScalar: (k: number) => void; /** * Adds the other Vec2 to this Vec2 componentwise. */ add: (other: Vec2Like) => void; /** * Adds the specified values to this Vec2 componentwise. */ add$: (x: number, y: number) => void; /** * Subtracts the other Vec2 from this Vec2 componentwise. */ subtract: (other: Vec2Like) => void; /** * Subtracts the specified values from this Vec2 componentwise. */ subtract$: (x: number, y: number) => void; /** * Multiplies each component of this Vec2 by the specified scalar. */ mulScalar: (k: number) => void; /** * Divides each component of this Vec2 by the specified scalar. */ divScalar: (k: number) => void; /** * Checks if each component of this Vec2 is exactly equal to that of the other Vec2. */ equals: (other: Vec2Like) => boolean; /** * Checks if each component of this Vec2 is exactly equal to the specified scalar. */ equalsScalar: (k: number) => boolean; /** * Checks if each component of this Vec2 is approximately equal to that of the other Vec2. */ epsilonEquals: (other: Vec2Like, e: number) => boolean; /** * Checks if each component of this Vec2 is approximately equal to the specified scalar. */ epsilonEqualsScalar: (k: number, e: number) => boolean; /** * Returns a string representation of this Vec2. */ toString: () => string; /** * The X component of the current Vec2. */ /** * The X component of the current Vec2. */ x: number; /** * The Y component of the current Vec2. */ /** * The Y component of the current Vec2. */ y: number; /** * Gets the number of properties in a Vec2, namely 2. */ structLength(): number; /** * Gets the components of the Vec2 at the specified position of this buffer. */ aget(position: number, dst?: Vec2Like): Vec2Like; /** * Gets the components of the current Vec2, then moves to the next position of this buffer. */ rget(dst?: Vec2Like): Vec2Like; /** * Sets each component of the Vec2 at the specified position to that of the src Vec2. */ aset(position: number, src: Vec2Like): void; /** * Sets each component of the Vec2 at the specified position. */ aset$(position: number, x: number, y: number): void; /** * Sets each component of the current Vec2 to that of the src Vec2, then moves to the next position of this buffer. */ rset(src: Vec2Like): void; /** * Sets each component of the current Vec2, then moves to the next position of this buffer. */ rset$(x: number, y: number): void; }