canvas-hidden-transform
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

This is a microlibrary for enabling custom 'hidden' transformations on any CanvasRenderingContext2D. It is especially useful for rapidly implementing high-quality rendering, but can be used for various other scenarios, too. Example:

const addTransform = require('canvas-hidden-transform')
 
const canvas = document.createElement('canvas')
const ctxt = canvas.getContext('2d')
 
// this will translate any point by [10, 10]
const myTransform = [1, 0, 0, 1, 10, 10]
 
const myCtxt = addTransform(ctxt, myTransform)
 
myCtxt.translate(5, 3)
// will draw a rectangle from [15,13] to [20,18]
myCtxt.fillRect(0,0,5,5) 

For more information on how a transformation works, read this MDN article.

Package Sidebar

Install

npm i canvas-hidden-transform

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • samvv