paper.js/examples/Node.js/RemoteRaster.js

26 lines
621 B
JavaScript
Raw Normal View History

var paper = require('paper');
var fs = require('fs');
var canvas = new paper.Canvas(800, 600);
paper.setup(canvas);
2015-05-31 04:50:04 -04:00
var url = 'http://assets.paperjs.org/images/marilyn.jpg';
var raster = new paper.Raster(url);
raster.position = paper.view.center;
raster.onLoad = function() {
console.log('The image has loaded:' + raster.bounds);
// Saving the canvas to a file.
out = fs.createWriteStream(__dirname + '/canvas.png');
stream = canvas.pngStream();
2013-12-16 15:40:40 -05:00
stream.on('data', function(chunk) {
out.write(chunk);
});
stream.on('end', function() {
console.log('saved png');
});
};