🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

2d-context

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

2d-context

grabs a new 2d canvas context

1.3.0
latest
Source
npm
Version published
Weekly downloads
16
-27.27%
Maintainers
1
Weekly downloads
 
Created
Source

2d-context

Grabs a CanvasRenderingContext2D, returning null if it doesn't exist. Similar to webgl-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

NPM

ctx = require('2d-context')([opt])

Gets a new canvas context with optional parameters:

  • canvas a canvas element to use, otherwise creates a new element
  • width a width to set, otherwise no change
  • height a height to set, otherwise no change
  • other attributes are passed to the getContext call, like alpha and storage

You can then get a reference of the canvas element with ctx.canvas.

License

MIT, see LICENSE.md for details.

Keywords

canvas

FAQs

Package last updated on 11 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts