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, gpupresent), optionally offscreen for possible use in a Worker.

  • 3.0.0
  • Source
  • npm
  • Socket score

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

canvas-context

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

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

paypal coinbase twitter

See the example and its source with a Worker implementation.

Installation

npm install canvas-context

Usage

import createCanvasContext from "canvas-context";

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

API

Modules

createCanvasContext

Typedefs

ContextType : "2d" | "webgl" | "experimental-webgl" | "webgl2" | "webgl2-compute" | "bitmaprenderer" | "gpupresent"

A DOMString containing the context identifier defining the drawing context associated to the canvas.

CanvasContextOptions : Object

Options for canvas creation. All optional.

CanvasContextReturnValue : Object

createCanvasContext

createCanvasContext([contextType], [options]) ⇒ CanvasContextReturnValue

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

Kind: Exported function

ParamTypeDefault
[contextType]ContextType"2d"
[options]CanvasContextOptions{}

ContextType : "2d" | "webgl" | "experimental-webgl" | "webgl2" | "webgl2-compute" | "bitmaprenderer" | "gpupresent"

A DOMString containing the context identifier defining the drawing context associated to the canvas.

Kind: global typedef

CanvasContextOptions : Object

Options for canvas creation. All optional.

Kind: global typedef
Properties

NameTypeDefaultDescription
[width]number300Request an initial canvas width.
[height]number150Request an initial canvas height.
[offscreen]booleanfalseRequest an offscreen canvas.
[worker]booleanfalseHandle use in a worker.
[contextAttributes]CanvasRenderingContext2DSettings | WebGLContextAttributes{}Attributes to be passed to getContext.

CanvasContextReturnValue : Object

Kind: global typedef
Properties

NameType
canvasHTMLCanvasElement | OffscreenCanvas
contextRenderingContext

License

MIT. See license file.

Keywords

FAQs

Package last updated on 18 Mar 2021

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