mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-13 06:29:11 -04:00
Start making exportSVG() work for node, using jsdom.
This commit is contained in:
parent
fc71db458b
commit
219ccd2fdd
2 changed files with 22 additions and 1 deletions
src/node
|
@ -13,10 +13,15 @@
|
|||
var fs = require('fs'),
|
||||
vm = require('vm'),
|
||||
path = require('path'),
|
||||
Canvas = require('canvas');
|
||||
Canvas = require('canvas'),
|
||||
jsdom = require('jsdom');
|
||||
|
||||
__dirname = path.resolve(__dirname, '..');
|
||||
|
||||
// Create a window and document using jsdom, e.g. for exportSVG()
|
||||
var win = jsdom.createWindow(),
|
||||
doc = win.document = jsdom.jsdom("<html><body></body></html>");
|
||||
|
||||
// Create the context within which we will run the source files:
|
||||
var context = vm.createContext({
|
||||
options: {
|
||||
|
@ -31,6 +36,9 @@ var context = vm.createContext({
|
|||
HTMLCanvasElement: Canvas,
|
||||
Image: Canvas.Image,
|
||||
// Copy over global variables:
|
||||
window: win,
|
||||
document: doc,
|
||||
navigator: win.navigator,
|
||||
console: console,
|
||||
require: require,
|
||||
__dirname: __dirname,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue