2016-01-29 17:06:31 -05:00
|
|
|
// Please note: When loading paper as a normal module installed in node_modules,
|
|
|
|
// you would use this instead:
|
2017-04-19 14:32:12 -04:00
|
|
|
// var paper = require('paper-jsdom-canvas');
|
2016-02-15 17:59:31 -05:00
|
|
|
var paper = require('../../dist/paper-core.js');
|
2013-07-18 22:04:04 -04:00
|
|
|
var http = require('http');
|
|
|
|
|
|
|
|
http.createServer(function(request, response) {
|
2016-01-26 05:41:49 -05:00
|
|
|
var canvas = paper.createCanvas(800, 800);
|
2014-08-16 13:24:54 -04:00
|
|
|
paper.setup(canvas);
|
|
|
|
with(paper) {
|
|
|
|
var style = {
|
|
|
|
fillColor: new Color(1, 1, 0, 0.5),
|
|
|
|
strokeColor: new Color(0, 0, 0),
|
|
|
|
strokeWidth: 1.5
|
|
|
|
};
|
2013-07-18 22:04:04 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var first = new Path.Rectangle([50, 50], [150, 150]);
|
|
|
|
first.style = style;
|
|
|
|
var second = first.clone().translate(50, 50);
|
|
|
|
second.style = style;
|
2013-07-18 22:04:04 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var intersection = first.subtract(second);
|
|
|
|
intersection.style = style;
|
|
|
|
intersection.translate(250, 0);
|
|
|
|
view.update();
|
|
|
|
}
|
2017-10-04 16:39:19 -04:00
|
|
|
var stream = canvas.pngStream();
|
2014-08-16 13:24:54 -04:00
|
|
|
stream.on('data', function(chunk) {
|
|
|
|
response.write(chunk);
|
|
|
|
});
|
|
|
|
stream.on('end', function() {
|
|
|
|
response.end();
|
|
|
|
});
|
2013-07-18 22:04:04 -04:00
|
|
|
}).listen(3000);
|
|
|
|
|
2016-01-26 05:41:49 -05:00
|
|
|
console.log('Server running at http://127.0.0.1:3000/');
|