2011-07-26 07:27:36 -04:00
|
|
|
/*
|
2013-01-28 21:03:27 -05:00
|
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
2011-07-26 07:27:36 -04:00
|
|
|
* http://paperjs.org/
|
|
|
|
*
|
2015-12-27 12:09:25 -05:00
|
|
|
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
2014-01-03 19:47:16 -05:00
|
|
|
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
2011-07-26 07:27:36 -04:00
|
|
|
*
|
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2013-06-26 22:14:54 -04:00
|
|
|
// This file uses PrePro to preprocess the paper.js source code on the fly in
|
|
|
|
// the browser, avoiding the step of having to manually preprocess it after each
|
|
|
|
// change. This is very useful during development of the library itself.
|
2013-10-10 14:36:33 -04:00
|
|
|
if (typeof window === 'object') {
|
2014-08-16 13:24:54 -04:00
|
|
|
// Browser based loading through PrePro:
|
|
|
|
if (!window.include) {
|
|
|
|
var scripts = document.getElementsByTagName('script');
|
|
|
|
var src = scripts[scripts.length - 1].getAttribute('src');
|
|
|
|
// Assume that we're loading browser.js from a root folder, either
|
|
|
|
// through dist/paper-full.js, or directly through src/load.js, and
|
|
|
|
// match root as all the parts of the path that lead to that folder.
|
|
|
|
var root = src.match(/^(.*\/)\w*\//)[1];
|
|
|
|
// First load the PrePro's browser.js file, which provides the include()
|
|
|
|
// function for the browser.
|
|
|
|
document.write('<script type="text/javascript" src="' + root
|
|
|
|
+ 'node_modules/prepro/lib/browser.js"></script>');
|
|
|
|
// Now that we have include(), load this file again, which will execute
|
|
|
|
// the lower part of the code the 2nd time around.
|
|
|
|
document.write('<script type="text/javascript" src="' + root
|
|
|
|
+ 'src/load.js"></script>');
|
|
|
|
} else {
|
|
|
|
include('options.js');
|
|
|
|
include('paper.js');
|
|
|
|
}
|
2013-06-26 22:14:54 -04:00
|
|
|
} else {
|
2014-08-16 13:24:54 -04:00
|
|
|
// Node based loading through PrePro:
|
|
|
|
var prepro = require('prepro/lib/node.js');
|
|
|
|
// Include deafult browser options.
|
|
|
|
// Step out and back into src in case this is loaded from dist/paper-node.js
|
|
|
|
prepro.include('../src/options.js');
|
|
|
|
// Override node specific options.
|
|
|
|
prepro.setOptions({
|
|
|
|
environment: 'node',
|
|
|
|
legacy: false,
|
|
|
|
version: 'dev'
|
|
|
|
});
|
|
|
|
// Load Paper.js library files.
|
|
|
|
prepro.include('../src/paper.js');
|
2013-06-26 22:14:54 -04:00
|
|
|
}
|