Web UI for ARGUS server
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.

33 lines
894 B

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. // Please note: When loading paper as a normal module installed in node_modules,
  2. // you would use this instead:
  3. // var paper = require('paper-jsdom-canvas');
  4. var paper = require('../../dist/paper-core.js');
  5. var fs = require('fs');
  6. var canvas = paper.createCanvas(800, 600);
  7. paper.setup(canvas);
  8. var url = 'http://assets.paperjs.org/images/marilyn.jpg';
  9. var raster = new paper.Raster(url);
  10. raster.position = paper.view.center;
  11. raster.onLoad = function() {
  12. paper.view.update();
  13. console.log('The image has loaded:' + raster.bounds);
  14. // Saving the canvas to a file.
  15. out = fs.createWriteStream(__dirname + '/canvas.png');
  16. stream = canvas.pngStream();
  17. stream.on('data', function(chunk) {
  18. out.write(chunk);
  19. });
  20. stream.on('end', function() {
  21. console.log('saved png');
  22. });
  23. };
  24. raster.onError = function(message) {
  25. console.error(message);
  26. };