UNPKG

gl2d

Version:

2D graphics package for WebGL

1,026 lines (1,025 loc) 40.4 kB
import { Point, PointLike } from "./point"; import { Rect } from "./rect"; import { Vec2Like } from "./vec2"; import { Struct } from "gulp-structify/struct"; import { StructBuffer } from "gulp-structify/buffer"; /** * Scale to fit options for a rect-to-rect matrix transformation. */ export declare const enum ScaleToFit { /** * Stretches the src rect to fit inside dst, then translates src.center() to dst.center(). */ Center = 0, /** * Stretches the src rect to fit inside dst, then translates src.bottomRight() to dst.bottomRight(). */ End = 1, /** * Scales the src rect to fit inside dst exactly, then translates src to dst. */ Fill = 2, /** * Stretches the src rect to fit inside dst, then translates src.topLeft() to dst.topLeft(). */ Start = 3, } /** * A 3x2 matrix for 2d transformations. */ export declare class Mat2d { static concat(left: Mat2dLike, right: Mat2dLike): Mat2d; static identity(): Mat2d; static rectToRect(src: Rect, dst: Rect, stf?: ScaleToFit): Mat2d; static rotate(radians: number, p?: PointLike): Mat2d; static rotateToPoint(start: PointLike, end: PointLike, p?: PointLike): Mat2d; static sinCos(sin: number, cos: number, p?: PointLike): Mat2d; static scale(sx: number, sy: number, p?: PointLike): Mat2d; static scaleToPoint(start: PointLike, end: PointLike, p?: PointLike): Mat2d; static stretch(ratio: number, p?: PointLike): Mat2d; static stretchToPoint(start: Point, end: Point, p?: Point): Mat2d; static stretchRotateToPoint(start: PointLike, end: PointLike, p?: PointLike): Mat2d; static translate(vec: Vec2Like): Mat2d; static translate$(dx: number, dy: number): Mat2d; static translateToPoint(start: PointLike, end: PointLike): Mat2d; static inverse(other: Mat2dLike): Mat2d; static create(other: Mat2dLike): Mat2d; /** * The first entry in the first column of this Mat2d. */ c1r1: number; /** * The second entry in the first column of this Mat2d. */ c1r2: number; /** * The first entry in the second column of this Mat2d. */ c2r1: number; /** * The second entry in the second column of this Mat2d. */ c2r2: number; /** * The first entry in the third column of this Mat2d. */ c3r1: number; /** * The second entry in the third column of this Mat2d. */ c3r2: number; /** * A 3x2 matrix for 2d transformations. */ constructor(c1r1?: number, c1r2?: number, c2r1?: number, c2r2?: number, c3r1?: number, c3r2?: number); /** * Computes the determinant of this Mat2d. */ determinant(): number; /** * Checks if this Mat2d is exactly equal to the identity. */ isIdentity(): boolean; /** * Sets this matrix to the result of multiplying the specified matrices from left to right. * @param left the left hand matrix. * @param right the right hand matrix. * @param dst where to store the result. */ setConcat(left: Mat2dLike, right: Mat2dLike): void; /** * Sets this Mat2d to the identity matrix. */ setIdentity(): void; /** * Sets this Mat2d to map src into dst using the specified scale to fit option. * @param src the source rectangle. * @param dst the destination rectangle. * @param stf the scale to fit option. Defaults to fill. */ setRectToRect(src: Rect, dst: Rect, stf?: ScaleToFit): void; /** * Sets this Mat2d to rotate by the specified angle, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param radians the angle of the rotation in radians. * @param p the pivot point. */ setRotate(radians: number, p?: PointLike): void; /** * Sets this Mat2d to rotate from the specified start point to the specified end point, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param start the start point (before rotation). * @param end the end point (after rotation). * @param p the pivot point. Defaults to (0,0). */ setRotateToPoint(start: PointLike, end: PointLike, p?: PointLike): void; /** * Sets this Mat2d to rotate by the specified sin and cos values, with a pivot point at p. * @param sin the sine of the rotation angle. * @param cos the cosine of the rotation angle. * @param p the pivot point. */ setSinCos(sin: number, cos: number, p?: PointLike): void; /** * Sets this Mat2d to scale by the specified width and height ratios, with a pivot point at p. * @param sx the percentage by which to scale in the horizontal direction. * @param sy the percentage by which to scale in the vertical direction. * @param p the pivot point. */ setScale(sx: number, sy: number, p?: PointLike): void; /** * Sets this Mat2d to scale from the specified start point to the specified end point, with a pivot point at p. * @param start the start point (before scale). * @param end the end point (after scale). * @param p the pivot point. Defaults to (0,0). */ setScaleToPoint(start: PointLike, end: PointLike, p?: PointLike): void; /** * Sets this Mat2d to stretch by the specified ratio, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param ratio the percentage by which to stretch in all directions. * @param p the pivot point. */ setStretch(ratio: number, p?: PointLike): void; /** * Sets this Mat2d to stretch from the specified start point to the specified end point, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param start: the start point (before stretch). * @param end: the end point (after stretch). * @param p the pivot point. Defaults to (0,0). */ setStretchToPoint(start: Point, end: Point, p?: Point): void; /** * Sets this Mat2d to stretch rotate from the specified start point to the specified end point, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param start the start point (before stretch rotation). * @param end the end point (after stretch rotation). * @param p the pivot point. Defaults to (0,0). */ setStretchRotateToPoint(start: PointLike, end: PointLike, p?: PointLike): void; /** * Sets this Mat2d to translate by the specified vector. */ setTranslate(vec: Vec2Like): void; /** * Sets this Mat2d to translate by the vector (dx,dy). */ setTranslate$(dx: number, dy: number): void; /** * Sets this Mat2d to translate from the specified start point to the specified end point. * @param start the start point (before translation). * @param end the end point (after translation). */ setTranslateToPoint(start: PointLike, end: PointLike): void; /** * Conjugates this Mat2d with a translation by the specified vector. */ conjugateByTranslation(vec: Vec2Like): void; /** * Conjugates this Mat2d with a translation by vector (dx,dy). * @param dx the vertical component of the translation vector. * @param dy the horizontal component of the translation vector. */ conjugateByTranslation$(dx: number, dy: number): void; /** * Sets this Mat2d to the inverse of the other Mat2d. */ setInverse(other: Mat2dLike): void; /** * Post concats this Mat2d by the other Mat2d: this = other * this. */ postConcat(other: Mat2dLike): void; /** * Pre concats this Mat2d by the other Mat2d: this = this * other. */ preConcat(other: Mat2dLike): void; /** * Post concats this Mat2d with a rotation by the specified angle in radians. * @param radians the angle in radians. */ postRotate(radians: number): void; /** * Pre concats this Mat2d with a rotation by the specified angle in radians. * @param radians the angle in radians. */ preRotate(radians: number): void; /** * Post concats this Mat2d with a scale of the specified width and height ratios. * @param sx the percentage by which to scale in the horizontal direction. * @param sy the percentage by which to scale in the vertical direction. */ postScale(sx: number, sy: number): void; /** * Pre concats this Mat2d with a scale of the specified width and height ratios. * @param sx the percentage by which to scale in the horizontal direction. * @param sy the percentage by which to scale in the vertical direction. */ preScale(sx: number, sy: number): void; /** * Post concats this Mat2d with a stretch of the specified ratio. * @param ratio the percentage by whih to stretch all in directions. */ postStretch(ratio: number): void; /** * Pre concats this Mat2d with a stretch of the specified ratio. * @param ratio the percentage by which to stretch all in directions. */ preStretch(ratio: number): void; /** * Post concats this Mat2d with a translation by the specified vector. */ postTranslate(vec: Vec2Like): void; /** * Post concats this Mat2d with a translation by vector (dx,dy). */ postTranslate$(dx: number, dy: number): void; /** * Post concats this Mat2d with a translation by vector (dx,dy). */ preTranslate(vec: Vec2Like): void; /** * Post concats this Mat2d with a translation by vector (dx,dy). */ preTranslate$(dx: number, dy: number): void; /** * Maps the source point and writes the result into dst. * @param src the point to map. * @param dst where to write the result. */ map(src: PointLike, dst: PointLike): void; /** * Maps the point (x,y) and writes the result into dst. * @param x the x coordinate of the point. * @param y the y coordinate of the point. * @param dst where to write the result. */ map$(x: number, y: number, dst: PointLike): void; /** * Maps a subset of points in the specified array. * @param src array of points to map. * @param srcOffset offset into src of the first point in the subset. * @param count the number of points to include. */ mapPoints(src: PointLike[], srcOffset?: number, count?: number): void; /** * Maps a subset of points in the specified array. * @param src array of points written as a series of (x,y) coordinates. * @param srcOffset offset into src of the first point in the subset. * @param count the number of points to include. */ mapPoints$(src: Float32Array, srcOffset?: number, count?: number): void; /** * Maps the src rect and writes the result into dst. * @param src the source rectangle. * @param dst the destination rectangle. */ mapRect(src: Rect, dst: Rect): void; /** * Sets each component of this Mat2d to that of the other Mat2d. */ set(other: Mat2dLike): void; /** * Sets each component of this Mat2d. */ set$(c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number): void; /** * Sets each component of this Mat2d to the specified scalar. */ setScalar(k: number): void; /** * Adds the other Mat2d to this Mat2d componentwise. */ add(other: Mat2dLike): void; /** * Adds the specified values to this Mat2d componentwise. */ add$(c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number): void; /** * Subtracts the other Mat2d from this Mat2d componentwise. */ subtract(other: Mat2dLike): void; /** * Subtracts the specified values from this Mat2d componentwise. */ subtract$(c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number): void; /** * Multiplies each component of this Mat2d by the specified scalar. */ mulScalar(k: number): void; /** * Divides each component of this Mat2d by the specified scalar. */ divScalar(k: number): void; /** * Checks if each component of this Mat2d is exactly equal to that of the other Mat2d. */ equals(other: Mat2dLike): boolean; /** * Checks if each component of this Mat2d is exactly equal to the specified scalar. */ equalsScalar(k: number): boolean; /** * Checks if each component of this Mat2d is approximately equal to that of the other Mat2d. */ epsilonEquals(other: Mat2dLike, e: number): boolean; /** * Checks if each component of this Mat2d is approximately equal to the specified scalar. */ epsilonEqualsScalar(k: number, e: number): boolean; /** * Returns a string representation of this Mat2d. */ toString(): string; } /** * A 3x2 matrix for 2d transformations. */ export interface Mat2dLike { /** * The first entry in the first column of this Mat2d. */ c1r1: number; /** * The second entry in the first column of this Mat2d. */ c1r2: number; /** * The first entry in the second column of this Mat2d. */ c2r1: number; /** * The second entry in the second column of this Mat2d. */ c2r2: number; /** * The first entry in the third column of this Mat2d. */ c3r1: number; /** * The second entry in the third column of this Mat2d. */ c3r2: number; } /** * A Mat2d backed by a Float32Array. */ export declare class Mat2dStruct extends Struct<Float32Array> { static concat(left: Mat2dLike, right: Mat2dLike): Mat2dStruct; static identity(): Mat2dStruct; static rectToRect(src: Rect, dst: Rect, stf?: ScaleToFit): Mat2dStruct; static rotate(radians: number, p?: PointLike): Mat2dStruct; static rotateToPoint(start: PointLike, end: PointLike, p?: PointLike): Mat2dStruct; static sinCos(sin: number, cos: number, p?: PointLike): Mat2dStruct; static scale(sx: number, sy: number, p?: PointLike): Mat2dStruct; static scaleToPoint(start: PointLike, end: PointLike, p?: PointLike): Mat2dStruct; static stretch(ratio: number, p?: PointLike): Mat2dStruct; static stretchToPoint(start: Point, end: Point, p?: Point): Mat2dStruct; static stretchRotateToPoint(start: PointLike, end: PointLike, p?: PointLike): Mat2dStruct; static translate(vec: Vec2Like): Mat2dStruct; static translate$(dx: number, dy: number): Mat2dStruct; static translateToPoint(start: PointLike, end: PointLike): Mat2dStruct; static inverse(other: Mat2dLike): Mat2dStruct; static create(other: Mat2dLike): Mat2dStruct; static create$(c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number): Mat2dStruct; /** * Computes the determinant of this Mat2d. */ determinant: () => number; /** * Checks if this Mat2d is exactly equal to the identity. */ isIdentity: () => boolean; /** * Sets this matrix to the result of multiplying the specified matrices from left to right. * @param left the left hand matrix. * @param right the right hand matrix. * @param dst where to store the result. */ setConcat: (left: Mat2dLike, right: Mat2dLike) => void; /** * Sets this Mat2d to the identity matrix. */ setIdentity: () => void; /** * Sets this Mat2d to map src into dst using the specified scale to fit option. * @param src the source rectangle. * @param dst the destination rectangle. * @param stf the scale to fit option. Defaults to fill. */ setRectToRect: (src: Rect, dst: Rect, stf?: ScaleToFit) => void; /** * Sets this Mat2d to rotate by the specified angle, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param radians the angle of the rotation in radians. * @param p the pivot point. */ setRotate: (radians: number, p?: PointLike) => void; /** * Sets this Mat2d to rotate from the specified start point to the specified end point, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param start the start point (before rotation). * @param end the end point (after rotation). * @param p the pivot point. Defaults to (0,0). */ setRotateToPoint: (start: PointLike, end: PointLike, p?: PointLike) => void; /** * Sets this Mat2d to rotate by the specified sin and cos values, with a pivot point at p. * @param sin the sine of the rotation angle. * @param cos the cosine of the rotation angle. * @param p the pivot point. */ setSinCos: (sin: number, cos: number, p?: PointLike) => void; /** * Sets this Mat2d to scale by the specified width and height ratios, with a pivot point at p. * @param sx the percentage by which to scale in the horizontal direction. * @param sy the percentage by which to scale in the vertical direction. * @param p the pivot point. */ setScale: (sx: number, sy: number, p?: PointLike) => void; /** * Sets this Mat2d to scale from the specified start point to the specified end point, with a pivot point at p. * @param start the start point (before scale). * @param end the end point (after scale). * @param p the pivot point. Defaults to (0,0). */ setScaleToPoint: (start: PointLike, end: PointLike, p?: PointLike) => void; /** * Sets this Mat2d to stretch by the specified ratio, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param ratio the percentage by which to stretch in all directions. * @param p the pivot point. */ setStretch: (ratio: number, p?: PointLike) => void; /** * Sets this Mat2d to stretch from the specified start point to the specified end point, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param start: the start point (before stretch). * @param end: the end point (after stretch). * @param p the pivot point. Defaults to (0,0). */ setStretchToPoint: (start: Point, end: Point, p?: Point) => void; /** * Sets this Mat2d to stretch rotate from the specified start point to the specified end point, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param start the start point (before stretch rotation). * @param end the end point (after stretch rotation). * @param p the pivot point. Defaults to (0,0). */ setStretchRotateToPoint: (start: PointLike, end: PointLike, p?: PointLike) => void; /** * Sets this Mat2d to translate by the specified vector. */ setTranslate: (vec: Vec2Like) => void; /** * Sets this Mat2d to translate by the vector (dx,dy). */ setTranslate$: (dx: number, dy: number) => void; /** * Sets this Mat2d to translate from the specified start point to the specified end point. * @param start the start point (before translation). * @param end the end point (after translation). */ setTranslateToPoint: (start: PointLike, end: PointLike) => void; /** * Conjugates this Mat2d with a translation by the specified vector. */ conjugateByTranslation: (vec: Vec2Like) => void; /** * Conjugates this Mat2d with a translation by vector (dx,dy). * @param dx the vertical component of the translation vector. * @param dy the horizontal component of the translation vector. */ conjugateByTranslation$: (dx: number, dy: number) => void; /** * Sets this Mat2d to the inverse of the other Mat2d. */ setInverse: (other: Mat2dLike) => void; /** * Post concats this Mat2d by the other Mat2d: this = other * this. */ postConcat: (other: Mat2dLike) => void; /** * Pre concats this Mat2d by the other Mat2d: this = this * other. */ preConcat: (other: Mat2dLike) => void; /** * Post concats this Mat2d with a rotation by the specified angle in radians. * @param radians the angle in radians. */ postRotate: (radians: number) => void; /** * Pre concats this Mat2d with a rotation by the specified angle in radians. * @param radians the angle in radians. */ preRotate: (radians: number) => void; /** * Post concats this Mat2d with a scale of the specified width and height ratios. * @param sx the percentage by which to scale in the horizontal direction. * @param sy the percentage by which to scale in the vertical direction. */ postScale: (sx: number, sy: number) => void; /** * Pre concats this Mat2d with a scale of the specified width and height ratios. * @param sx the percentage by which to scale in the horizontal direction. * @param sy the percentage by which to scale in the vertical direction. */ preScale: (sx: number, sy: number) => void; /** * Post concats this Mat2d with a stretch of the specified ratio. * @param ratio the percentage by whih to stretch all in directions. */ postStretch: (ratio: number) => void; /** * Pre concats this Mat2d with a stretch of the specified ratio. * @param ratio the percentage by which to stretch all in directions. */ preStretch: (ratio: number) => void; /** * Post concats this Mat2d with a translation by the specified vector. */ postTranslate: (vec: Vec2Like) => void; /** * Post concats this Mat2d with a translation by vector (dx,dy). */ postTranslate$: (dx: number, dy: number) => void; /** * Post concats this Mat2d with a translation by vector (dx,dy). */ preTranslate: (vec: Vec2Like) => void; /** * Post concats this Mat2d with a translation by vector (dx,dy). */ preTranslate$: (dx: number, dy: number) => void; /** * Maps the source point and writes the result into dst. * @param src the point to map. * @param dst where to write the result. */ map: (src: PointLike, dst: PointLike) => void; /** * Maps the point (x,y) and writes the result into dst. * @param x the x coordinate of the point. * @param y the y coordinate of the point. * @param dst where to write the result. */ map$: (x: number, y: number, dst: PointLike) => void; /** * Maps a subset of points in the specified array. * @param src array of points to map. * @param srcOffset offset into src of the first point in the subset. * @param count the number of points to include. */ mapPoints: (src: PointLike[], srcOffset?: number, count?: number) => void; /** * Maps a subset of points in the specified array. * @param src array of points written as a series of (x,y) coordinates. * @param srcOffset offset into src of the first point in the subset. * @param count the number of points to include. */ mapPoints$: (src: Float32Array, srcOffset?: number, count?: number) => void; /** * Maps the src rect and writes the result into dst. * @param src the source rectangle. * @param dst the destination rectangle. */ mapRect: (src: Rect, dst: Rect) => void; /** * Sets each component of this Mat2d to that of the other Mat2d. */ set: (other: Mat2dLike) => void; /** * Sets each component of this Mat2d. */ set$: (c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number) => void; /** * Sets each component of this Mat2d to the specified scalar. */ setScalar: (k: number) => void; /** * Adds the other Mat2d to this Mat2d componentwise. */ add: (other: Mat2dLike) => void; /** * Adds the specified values to this Mat2d componentwise. */ add$: (c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number) => void; /** * Subtracts the other Mat2d from this Mat2d componentwise. */ subtract: (other: Mat2dLike) => void; /** * Subtracts the specified values from this Mat2d componentwise. */ subtract$: (c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number) => void; /** * Multiplies each component of this Mat2d by the specified scalar. */ mulScalar: (k: number) => void; /** * Divides each component of this Mat2d by the specified scalar. */ divScalar: (k: number) => void; /** * Checks if each component of this Mat2d is exactly equal to that of the other Mat2d. */ equals: (other: Mat2dLike) => boolean; /** * Checks if each component of this Mat2d is exactly equal to the specified scalar. */ equalsScalar: (k: number) => boolean; /** * Checks if each component of this Mat2d is approximately equal to that of the other Mat2d. */ epsilonEquals: (other: Mat2dLike, e: number) => boolean; /** * Checks if each component of this Mat2d is approximately equal to the specified scalar. */ epsilonEqualsScalar: (k: number, e: number) => boolean; /** * Returns a string representation of this Mat2d. */ toString: () => string; /** * Creates a Mat2d struct backed by the specified data. */ constructor(data?: Float32Array); /** * The first entry in the first column of this Mat2d. */ /** * The first entry in the first column of this Mat2d. */ c1r1: number; /** * The second entry in the first column of this Mat2d. */ /** * The second entry in the first column of this Mat2d. */ c1r2: number; /** * The first entry in the second column of this Mat2d. */ /** * The first entry in the second column of this Mat2d. */ c2r1: number; /** * The second entry in the second column of this Mat2d. */ /** * The second entry in the second column of this Mat2d. */ c2r2: number; /** * The first entry in the third column of this Mat2d. */ /** * The first entry in the third column of this Mat2d. */ c3r1: number; /** * The second entry in the third column of this Mat2d. */ /** * The second entry in the third column of this Mat2d. */ c3r2: number; } /** * A Mat2d buffer backed by a Float32Array. */ export declare class Mat2dBuffer extends StructBuffer<Float32Array> { /** * Creates an empty Mat2d buffer with the specified Mat2d capacity. */ static create(capacity: number): Mat2dBuffer; /** * Computes the determinant of this Mat2d. */ determinant: () => number; /** * Checks if this Mat2d is exactly equal to the identity. */ isIdentity: () => boolean; /** * Sets this matrix to the result of multiplying the specified matrices from left to right. * @param left the left hand matrix. * @param right the right hand matrix. * @param dst where to store the result. */ setConcat: (left: Mat2dLike, right: Mat2dLike) => void; /** * Sets this Mat2d to the identity matrix. */ setIdentity: () => void; /** * Sets this Mat2d to map src into dst using the specified scale to fit option. * @param src the source rectangle. * @param dst the destination rectangle. * @param stf the scale to fit option. Defaults to fill. */ setRectToRect: (src: Rect, dst: Rect, stf?: ScaleToFit) => void; /** * Sets this Mat2d to rotate by the specified angle, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param radians the angle of the rotation in radians. * @param p the pivot point. */ setRotate: (radians: number, p?: PointLike) => void; /** * Sets this Mat2d to rotate from the specified start point to the specified end point, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param start the start point (before rotation). * @param end the end point (after rotation). * @param p the pivot point. Defaults to (0,0). */ setRotateToPoint: (start: PointLike, end: PointLike, p?: PointLike) => void; /** * Sets this Mat2d to rotate by the specified sin and cos values, with a pivot point at p. * @param sin the sine of the rotation angle. * @param cos the cosine of the rotation angle. * @param p the pivot point. */ setSinCos: (sin: number, cos: number, p?: PointLike) => void; /** * Sets this Mat2d to scale by the specified width and height ratios, with a pivot point at p. * @param sx the percentage by which to scale in the horizontal direction. * @param sy the percentage by which to scale in the vertical direction. * @param p the pivot point. */ setScale: (sx: number, sy: number, p?: PointLike) => void; /** * Sets this Mat2d to scale from the specified start point to the specified end point, with a pivot point at p. * @param start the start point (before scale). * @param end the end point (after scale). * @param p the pivot point. Defaults to (0,0). */ setScaleToPoint: (start: PointLike, end: PointLike, p?: PointLike) => void; /** * Sets this Mat2d to stretch by the specified ratio, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param ratio the percentage by which to stretch in all directions. * @param p the pivot point. */ setStretch: (ratio: number, p?: PointLike) => void; /** * Sets this Mat2d to stretch from the specified start point to the specified end point, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param start: the start point (before stretch). * @param end: the end point (after stretch). * @param p the pivot point. Defaults to (0,0). */ setStretchToPoint: (start: Point, end: Point, p?: Point) => void; /** * Sets this Mat2d to stretch rotate from the specified start point to the specified end point, with a pivot point at p. * @param m the Mat2d. Defaults to a new matrix. * @param start the start point (before stretch rotation). * @param end the end point (after stretch rotation). * @param p the pivot point. Defaults to (0,0). */ setStretchRotateToPoint: (start: PointLike, end: PointLike, p?: PointLike) => void; /** * Sets this Mat2d to translate by the specified vector. */ setTranslate: (vec: Vec2Like) => void; /** * Sets this Mat2d to translate by the vector (dx,dy). */ setTranslate$: (dx: number, dy: number) => void; /** * Sets this Mat2d to translate from the specified start point to the specified end point. * @param start the start point (before translation). * @param end the end point (after translation). */ setTranslateToPoint: (start: PointLike, end: PointLike) => void; /** * Conjugates this Mat2d with a translation by the specified vector. */ conjugateByTranslation: (vec: Vec2Like) => void; /** * Conjugates this Mat2d with a translation by vector (dx,dy). * @param dx the vertical component of the translation vector. * @param dy the horizontal component of the translation vector. */ conjugateByTranslation$: (dx: number, dy: number) => void; /** * Sets this Mat2d to the inverse of the other Mat2d. */ setInverse: (other: Mat2dLike) => void; /** * Post concats this Mat2d by the other Mat2d: this = other * this. */ postConcat: (other: Mat2dLike) => void; /** * Pre concats this Mat2d by the other Mat2d: this = this * other. */ preConcat: (other: Mat2dLike) => void; /** * Post concats this Mat2d with a rotation by the specified angle in radians. * @param radians the angle in radians. */ postRotate: (radians: number) => void; /** * Pre concats this Mat2d with a rotation by the specified angle in radians. * @param radians the angle in radians. */ preRotate: (radians: number) => void; /** * Post concats this Mat2d with a scale of the specified width and height ratios. * @param sx the percentage by which to scale in the horizontal direction. * @param sy the percentage by which to scale in the vertical direction. */ postScale: (sx: number, sy: number) => void; /** * Pre concats this Mat2d with a scale of the specified width and height ratios. * @param sx the percentage by which to scale in the horizontal direction. * @param sy the percentage by which to scale in the vertical direction. */ preScale: (sx: number, sy: number) => void; /** * Post concats this Mat2d with a stretch of the specified ratio. * @param ratio the percentage by whih to stretch all in directions. */ postStretch: (ratio: number) => void; /** * Pre concats this Mat2d with a stretch of the specified ratio. * @param ratio the percentage by which to stretch all in directions. */ preStretch: (ratio: number) => void; /** * Post concats this Mat2d with a translation by the specified vector. */ postTranslate: (vec: Vec2Like) => void; /** * Post concats this Mat2d with a translation by vector (dx,dy). */ postTranslate$: (dx: number, dy: number) => void; /** * Post concats this Mat2d with a translation by vector (dx,dy). */ preTranslate: (vec: Vec2Like) => void; /** * Post concats this Mat2d with a translation by vector (dx,dy). */ preTranslate$: (dx: number, dy: number) => void; /** * Maps the source point and writes the result into dst. * @param src the point to map. * @param dst where to write the result. */ map: (src: PointLike, dst: PointLike) => void; /** * Maps the point (x,y) and writes the result into dst. * @param x the x coordinate of the point. * @param y the y coordinate of the point. * @param dst where to write the result. */ map$: (x: number, y: number, dst: PointLike) => void; /** * Maps a subset of points in the specified array. * @param src array of points to map. * @param srcOffset offset into src of the first point in the subset. * @param count the number of points to include. */ mapPoints: (src: PointLike[], srcOffset?: number, count?: number) => void; /** * Maps a subset of points in the specified array. * @param src array of points written as a series of (x,y) coordinates. * @param srcOffset offset into src of the first point in the subset. * @param count the number of points to include. */ mapPoints$: (src: Float32Array, srcOffset?: number, count?: number) => void; /** * Maps the src rect and writes the result into dst. * @param src the source rectangle. * @param dst the destination rectangle. */ mapRect: (src: Rect, dst: Rect) => void; /** * Sets each component of this Mat2d to that of the other Mat2d. */ set: (other: Mat2dLike) => void; /** * Sets each component of this Mat2d. */ set$: (c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number) => void; /** * Sets each component of this Mat2d to the specified scalar. */ setScalar: (k: number) => void; /** * Adds the other Mat2d to this Mat2d componentwise. */ add: (other: Mat2dLike) => void; /** * Adds the specified values to this Mat2d componentwise. */ add$: (c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number) => void; /** * Subtracts the other Mat2d from this Mat2d componentwise. */ subtract: (other: Mat2dLike) => void; /** * Subtracts the specified values from this Mat2d componentwise. */ subtract$: (c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number) => void; /** * Multiplies each component of this Mat2d by the specified scalar. */ mulScalar: (k: number) => void; /** * Divides each component of this Mat2d by the specified scalar. */ divScalar: (k: number) => void; /** * Checks if each component of this Mat2d is exactly equal to that of the other Mat2d. */ equals: (other: Mat2dLike) => boolean; /** * Checks if each component of this Mat2d is exactly equal to the specified scalar. */ equalsScalar: (k: number) => boolean; /** * Checks if each component of this Mat2d is approximately equal to that of the other Mat2d. */ epsilonEquals: (other: Mat2dLike, e: number) => boolean; /** * Checks if each component of this Mat2d is approximately equal to the specified scalar. */ epsilonEqualsScalar: (k: number, e: number) => boolean; /** * Returns a string representation of this Mat2d. */ toString: () => string; /** * The first entry in the first column of the current Mat2d. */ /** * The first entry in the first column of the current Mat2d. */ c1r1: number; /** * The second entry in the first column of the current Mat2d. */ /** * The second entry in the first column of the current Mat2d. */ c1r2: number; /** * The first entry in the second column of the current Mat2d. */ /** * The first entry in the second column of the current Mat2d. */ c2r1: number; /** * The second entry in the second column of the current Mat2d. */ /** * The second entry in the second column of the current Mat2d. */ c2r2: number; /** * The first entry in the third column of the current Mat2d. */ /** * The first entry in the third column of the current Mat2d. */ c3r1: number; /** * The second entry in the third column of the current Mat2d. */ /** * The second entry in the third column of the current Mat2d. */ c3r2: number; /** * Gets the number of properties in a Mat2d, namely 6. */ structLength(): number; /** * Gets the components of the Mat2d at the specified position of this buffer. */ aget(position: number, dst?: Mat2dLike): Mat2dLike; /** * Gets the components of the current Mat2d, then moves to the next position of this buffer. */ rget(dst?: Mat2dLike): Mat2dLike; /** * Sets each component of the Mat2d at the specified position to that of the src Mat2d. */ aset(position: number, src: Mat2dLike): void; /** * Sets each component of the Mat2d at the specified position. */ aset$(position: number, c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number): void; /** * Sets each component of the current Mat2d to that of the src Mat2d, then moves to the next position of this buffer. */ rset(src: Mat2dLike): void; /** * Sets each component of the current Mat2d, then moves to the next position of this buffer. */ rset$(c1r1: number, c1r2: number, c2r1: number, c2r2: number, c3r1: number, c3r2: number): void; }