@anderpang/matrix3.js
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

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;
}

Package Sidebar

Install

npm i @anderpang/matrix3.js

Weekly Downloads

3

Version

2.0.1

License

ISC

Unpacked Size

5.33 kB

Total Files

4

Last publish

Collaborators

  • anderpang