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');
|
2016-01-29 17:06:31 -05:00
|
|
|
var path = require('path');
|
|
|
|
var fs = require('fs');
|
2013-05-08 23:19:49 -04:00
|
|
|
|
|
|
|
with (paper) {
|
2016-01-26 05:41:49 -05:00
|
|
|
paper.setup(new Size(300, 600));
|
2014-08-16 13:24:54 -04:00
|
|
|
var stops = [new Color(1, 1, 0, 0), 'red', 'black'];
|
|
|
|
|
|
|
|
var radius = view.bounds.width * 0.4,
|
|
|
|
from = new Point(view.center.x),
|
|
|
|
to = from.add(radius, 0);
|
|
|
|
|
|
|
|
var circle = new Path.Circle({
|
|
|
|
center: from,
|
|
|
|
radius: radius,
|
|
|
|
fillColor: {
|
|
|
|
stops: stops,
|
|
|
|
radial: true,
|
|
|
|
origin: from,
|
|
|
|
destination: to
|
|
|
|
},
|
|
|
|
strokeColor: 'black'
|
|
|
|
});
|
|
|
|
|
|
|
|
var from = view.bounds.leftCenter,
|
|
|
|
to = view.bounds.bottomRight;
|
|
|
|
|
|
|
|
var rect = new Path.Rectangle({
|
|
|
|
from: from,
|
|
|
|
to: to,
|
|
|
|
fillColor: {
|
|
|
|
stops: stops,
|
|
|
|
radial: false,
|
|
|
|
origin: from,
|
|
|
|
destination: to
|
|
|
|
},
|
|
|
|
strokeColor: 'black'
|
|
|
|
});
|
|
|
|
|
|
|
|
rect.rotate(45).scale(0.7);
|
|
|
|
|
|
|
|
var svg = project.exportSVG({ asString: true });
|
|
|
|
console.log(svg);
|
|
|
|
|
2019-06-11 15:24:50 -04:00
|
|
|
fs.writeFile(path.resolve('./out.svg'), svg, function (err) {
|
2014-08-16 13:24:54 -04:00
|
|
|
if (err) throw err;
|
|
|
|
console.log('Saved!');
|
|
|
|
});
|
2013-10-10 17:12:53 -04:00
|
|
|
}
|