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

@playcanvas/canvas-mock

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@playcanvas/canvas-mock

Mock for HTMLCanvasElement and related classes

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
102
increased by32.47%
Maintainers
1
Weekly downloads
 
Created
Source

Canvas-Mock: A Mock for HTMLCanvasElement

The canvas-mock package recreates the HTMLCanvasElement API and is intended to be used in a Node.js environment. This makes it possible to run WebGL-based libraries server-side or to execute unit tests for WebGL codebases within Node.

It has been tested with the PlayCanvas Engine but other libraries should be compatible too.

Installation

Ensure you have node installed. Then:

npm install @playcanvas/canvas-mock

Usage

canvas-mock is currently only available as ES Modules. To use it, do:

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

const width = 500;
const height = 500;
const canvas = new HTMLCanvasElement(width, height);
const gl = canvas.getContext('webgl');

// Use WebGL API as normal

Currently, only webgl or 2d contexts can be requested (webgl2 is unavailable). The WebGL 1.0 implementation assumes a minimum supported spec (so no extensions are available and capabilities are restricted to the absolute minimum allowed by the WebGL 1.0 spec).

Keywords

FAQs

Package last updated on 03 Jan 2022

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