vega-canvas
Canvas and Image utilities.
Last updated 3 years ago by jheer .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install vega-canvas 
SYNC missed versions from official npm registry.

vega-canvas

Canvas and Image object instantiation utilities. Creates an HTML5 Canvas, using either the web browser DOM or a node-canvas library.

This package attempts three forms of canvas creation, in this order:

  • If in a browser environment, use DOM methods to create a new canvas.
  • If the node-canvas library is present, use that.
  • Otherwise, return null.

To ensure error-free build processes for client-side code, this module does not include any direct or optional dependencies on the node-canvas library. Projects that use this pacakge and require canvas support for server-side (node.js) operations must include a canvas dependency in their own package.json file.

API Reference

# vega.canvas([width, height, type]) <>

Creates a new Canvas instance, with an optional width and height (in pixels). If width and height are omitted, creates a 0 x 0 canvas. The optional type parameter is a node-canvas type parameter to enable PDF or SVG output modes; this parameter is applied only if node-canvas is used. This method first attempts to create a canvas using the DOM document.createElement method. If that fails, the method then attempts to instantiate a canvas using the node-canvas library. If that also fails, returns null.

# vega.domCanvas([width, height]) <>

Creates a new Canvas instance, with an optional width and height (in pixels). If width and height are omitted, creates a 0 x 0 canvas. This method first attempts to create a canvas using the DOM document.createElement method. If that fails, returns null.

# vega.nodeCanvas([width, height, type]) <>

Creates a new Canvas instance, with an optional width and height (in pixels). If width and height are omitted, creates a 0 x 0 canvas. The optional type parameter is a node-canvas type parameter to enable PDF or SVG output modes. This method attempts to instantiate a canvas using using the node-canvas library. If that fails, returns null. This method is not exported in browser-only builds.

# vega.image() <>

Returns a reference to the Image constructor. In a web browser environment, simply returns the built-in Image object. Otherwise, attempts to return the Image instance exported by a node canvas library. If all attempts to find a canvas library fail, returns null.

Current Tags

  • 1.2.7                                ...           latest (3 years ago)

11 Versions

  • 1.2.7                                ...           3 years ago
  • 1.2.6                                ...           6 years ago
  • 1.2.5                                ...           6 years ago
  • 1.2.4                                ...           6 years ago
  • 1.2.3                                ...           6 years ago
  • 1.2.2                                ...           6 years ago
  • 1.2.1                                ...           7 years ago
  • 1.2.0                                ...           7 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (0)
None
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |