Skip to content

Commit 83f295a

Browse files
authored
Merge pull request #964 from saschagehlich/feature/svg-rendering
Re-rasterize SVG on draw
2 parents ee4fa39 + 77749e6 commit 83f295a

File tree

4 files changed

+190
-49
lines changed

4 files changed

+190
-49
lines changed

examples/image-src-svg.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var fs = require('fs')
2+
var path = require('path')
3+
var Canvas = require('..')
4+
5+
var canvas = Canvas.createCanvas(500, 500)
6+
var ctx = canvas.getContext('2d')
7+
ctx.fillStyle = 'white'
8+
ctx.fillRect(0, 0, 500, 500)
9+
10+
Canvas.loadImage(path.join(__dirname, 'images', 'small-svg.svg'))
11+
.then(image => {
12+
image.width *= 1.5
13+
image.height *= 1.5
14+
ctx.drawImage(image, canvas.width / 2 - image.width / 2, canvas.height / 2 - image.height / 2)
15+
16+
canvas.createPNGStream().pipe(fs.createWriteStream(path.join(__dirname, 'image-src-svg.png')))
17+
})
18+
.catch(e => console.error(e))

examples/images/small-svg.svg

Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)