2016-01-26 14:02:23 -05:00
|
|
|
/*
|
|
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
|
|
|
* http://paperjs.org/
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
|
|
|
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
|
|
|
*
|
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 14:14:49 -05:00
|
|
|
// Here we only make sure that there's a window and document object in the node
|
|
|
|
// environment. We can't do this directly in src/paper.js, due to the nature of
|
|
|
|
// how Prepro.js loads the include() files in the various scenarios. E.g. on
|
|
|
|
// Node.js,only the files included in such a way see each other's variables in
|
|
|
|
// their shared scope.
|
2016-01-26 14:02:23 -05:00
|
|
|
|
|
|
|
/* global document:true, window:true */
|
2016-02-17 13:06:29 -05:00
|
|
|
// Create a window variable valid in the paper.js scope, that points to the
|
|
|
|
// native window in browsers and the emulated JSDom one in node.js
|
2016-07-12 13:11:09 -04:00
|
|
|
// In workers, and on Node.js when no Canvas is present, `window` is null (but
|
|
|
|
// `self` is defined), so we can use the validity of the local window object to
|
|
|
|
// detect a worker-like context in the library.
|
|
|
|
// Make sure `self` always points to a window object, also on Node.js.
|
|
|
|
self = self || require('./node/window.js');
|
2016-02-02 11:30:38 -05:00
|
|
|
// NOTE: We're not modifying the global `self` here. We receive its value passed
|
|
|
|
// to the paper.js function scope, and this is the one that is modified here.
|
2016-07-12 13:11:09 -04:00
|
|
|
var window = self.window,
|
|
|
|
document = self.document;
|