UNPKG

gl2d

Version:

2D graphics package for WebGL

361 lines (360 loc) 11.7 kB
import { PointLike } from "./point"; import { Struct } from "gulp-structify/struct"; import { StructBuffer } from "gulp-structify/buffer"; /** * The line from (x1,y1) to (x2,y2). */ export declare class Line { static fromPointToPoint(p1: PointLike, p2: PointLike): Line; static create(other: LineLike): Line; /** * The X coordinate of the point at the start of this Line. */ x1: number; /** * The Y coordinate of the point at the start of this Line. */ y1: number; /** * The X coordinate of the point at the end of this Line. */ x2: number; /** * The Y coordinate of the point at the end of this Line. */ y2: number; /** * The line from (x1,y1) to (x2,y2). */ constructor(x1?: number, y1?: number, x2?: number, y2?: number); /** * Sets this line to the line from one point to another. */ setFromPointToPoint(p1: PointLike, p2: PointLike): void; /** * Checks if the distance from this line to the specified point is less than epsilon. */ contains(pt: PointLike, epsilon: number): boolean; /** * Checks if the distance from this line to (x,y) is less than epsilon. */ contains$(x: number, y: number, epsilon: number): boolean; /** * Sets each component of this Line to that of the other Line. */ set(other: LineLike): void; /** * Sets each component of this Line. */ set$(x1: number, y1: number, x2: number, y2: number): void; /** * Sets each component of this Line to the specified scalar. */ setScalar(k: number): void; /** * Adds the other Line to this Line componentwise. */ add(other: LineLike): void; /** * Adds the specified values to this Line componentwise. */ add$(x1: number, y1: number, x2: number, y2: number): void; /** * Subtracts the other Line from this Line componentwise. */ subtract(other: LineLike): void; /** * Subtracts the specified values from this Line componentwise. */ subtract$(x1: number, y1: number, x2: number, y2: number): void; /** * Multiplies each component of this Line by the specified scalar. */ mulScalar(k: number): void; /** * Divides each component of this Line by the specified scalar. */ divScalar(k: number): void; /** * Checks if each component of this Line is exactly equal to that of the other Line. */ equals(other: LineLike): boolean; /** * Checks if each component of this Line is exactly equal to the specified scalar. */ equalsScalar(k: number): boolean; /** * Checks if each component of this Line is approximately equal to that of the other Line. */ epsilonEquals(other: LineLike, e: number): boolean; /** * Checks if each component of this Line is approximately equal to the specified scalar. */ epsilonEqualsScalar(k: number, e: number): boolean; /** * Returns a string representation of this Line. */ toString(): string; } /** * The line from (x1,y1) to (x2,y2). */ export interface LineLike { /** * The X coordinate of the point at the start of this Line. */ x1: number; /** * The Y coordinate of the point at the start of this Line. */ y1: number; /** * The X coordinate of the point at the end of this Line. */ x2: number; /** * The Y coordinate of the point at the end of this Line. */ y2: number; } /** * A Line backed by a Float32Array. */ export declare class LineStruct extends Struct<Float32Array> { static fromPointToPoint(p1: PointLike, p2: PointLike): LineStruct; static create(other: LineLike): LineStruct; static create$(x1: number, y1: number, x2: number, y2: number): LineStruct; /** * Sets this line to the line from one point to another. */ setFromPointToPoint: (p1: PointLike, p2: PointLike) => void; /** * Checks if the distance from this line to the specified point is less than epsilon. */ contains: (pt: PointLike, epsilon: number) => boolean; /** * Checks if the distance from this line to (x,y) is less than epsilon. */ contains$: (x: number, y: number, epsilon: number) => boolean; /** * Sets each component of this Line to that of the other Line. */ set: (other: LineLike) => void; /** * Sets each component of this Line. */ set$: (x1: number, y1: number, x2: number, y2: number) => void; /** * Sets each component of this Line to the specified scalar. */ setScalar: (k: number) => void; /** * Adds the other Line to this Line componentwise. */ add: (other: LineLike) => void; /** * Adds the specified values to this Line componentwise. */ add$: (x1: number, y1: number, x2: number, y2: number) => void; /** * Subtracts the other Line from this Line componentwise. */ subtract: (other: LineLike) => void; /** * Subtracts the specified values from this Line componentwise. */ subtract$: (x1: number, y1: number, x2: number, y2: number) => void; /** * Multiplies each component of this Line by the specified scalar. */ mulScalar: (k: number) => void; /** * Divides each component of this Line by the specified scalar. */ divScalar: (k: number) => void; /** * Checks if each component of this Line is exactly equal to that of the other Line. */ equals: (other: LineLike) => boolean; /** * Checks if each component of this Line is exactly equal to the specified scalar. */ equalsScalar: (k: number) => boolean; /** * Checks if each component of this Line is approximately equal to that of the other Line. */ epsilonEquals: (other: LineLike, e: number) => boolean; /** * Checks if each component of this Line is approximately equal to the specified scalar. */ epsilonEqualsScalar: (k: number, e: number) => boolean; /** * Returns a string representation of this Line. */ toString: () => string; /** * Creates a Line struct backed by the specified data. */ constructor(data?: Float32Array); /** * The X coordinate of the point at the start of this Line. */ /** * The X coordinate of the point at the start of this Line. */ x1: number; /** * The Y coordinate of the point at the start of this Line. */ /** * The Y coordinate of the point at the start of this Line. */ y1: number; /** * The X coordinate of the point at the end of this Line. */ /** * The X coordinate of the point at the end of this Line. */ x2: number; /** * The Y coordinate of the point at the end of this Line. */ /** * The Y coordinate of the point at the end of this Line. */ y2: number; } /** * A Line buffer backed by a Float32Array. */ export declare class LineBuffer extends StructBuffer<Float32Array> { /** * Creates an empty Line buffer with the specified Line capacity. */ static create(capacity: number): LineBuffer; /** * Sets this line to the line from one point to another. */ setFromPointToPoint: (p1: PointLike, p2: PointLike) => void; /** * Checks if the distance from this line to the specified point is less than epsilon. */ contains: (pt: PointLike, epsilon: number) => boolean; /** * Checks if the distance from this line to (x,y) is less than epsilon. */ contains$: (x: number, y: number, epsilon: number) => boolean; /** * Sets each component of this Line to that of the other Line. */ set: (other: LineLike) => void; /** * Sets each component of this Line. */ set$: (x1: number, y1: number, x2: number, y2: number) => void; /** * Sets each component of this Line to the specified scalar. */ setScalar: (k: number) => void; /** * Adds the other Line to this Line componentwise. */ add: (other: LineLike) => void; /** * Adds the specified values to this Line componentwise. */ add$: (x1: number, y1: number, x2: number, y2: number) => void; /** * Subtracts the other Line from this Line componentwise. */ subtract: (other: LineLike) => void; /** * Subtracts the specified values from this Line componentwise. */ subtract$: (x1: number, y1: number, x2: number, y2: number) => void; /** * Multiplies each component of this Line by the specified scalar. */ mulScalar: (k: number) => void; /** * Divides each component of this Line by the specified scalar. */ divScalar: (k: number) => void; /** * Checks if each component of this Line is exactly equal to that of the other Line. */ equals: (other: LineLike) => boolean; /** * Checks if each component of this Line is exactly equal to the specified scalar. */ equalsScalar: (k: number) => boolean; /** * Checks if each component of this Line is approximately equal to that of the other Line. */ epsilonEquals: (other: LineLike, e: number) => boolean; /** * Checks if each component of this Line is approximately equal to the specified scalar. */ epsilonEqualsScalar: (k: number, e: number) => boolean; /** * Returns a string representation of this Line. */ toString: () => string; /** * The X coordinate of the point at the start of the current Line. */ /** * The X coordinate of the point at the start of the current Line. */ x1: number; /** * The Y coordinate of the point at the start of the current Line. */ /** * The Y coordinate of the point at the start of the current Line. */ y1: number; /** * The X coordinate of the point at the end of the current Line. */ /** * The X coordinate of the point at the end of the current Line. */ x2: number; /** * The Y coordinate of the point at the end of the current Line. */ /** * The Y coordinate of the point at the end of the current Line. */ y2: number; /** * Gets the number of properties in a Line, namely 4. */ structLength(): number; /** * Gets the components of the Line at the specified position of this buffer. */ aget(position: number, dst?: LineLike): LineLike; /** * Gets the components of the current Line, then moves to the next position of this buffer. */ rget(dst?: LineLike): LineLike; /** * Sets each component of the Line at the specified position to that of the src Line. */ aset(position: number, src: LineLike): void; /** * Sets each component of the Line at the specified position. */ aset$(position: number, x1: number, y1: number, x2: number, y2: number): void; /** * Sets each component of the current Line to that of the src Line, then moves to the next position of this buffer. */ rset(src: LineLike): void; /** * Sets each component of the current Line, then moves to the next position of this buffer. */ rset$(x1: number, y1: number, x2: number, y2: number): void; }