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

canvas-matrix2d

v1.0.0

Published

matrix 2d util

Downloads

3

Readme

canvas-matrix2d

2d图形矩阵工具,通过矩阵,可以简单快捷的计算2d图形对象的平移、旋转,并自然的画在canvas上,并可以轻松的转换全局坐标和本地坐标。避免繁琐的三角函数数去计算对象的位置信息。

安装

npm install canvas-matrix2d
或者<script>标签直接引用  build/matrix2d.js

API

  • constructor(params) 构造,参数可以是空、Matrix2d对象、数组、字符串
new Matrix2d()
new Matrix2d(matrix)
new Matrix2d([a, b, c, d, e, f])
new Matrix2d('a, b, c, d, e, f')
  • translate(x, y) 平移,返回已新的Matrix2d对象
  • scale(x, y, cx, cy) 缩放
  • rotate(r, cx, cy) 旋转
  • multiply(matrix) 矩阵合并
  • transform(context2d) 将矩阵应用到context2d上
  • matrixTransform(point) 将矩阵应用到点上
  • world2local(point) 将全局坐标转成本地坐标
  • extract(point) 提取平移、旋转等信息
  • toArray() toArray
  • toString() toString

demo

  • https://ouch1985.github.io/matrix2d/demo/index.html
  • demo/index.js 演示了如果平移、旋转一个矩形对象;如果根据matrix全局坐标(鼠标坐标)是否落在平移、旋转后的矩形对象上