Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

canvas-context

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-context

Create a RenderingContext (2d, webgl, webgl2, bitmaprenderer), optionally offscreen for possible use in a Worker.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
68
decreased by-45.16%
Maintainers
1
Weekly downloads
 
Created
Source

canvas-context stable

npm version styled with prettier

Create a RenderingContext (2d, webgl, webgl2, bitmaprenderer), optionally offscreen for possible use in a Worker.

See the demo and its source for an example with Worker implementation.

Installation

npm install canvas-context

NPM

Usage

const createCanvasContext = require("canvas-context");

const { context, canvas } = createCanvasContext("2d", {
	width: 100,
	height: 100,
	offscreen: true
});

API

createCanvasContext(contextType, options): { context: RenderingContext, canvas: HTMLCanvasElement }

type ContextType =
	| "2d"
	| "webgl"
	| "experimental-webgl"
	| "webgl2"
	| "bitmaprenderer";
OptionTypeDefaultDescription
contextTypeContextType"2d"Context identifier defining the drawing context associated to the canvas
options.canvasHTMLCanvasElement?An optional canvas. Necessary when window === "undefined" (eg. Node or Worker context)
options.widthnumber?300Set canvas.width (should be an integer >= 0)
options.heightnumber?150Set canvas.height (should be an integer >= 0)
options.offscreenboolean?falseCreate an OffscreenCanvas or transferControlToOffscreen() if options.canvas
options.workerboolean?falseTry to get an OffscreenCanvas and return only the canvas so it can be transferred in a Worker

License

MIT. See license file.

Keywords

FAQs

Package last updated on 29 Apr 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc