2.0.1 • Published 2 years ago

@anderpang/matrix3.js v2.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Matrix3.js

JavaScript 2D matrix 3x3 library

Installation

$ npm i @anderpang/matrix3.js

Use

 import Matrix3 from "@anderpang/matrix3.js";

or

<script src="./Matrix3.js/Matrix3.js"></script>

Usage

matrix = Matrix3.translate(5, 0).scale(2);

gl.uniformMatrix3fv(loc, false, matrix.data);

METHODS

declare class Matrix3 {
    data: Float32Array;
    constructor(array?: ArrayLike<number> | ArrayBufferLike);
    static identity: (this: typeof Matrix3) => Matrix3;
    static translate: (this: typeof Matrix3, tx: number, ty: number) => Matrix3;
    static rotate: (this: typeof Matrix3, rad: number) => Matrix3;
    static scale: (this: typeof Matrix3, sx: number, sy?: number) => Matrix3;
    static projection: (this: typeof Matrix3, width: number, height: number) => Matrix3;

    zero(): this;
    identity(): this;
    copy(): Matrix3;
    copyFrom(from: Matrix3): this;
    multiply(m: Matrix3): this;
    translate(tx: number, ty: number): this;
    rotate(rad: number): this;
    scale(sx: number, sy?: number): this;
    transpose(): this;
}