mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Node.js: Fix bug when using paper-core.js
And improve Node.js examples. Closes #975
This commit is contained in:
parent
16a7baa967
commit
c35814f94f
9 changed files with 51 additions and 49 deletions
|
@ -1,7 +1,7 @@
|
|||
// Please note: When loading paper as a normal module installed in node_modules,
|
||||
// you would use this instead:
|
||||
// var paper = require('paper');
|
||||
var paper = require('../../dist/paper-full.js');
|
||||
var paper = require('../../dist/paper-core.js');
|
||||
paper.setup(new paper.Size(1024, 768));
|
||||
|
||||
var layer = paper.project.activeLayer;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Please note: When loading paper as a normal module installed in node_modules,
|
||||
// you would use this instead:
|
||||
// var paper = require('paper');
|
||||
var paper = require('../../dist/paper-full.js');
|
||||
var paper = require('../../dist/paper-core.js');
|
||||
var http = require('http');
|
||||
|
||||
http.createServer(function(request, response) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Please note: When loading paper as a normal module installed in node_modules,
|
||||
// you would use this instead:
|
||||
// var paper = require('paper');
|
||||
var paper = require('../../dist/paper-full.js');
|
||||
var paper = require('../../dist/paper-core.js');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
|
@ -12,7 +12,7 @@ fs.readFile('./in.json', { encoding: 'utf8' }, function (err, data) {
|
|||
throw err;
|
||||
paper.project.importJSON(data);
|
||||
paper.view.update();
|
||||
fs.writeFile(path.resolve(__dirname, 'out.pdf'), canvas.toBuffer(), function (err) {
|
||||
fs.writeFile(path.resolve('./out.pdf'), canvas.toBuffer(), function (err) {
|
||||
if (err)
|
||||
throw err;
|
||||
console.log('Saved!');
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
// Please note: When loading paper as a normal module installed in node_modules,
|
||||
// you would use this instead:
|
||||
// var paper = require('paper');
|
||||
var paper = require('../../dist/paper-full.js');
|
||||
var paper = require('../../dist/paper-core.js');
|
||||
var fs = require('fs');
|
||||
|
||||
var canvas = paper.createCanvas(800, 600);
|
||||
|
@ -12,6 +12,7 @@ var raster = new paper.Raster(url);
|
|||
raster.position = paper.view.center;
|
||||
|
||||
raster.onLoad = function() {
|
||||
paper.view.update();
|
||||
console.log('The image has loaded:' + raster.bounds);
|
||||
|
||||
// Saving the canvas to a file.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Please note: When loading paper as a normal module installed in node_modules,
|
||||
// you would use this instead:
|
||||
// var paper = require('paper');
|
||||
var paper = require('../../dist/paper-full.js');
|
||||
var paper = require('../../dist/paper-core.js');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
|
@ -45,7 +45,7 @@ with (paper) {
|
|||
var svg = project.exportSVG({ asString: true });
|
||||
console.log(svg);
|
||||
|
||||
fs.writeFile(path.resolve(__dirname, 'out.svg'),svg, function (err) {
|
||||
fs.writeFile(path.resolve('./out.svg'),svg, function (err) {
|
||||
if (err) throw err;
|
||||
console.log('Saved!');
|
||||
});
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Please note: When loading paper as a normal module installed in node_modules,
|
||||
// you would use this instead:
|
||||
// var paper = require('paper');
|
||||
var paper = require('../../dist/paper-full.js');
|
||||
var paper = require('../../dist/paper-core.js');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
paper.setup(new paper.Size(300, 600));
|
||||
paper.project.importSVG(/*'in.svg'*/'file://' + path.resolve(__dirname, 'in.svg'), {
|
||||
paper.project.importSVG(/*'in.svg'*/'file://' + path.resolve('./in.svg'), {
|
||||
onLoad: function(item) {
|
||||
paper.view.exportFrames({
|
||||
amount: 1,
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
"gulp-cached": "^1.1.0",
|
||||
"gulp-git-streamed": "^1.0.0",
|
||||
"gulp-jshint": "^2.0.0",
|
||||
"gulp-prepro": "^2.3.0",
|
||||
"gulp-prepro": "^2.4.0",
|
||||
"gulp-qunits": "^2.0.1",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-shell": "^0.5.2",
|
||||
|
@ -60,7 +60,7 @@
|
|||
"jshint": "2.8.x",
|
||||
"jshint-summary": "^0.4.0",
|
||||
"merge-stream": "^1.0.0",
|
||||
"prepro": "^2.3.0",
|
||||
"prepro": "^2.4.0",
|
||||
"qunitjs": "^1.20.0",
|
||||
"require-dir": "^0.3.0",
|
||||
"resemblejs": "^2.1.0",
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
|
||||
var fs = require('fs'),
|
||||
path = require('path');
|
||||
Canvas = require('canvas');
|
||||
|
||||
module.exports = function(paper) {
|
||||
var sourceMaps = {},
|
||||
sourceMapSupprt = 'require("source-map-support").install(paper.PaperScript.sourceMapSupport);\n';
|
||||
if (paper.PaperScript) {
|
||||
var sourceMapSupprt = 'require("source-map-support").install(paper.PaperScript.sourceMapSupport);\n',
|
||||
sourceMaps = {};
|
||||
|
||||
paper.PaperScript.sourceMapSupport = {
|
||||
retrieveSourceMap: function(source) {
|
||||
|
@ -52,6 +52,7 @@ module.exports = function(paper) {
|
|||
return scope;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
paper.PaperScope.inject({
|
||||
createCanvas: function(width, height, type) {
|
||||
|
|
Loading…
Reference in a new issue