mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Update exportSVG example.
This commit is contained in:
parent
731a873884
commit
e2ae03d571
1 changed files with 48 additions and 11 deletions
|
@ -1,13 +1,50 @@
|
||||||
var paper = require('paper');
|
var paper = require('paper'),
|
||||||
paper.setup(new paper.Canvas(1024, 768));
|
path = require('path'),
|
||||||
var scope = {};
|
fs = require('fs');
|
||||||
paper.install(scope);
|
|
||||||
with (scope) {
|
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 + [radius, 0];
|
||||||
|
|
||||||
var circle = new Path.Circle({
|
var circle = new Path.Circle({
|
||||||
center: [100, 100],
|
center: from,
|
||||||
radius: 50,
|
radius: radius,
|
||||||
fillColor: 'red'
|
fillColor: {
|
||||||
|
stops: stops,
|
||||||
|
radial: true,
|
||||||
|
origin: from,
|
||||||
|
destination: to
|
||||||
|
},
|
||||||
|
strokeColor: 'black'
|
||||||
});
|
});
|
||||||
var svg = project.exportSVG();
|
|
||||||
console.log(svg.outerHTML);
|
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…
Reference in a new issue