canvas
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@mapbox/node-pre-gyp | 1.0.11 | 1 B | BSD-3-Clause | prod | |
nan | 2.19.0 | 419.43 kB | MIT | prod | |
simple-get | 3.1.1 | 4.88 kB | MIT | prod |
Node-canvas is a Cairo graphics library-backed canvas implementation for Node.js. It allows users to create programmatically controlled images in web servers and Node.js programs. It can create all type of graphics like lines, text, images including their properties like colors, shape, and style, etc.
To use canvas, Installation is accomplished via npm like so:
$ npm install canvas
You can then require the canvas
module and begin creating graphics. Here is a quick example:
const { createCanvas, loadImage } = require('canvas')
const canvas = createCanvas(200, 200)
const ctx = canvas.getContext('2d')
ctx.font = '30px Impact'
ctx.rotate(0.1)
ctx.fillText('Awesome!', 50, 100)
var text = ctx.measureText('Awesome!')
ctx.strokeStyle = 'rgba(0,0,0,0.5)'
ctx.beginPath()
ctx.lineTo(50, 102)
ctx.lineTo(50 + text.width, 102)
ctx.stroke()
loadImage('examples/images/lime-cat.jpg').then((image) => {
ctx.drawImage(image, 50, 0, 70, 70)
console.log('<img src="' + canvas.toDataURL() + '" />')
})
The canvas package documentation can be found on the Mozilla Web Canvas API link provided in the Readme and the Compatibility Status page for the current API compliance. All utility methods and non-standard APIs are documented in the Readme itself. For more detailed utilization and instructions, please refer to the wiki of the Github repository.