mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Implement SVGImport example for node, currently failing.
This commit is contained in:
parent
aa757e1d7b
commit
728be483d7
2 changed files with 38 additions and 0 deletions
22
examples/Node.js/SVGImport.js
Normal file
22
examples/Node.js/SVGImport.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
var paper = require('paper'),
|
||||
path = require('path'),
|
||||
fs = require('fs');
|
||||
|
||||
paper.setup(new paper.Canvas(600, 600));
|
||||
with (paper) {
|
||||
fs.readFile('./in.svg', { encoding: 'utf8' }, function (err, data) {
|
||||
if (err)
|
||||
throw err;
|
||||
project.importSVG(data);
|
||||
paper.view.exportFrames({
|
||||
amount: 1,
|
||||
directory: __dirname,
|
||||
onComplete: function() {
|
||||
console.log('Done exporting.');
|
||||
},
|
||||
onProgress: function(event) {
|
||||
console.log(event.percentage + '% complete, frame took: ' + event.delta);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
16
examples/Node.js/in.svg
Normal file
16
examples/Node.js/in.svg
Normal file
|
@ -0,0 +1,16 @@
|
|||
<svg x="0" y="0" width="300" height="600" version="1.1" xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink">
|
||||
<linearGradient x1="45" y1="345" x2="255" y2="555" gradientUnits="userSpaceOnUse" id="gradient-2">
|
||||
<stop offset="0" stop-color="rgb(255, 255, 0)" stop-opacity="0"></stop>
|
||||
<stop offset="0.5" stop-color="rgb(255, 0, 0)"></stop>
|
||||
<stop offset="1" stop-color="rgb(0, 0, 0)"></stop>
|
||||
</linearGradient>
|
||||
<radialGradient cx="150" cy="150" r="120" gradientUnits="userSpaceOnUse" id="gradient-1">
|
||||
<stop offset="0" stop-color="rgb(255, 255, 0)" stop-opacity="0"></stop>
|
||||
<stop offset="0.5" stop-color="rgb(255, 0, 0)"></stop>
|
||||
<stop offset="1" stop-color="rgb(0, 0, 0)"></stop>
|
||||
</radialGradient>
|
||||
<g fill="none" stroke="rgb(0, 0, 0)" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0">
|
||||
<circle cx="150" cy="150" r="120" fill="url(#gradient-1)"></circle>
|
||||
<rect x="45" y="345" width="210" height="210" transform="rotate(45,150,450)" fill="url(#gradient-2)"></rect>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in a new issue