npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@omjs/matrix2d

v1.0.1

Published

CSS tranform-2D matrix

Downloads

1

Readme

Matrix2D

A class derived from @omjs/iterable for describing css 2D-transformation, which is featured by ECMAScript 2015 and Immutable, where a polyfill for Symbol is needed for old browsers.

  • Now version: 1.0.0

  • Publish date: 2018.06.08

Source Code 👉

INSTALL

npm

npm i @omjs/matrix2d

browser

<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
<script src="node_modules/@omjs/matrix2d/dist/matrix2D.min.js"></script>

USAGE

import { Matrix2D } from '@omjs/matrix2d';

QUICK START

import { Matrix2D, lmul } from '@omjs/matrix2d';
let mat1 = new Matrix2D(1, 0, 0, 1, 0, 0); // constructor => matrix(1,0,0,1,0,0)
// using babel-plugin-transform-function-bind
let mat2 = mat1::lmul([-1, 0, 0, -1, 0, 0]); // matrix muliply => matrix(-1,0,0,-1,0,0)
mat2.toString(); // => matrix(-1,0,0,-1,0,0)

LICENCE

MIT 👉


APIs

Contructor

Serveral Numbers, Number Arrays or Strings are allowed to create a Matrix2D Object.

Matrix2D([a=1],[b=0],[c=0],[d=1],[tx=0],[ty=0])

Matrix2D([array, [...]])

Matrix2D([string, [...]])

e.g.

let mat1 = new Matrix2D(); // matrix(1,0,0,1,0,0)
let mat2 = new Matrix2D(1, 0, 0, 1, 0, 0); // matrix(1,0,0,1,0,0)
let mat3 = new Matrix2D([1, 0, 0, 1, 0, 0]); // matrix(1,0,0,1)
let mat4 = new Matrix2D('matrix(1,0,0,1,0,0)'); // matrix(1,0,0,1,0,0)
let mat5 = new Matrix2D(mat1); // matrix(1,0,0,1,0,0)

Static Properties

Matrix2D.MUL_DIR

The direction of multiply.

  • Matrix2D.MUL_DIR.L - left
  • Matrix2D.MUL_DIR.R - Right

Matrix2D.ROTATE_DIR

The direction of rotate.

  • Matrix2D.ROTATE_DIR.CW - clockwise
  • Matrix2D.ROTATE_DIR.ACW - anticlockwise

version: string

The code version, current version is 1.0.0;

Properties

[]

Get the matrix's data by index.

e.g.

let mat = new Matrix2D();
mat[0]; // 1
mat[1]; // 0
mat[2]; // 0
mat[3]; // 1
mat[4]; // 0
mat[5]; // 0

Static Methods

Matrix2D.isMatrix2D(obj: any) => boolean

Check whether the obj's type is matrix2d or not;

e.g.

let mat = new Matrix2D(1, 0, 0, 1, 0, 0);
Matrix2D.isMatrix2D(mat); // true
Matrix2D.isMatrix2D([1, 0, 0, 1, 0, 0]); // false

Methods

toString() => string

Convert to string.

e.g.

let mat = new Matrix2D(1, 0, 0, 1, 0, 0);
mat.toString(); // matrix(1,0,0,1,0,0)

valueOf() => Array(6)

Get the value of matrix2d object

e.g.

let mat = new Matrix2D();
mat.valueOf(); // [1,0,0,1,0,0]

clone() => Matrix2D

Get a deep clone.

e.g.

let mat = new Matrix2D();
mat.clone(); // matrix(1,0,0,1,0,0);
mat == mat.clone(); // false

Operations

lmul(mat: Matrix2D | Array) => Matrix2D

Pre-multiplied by given matrix, and return a new Matrix2D, used to compose transformation.

e.g.

let mat = new Matrix2d();
mat::lmul([-1, 0, 0, -1, 0, 0]); // matrix(-1,0,0,-1,0,0)

rmul(mat: Matrix2D | Array) => Matrix2D

Post-multiplied by given matrix, and return a new Matrix2D, used to compose transformation.

e.g.

let mat = new Matrix2d();
mat::rmul([-1, 0, 0, -1, 0, 0]); // matrix(-1,0,0,-1,0,0)

mul(mat: Matrix2D | Array, dir: Matrix2D.MUL_DIR) => Matrix2D

Multiplied by given matrix and direction, and return a new Matrix2D, used to compose transformation.

e.g.

let mat = new Matrix2d();
mat::mul([-1, 0, 0, -1, 0, 0], Matrix2D.MUL_DIR.L); // matrix(-1,0,0,-1,0,0)

Click here to read the full APIs 👉