canvas-2d
v1.0.3
Published
grabs a new 2d canvas context
Downloads
7
Maintainers
Readme
2d-context
deprecated in favour of 2d-context
Creates a new canvas with a 2D context, returning the context.
var context = require('2d-context')()
var canvas = context.canvas
or
var canvas = document.createElement('canvas')
var context = require('2d-context')({
canvas: canvas,
alpha: true,
width: 256,
height: 256
})
Usage
ctx = require('2d-context')([opt])
Creates a new canvas with optional parameters:
canvas
a canvas element to use, otherwise creates a new elementwidth
a width to set, otherwise no changeheight
a height to set, otherwise no change- other attributes are passed to the getContext call, like
alpha
andstorage
You can then get a reference of the canvas element with ctx.canvas
.
License
MIT, see LICENSE.md for details.