mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-28 22:08:54 -04:00
Update package.json for new release on NPM.
This commit is contained in:
parent
c5627d141e
commit
e5ed88462c
2 changed files with 2 additions and 2 deletions
50
examples/Node.js/SVGExport.js
Normal file
50
examples/Node.js/SVGExport.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
var paper = require('paper'),
|
||||
path = require('path'),
|
||||
fs = require('fs');
|
||||
|
||||
paper.setup(new paper.Canvas(300, 600));
|
||||
with (paper) {
|
||||
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 = new XMLSerializer().serializeToString(project.exportSVG());
|
||||
|
||||
console.log(svg);
|
||||
|
||||
fs.writeFile(path.resolve(__dirname, 'out.svg'),svg, function (err) {
|
||||
if (err) throw err;
|
||||
console.log('Saved!');
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue