🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
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.3
Source
npm
Version published
Maintainers
1
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

canvas

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