You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
564 B

9 years ago
var fs = require('fs')
var Canvas = require('..')
10 years ago
9 years ago
var canvas = new Canvas(400, 200, 'svg')
var ctx = canvas.getContext('2d')
10 years ago
var y = 80
9 years ago
var x = 50
10 years ago
9 years ago
ctx.font = '22px Helvetica'
ctx.fillText('node-canvas SVG', x, y)
10 years ago
9 years ago
ctx.font = '10px Arial'
ctx.fillText('Just a quick example of SVGs with node-canvas', x, (y += 20))
10 years ago
9 years ago
ctx.globalAlpha = 0.5
ctx.fillRect(x, (y += 20), 10, 10)
ctx.fillRect((x += 20), y, 10, 10)
ctx.fillRect((x += 20), y, 10, 10)
10 years ago
9 years ago
fs.writeFile('out.svg', canvas.toBuffer(), function (err) {
if (err) throw err
console.log('created out.svg')
})