diff --git a/AUTHORS.md b/AUTHORS.md index 46e21bd3..8b0438b3 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -1,6 +1,6 @@ ## Authors -- Juerg Lehni +- Juerg Lehni - Jonathan Puckey ## Contributors diff --git a/LICENSE.txt b/LICENSE.txt index f8619334..3c2bb41e 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,5 @@ -Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -http://lehni.org/ & http://jonathanpuckey.com/ +Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +http://scratchdisk.com/ & http://jonathanpuckey.com/ All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/README.md b/README.md index 9976378b..9c66024d 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,11 @@ You can download prebuilt packages from . As of July 2013, the recommended way to install and maintain Paper.js is through Bower for browsers, and through NPM for Node.js. -See for a tutorial explaining how to install Node.js, NPM and Bower on OSX. +For OSX see for a tutorial explaining how to install Node.js, NPM and Bower. + +For Linux see to locate 32-bit and 64-bit nodejs binaries as well as sources. It is recommended that you download directly from the nodejs site; the version available via many OS-supplied package managers is out-of-date and doesn't work with many of the packages paper uses. NPM is now included with the nodejs distribution. Once nodejs (with npm) has been installed you can install bower using the following command: + + npm install -g bower With Bower installed, simply type this command in your project folder: @@ -22,26 +26,38 @@ With Bower installed, simply type this command in your project folder: Upon execution, you will find a `paper` folder inside the project's `component` folder. For more information on Bower and to learn about its features for dependence tracking, see . -## Installing for Node.js +## Installing Paper.js for Node.js through NPM -Similarly you can use NPM to install Paper.js for Node.js. But before doing so, you need the Cairo Graphics library installed, see . +You can also use NPM to install Paper.js for Node.js. But before doing so, you need the Cairo Graphics library installed, see . -The easiest way to install Cairo on OSX is through Homebrew . +**Installing Cairo on OSX:** + +The easiest way to install Cairo is install Homebrew then issue the command: brew install cairo -Once Homebrew has installed this for you, you can then install the Paper.js module: - - npm install paper - Note that currently there is an issue on OSX with Cairo. If the above causes errors, the following will most likely fix it: - PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ npm install paper + PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ npm insetall paper Also, whenever you would like to update the modules, you will need to execute: PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ npm update +**Installing Cairo on Debian/Ubuntu Linux:** + + sudo apt-get install libcairo2-dev + +You might also need these additional packages if you don't usually build from c++ sources: + + sudo apt-get install build-essential libssl-dev libjpeg8-dev libgif-dev + +**Ater Cairo has been installed:** + +You should now be able to install the Paper.js module from NPM: + + npm install paper + ## Development **Get the source (for building):** @@ -53,11 +69,12 @@ Also, whenever you would like to update the modules, you will need to execute: If you want to contribute to the project you will have to [make a fork](http://help.github.com/forking/). Then do this: git clone --recursive git@github.com:yourusername/paper.js.git + cd paper.js git remote add upstream git://github.com/paperjs/paper.js.git ### Refreshing Your Clone -To fetch changes from origin, run +To fetch changes from origin (your fork), run git fetch origin @@ -73,11 +90,15 @@ To update the `jsdoc-toolkit` submodule inside the `build` folder, used to gener Paper.js has a couple of dependencies as Bower and NPM modules. See for a tutorial explaining how to install Node.js, NPM and Bower on OSX. -In order to be able to build Paper.js, these dependencies need to be installed first after checking out the repository: +In order to be able to build Paper.js, after checking out the repository, paper has dependencies that need to be installed. Install them by issuing the following commands from the paper.js directory: npm install bower install +You might find that the npm command fails attempting to fetch packages needed for dependencies due to using https (the default protocol to access the npm registry). If that is the case you can switch to using http for registry access with the following command: + + npm config set registry http://registry.npmjs.org/ + Next you need to create minified versions of some of these dependencies. This is handled by the `minify-components.sh` script inside the `build` folder: cd build @@ -145,7 +166,8 @@ As mentioned earlier in this article, we prefer that you send a [*pull request*] 3. This is important: Create a so-called *topic branch*: `git checkout -tb name-of-my-patch` where "name-of-my-patch" is a short but descriptive name of the patch you're about to create. Don't worry about the perfect name though -- you can change this name at any time later on. -4. Hack! Make your changes, additions, etc and commit them. +4. Hack! Make your changes, additions, etc., commit them then push them to your github fork: `git push origin name-of-my-patch` + 5. Send a pull request to the upstream repository's owner by visiting your repository's site at github (i.e. https://github.com/yourusername/paper.js) and press the "Pull Request" button. Here's a good guide on pull requests: diff --git a/build/build.sh b/build/build.sh index 52cfbcb8..6274ff4b 100755 --- a/build/build.sh +++ b/build/build.sh @@ -3,8 +3,8 @@ # Paper.js - The Swiss Army Knife of Vector Graphics Scripting. # http://paperjs.org/ # -# Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -# http://lehni.org/ & http://jonathanpuckey.com/ +# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ # # Distributed under the MIT license. See LICENSE file for details. # diff --git a/build/dist.sh b/build/dist.sh index 7fd72385..4a9bdf69 100755 --- a/build/dist.sh +++ b/build/dist.sh @@ -3,8 +3,8 @@ # Paper.js - The Swiss Army Knife of Vector Graphics Scripting. # http://paperjs.org/ # -# Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -# http://lehni.org/ & http://jonathanpuckey.com/ +# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ # # Distributed under the MIT license. See LICENSE file for details. # diff --git a/build/docs.sh b/build/docs.sh index 690c2e50..95c8caaa 100755 --- a/build/docs.sh +++ b/build/docs.sh @@ -3,8 +3,8 @@ # Paper.js - The Swiss Army Knife of Vector Graphics Scripting. # http://paperjs.org/ # -# Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -# http://lehni.org/ & http://jonathanpuckey.com/ +# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ # # Distributed under the MIT license. See LICENSE file for details. # diff --git a/build/load.sh b/build/load.sh index d04fb1b9..8b231cb9 100755 --- a/build/load.sh +++ b/build/load.sh @@ -3,8 +3,8 @@ # Paper.js - The Swiss Army Knife of Vector Graphics Scripting. # http://paperjs.org/ # -# Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -# http://lehni.org/ & http://jonathanpuckey.com/ +# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ # # Distributed under the MIT license. See LICENSE file for details. # diff --git a/build/minify-components.sh b/build/minify-components.sh index ed33157f..82a4bdd6 100755 --- a/build/minify-components.sh +++ b/build/minify-components.sh @@ -3,8 +3,8 @@ # Paper.js - The Swiss Army Knife of Vector Graphics Scripting. # http://paperjs.org/ # -# Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -# http://lehni.org/ & http://jonathanpuckey.com/ +# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ # # Distributed under the MIT license. See LICENSE file for details. # diff --git a/build/minify.sh b/build/minify.sh index 658fc982..7b12133e 100755 --- a/build/minify.sh +++ b/build/minify.sh @@ -3,8 +3,8 @@ # Paper.js - The Swiss Army Knife of Vector Graphics Scripting. # http://paperjs.org/ # -# Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -# http://lehni.org/ & http://jonathanpuckey.com/ +# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ # # Distributed under the MIT license. See LICENSE file for details. # diff --git a/build/preprocess.sh b/build/preprocess.sh index 00801c4a..eb20a20a 100755 --- a/build/preprocess.sh +++ b/build/preprocess.sh @@ -3,8 +3,8 @@ # Paper.js - The Swiss Army Knife of Vector Graphics Scripting. # http://paperjs.org/ # -# Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -# http://lehni.org/ & http://jonathanpuckey.com/ +# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ # # Distributed under the MIT license. See LICENSE file for details. # diff --git a/build/publish.sh b/build/publish.sh index e42c2359..7d839821 100755 --- a/build/publish.sh +++ b/build/publish.sh @@ -3,8 +3,8 @@ # Paper.js - The Swiss Army Knife of Vector Graphics Scripting. # http://paperjs.org/ # -# Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -# http://lehni.org/ & http://jonathanpuckey.com/ +# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ # # Distributed under the MIT license. See LICENSE file for details. # diff --git a/build/typescript.sh b/build/typescript.sh index 4320a2f2..8f2f6439 100755 --- a/build/typescript.sh +++ b/build/typescript.sh @@ -3,8 +3,8 @@ # Paper.js - The Swiss Army Knife of Vector Graphics Scripting. # http://paperjs.org/ # -# Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -# http://lehni.org/ & http://jonathanpuckey.com/ +# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ # # Distributed under the MIT license. See LICENSE file for details. # diff --git a/build/zip.sh b/build/zip.sh index cf0ee013..16b22d6e 100755 --- a/build/zip.sh +++ b/build/zip.sh @@ -3,8 +3,8 @@ # Paper.js - The Swiss Army Knife of Vector Graphics Scripting. # http://paperjs.org/ # -# Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey -# http://lehni.org/ & http://jonathanpuckey.com/ +# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ # # Distributed under the MIT license. See LICENSE file for details. # diff --git a/examples/Node.js/Tadpoles.js b/examples/Node.js/Tadpoles.js index 47ed04d6..6b025864 100644 --- a/examples/Node.js/Tadpoles.js +++ b/examples/Node.js/Tadpoles.js @@ -1,7 +1,7 @@ -require('paper'); -var paper = require('./Tadpoles.pjs'); +var paper = require('paper'); +var scope = require('./Tadpoles.pjs')(new paper.Size(1024, 768)); -paper.view.exportFrames({ +scope.view.exportFrames({ amount: 400, directory: __dirname, onComplete: function() { diff --git a/examples/Node.js/Tadpoles.pjs b/examples/Node.js/Tadpoles.pjs index 6db5b820..3b02c84d 100644 --- a/examples/Node.js/Tadpoles.pjs +++ b/examples/Node.js/Tadpoles.pjs @@ -1,5 +1,3 @@ -paper.setup(new Canvas(1024, 768)); - // Adapted from Flocking Processing example by Daniel Schiffman: // http://processing.org/learning/topics/flocking.html diff --git a/examples/Paperjs.org/HitTesting.html b/examples/Paperjs.org/HitTesting.html index a1c5f631..ec01d83c 100644 --- a/examples/Paperjs.org/HitTesting.html +++ b/examples/Paperjs.org/HitTesting.html @@ -89,12 +89,11 @@ function onMouseDrag(event) { if (segment) { - segment.point = event.point; + segment.point += event.delta; path.smooth(); - } - - if (movePath) + } else if (path) { path.position += event.delta; + } } diff --git a/node_modules/.gitignore b/node_modules/.gitignore index f03c65d0..b2703914 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -1,7 +1,8 @@ .bin canvas +grunt* +jsdoc jsdom +prepro request uglify-js -prepro -grunt* diff --git a/package.json b/package.json index 44a6995c..d1c3a009 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "homepage": "http://paperjs.org", "repository": "git://github.com/paperjs/paper.js", "contributors": [ - "Jürg Lehni (http://lehni.org)", + "Jürg Lehni (http://scratchdisk.com)", "Jonathan Puckey (http://studiomoniker.com)" ], "main": "./dist/paper-node.js", @@ -26,7 +26,7 @@ }, "devDependencies": { "uglify-js": "~2.3.6", - "prepro": "~0.8.0", + "prepro": "~0.8.1", "grunt": "~0.4.1", "grunt-contrib-uglify": "~0.2.2" }, diff --git a/src/basic/Line.js b/src/basic/Line.js index 93e2434b..447a5802 100644 --- a/src/basic/Line.js +++ b/src/basic/Line.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/basic/Matrix.js b/src/basic/Matrix.js index abe23fdb..9ea84067 100644 --- a/src/basic/Matrix.js +++ b/src/basic/Matrix.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/basic/Point.js b/src/basic/Point.js index 78d4db31..67523eee 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/basic/Rectangle.js b/src/basic/Rectangle.js index ce0b80cf..1555e569 100644 --- a/src/basic/Rectangle.js +++ b/src/basic/Rectangle.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/basic/Size.js b/src/basic/Size.js index 0e43edac..af8e38b4 100644 --- a/src/basic/Size.js +++ b/src/basic/Size.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/canvas/BlendMode.js b/src/canvas/BlendMode.js index 3fadee81..c3ccc3dd 100644 --- a/src/canvas/BlendMode.js +++ b/src/canvas/BlendMode.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/canvas/CanvasProvider.js b/src/canvas/CanvasProvider.js index 84594fac..f70eaa47 100644 --- a/src/canvas/CanvasProvider.js +++ b/src/canvas/CanvasProvider.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/canvas/ProxyContext.js b/src/canvas/ProxyContext.js index 19c72ba6..70e2ad39 100644 --- a/src/canvas/ProxyContext.js +++ b/src/canvas/ProxyContext.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/constants.js b/src/constants.js index 51e5e364..6b1dd923 100644 --- a/src/constants.js +++ b/src/constants.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/core/Base.js b/src/core/Base.js index 4fd9511e..36fe1340 100644 --- a/src/core/Base.js +++ b/src/core/Base.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -15,8 +15,7 @@ * @class * @private */ -// Extend Base with utility functions used across the library. Also set -// this.Base on the injection scope, since straps.js ommits that. +// Extend Base with utility functions used across the library. Base.inject(/** @lends Base# */{ /** * Renders base objects to strings in object literal notation. @@ -40,7 +39,7 @@ Base.inject(/** @lends Base# */{ /** * Serializes this object to a JSON string. * - * @param {Object} [options={ precision: 5 }] + * @param {Object} [options={ asString: true, precision: 5 }] */ exportJSON: function(options) { return Base.exportJSON(this, options); @@ -180,9 +179,6 @@ Base.inject(/** @lends Base# */{ obj = Base.create(this.prototype); if (readIndex) obj.__read = true; - // If options were provided, pass them on to the constructed object - if (options) - obj.__options = options; obj = obj.initialize.apply(obj, index > 0 || length < list.length ? Array.prototype.slice.call(list, index, index + length) : list) || obj; @@ -192,8 +188,6 @@ Base.inject(/** @lends Base# */{ // last read() call list.__read = obj.__read; obj.__read = undefined; - if (options) - obj.__options = undefined; } return obj; }, @@ -211,7 +205,7 @@ Base.inject(/** @lends Base# */{ /** * Reads all readable arguments from the list, handling nested arrays - * seperately. + * separately. * @param {Array} list the list to read from, either an arguments object * or a normal array. * @param {Number} start the index at which to start reading in the list @@ -433,7 +427,10 @@ Base.inject(/** @lends Base# */{ }, exportJSON: function(obj, options) { - return JSON.stringify(Base.serialize(obj, options)); + var json = Base.serialize(obj, options); + return options && options.asString === false + ? json + : JSON.stringify(json); }, importJSON: function(json, target) { diff --git a/src/core/Callback.js b/src/core/Callback.js index 33838d29..10d43b0d 100644 --- a/src/core/Callback.js +++ b/src/core/Callback.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -77,32 +77,16 @@ var Callback = { if (!handlers) return false; var args = [].slice.call(arguments, 1), - PaperScript = paper.PaperScript, - handleException = PaperScript && PaperScript.handleException, that = this; - - function callHandlers() { - for (var i in handlers) { - // When the handler function returns false, prevent the default - // behaviour and stop propagation of the event by calling stop() - if (handlers[i].apply(that, args) === false - && event && event.stop) { - event.stop(); - break; - } + for (var i in handlers) { + // When the handler function returns false, prevent the default + // behaviour and stop propagation of the event by calling stop() + if (handlers[i].apply(that, args) === false + && event && event.stop) { + event.stop(); + break; } } - // See PaperScript.handleException for an explanation of the following. - // Firefox is to blame for the necessity of this... - if (handleException) { - try { - callHandlers(); - } catch (e) { - handleException(e); - } - } else { - callHandlers(); - } return true; }, diff --git a/src/core/PaperScope.js b/src/core/PaperScope.js index 5061f7f0..ec0b2c14 100644 --- a/src/core/PaperScope.js +++ b/src/core/PaperScope.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/core/PaperScopeItem.js b/src/core/PaperScopeItem.js index 610d8069..b1344048 100644 --- a/src/core/PaperScopeItem.js +++ b/src/core/PaperScopeItem.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/core/PaperScript.js b/src/core/PaperScript.js index a11224b0..62138899 100644 --- a/src/core/PaperScript.js +++ b/src/core/PaperScript.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -14,17 +14,12 @@ * @name PaperScript * @namespace */ -var PaperScript = Base.exports.PaperScript = (function(root) { +var PaperScript = Base.exports.PaperScript = (function() { // Locally turn of exports and define for inlined acorn / esprima. // Just declaring the local vars is enough, as they will be undefined. var exports, define, // The scope into which the library is loaded. scope = this; -/*#*/ if (__options.version == 'dev') { - // As the above inclusion loads code into the root scope during dev, - // set scope to root, so we can find the library. - scope = root; -/*#*/ } // __options.version == 'dev' /*#*/ if (__options.parser == 'acorn') { /*#*/ include('../../bower_components/acorn/acorn.min.js', { exports: false }); /*#*/ } else if (__options.parser == 'esprima') { @@ -34,7 +29,7 @@ var PaperScript = Base.exports.PaperScript = (function(root) { // Operators to overload var binaryOperators = { - // The hidden math functions are to be injected specifically, see below. + // The hidden math methods are to be injected specifically, see below. '+': '__add', '-': '__subtract', '*': '__multiply', @@ -50,11 +45,11 @@ var PaperScript = Base.exports.PaperScript = (function(root) { '+': null }; - // Inject underscored math functions as aliases to Point, Size and Color. + // Inject underscored math methods as aliases to Point, Size and Color. var fields = Base.each( ['add', 'subtract', 'multiply', 'divide', 'modulo', 'negate'], function(name) { - // Create an alias for ach math function to be injected into the + // Create an alias for each math method to be injected into the // classes using Straps.js' #inject() this['__' + name] = '#' + name; }, @@ -109,13 +104,12 @@ var PaperScript = Base.exports.PaperScript = (function(root) { */ function compile(code) { // Use Acorn or Esprima to translate the code into an AST structure - // which is then walked and parsed for operators to overload. - // Instead of modifying the AST and converting back to code, we directly - // change the source code based on the parser's range information, so we - // can preserve line-numbers in syntax errors and remove the need for - // Escodegen. + // which is then walked and parsed for operators to overload. Instead of + // modifying the AST and translating it back to code, we directly change + // the source code based on the parser's range information, to preserve + // line-numbers in syntax errors and remove the need for Escodegen. - // Tracks code insertions so we can add their differences to the + // Track code insertions so their differences can be added to the // original offsets. var insertions = []; @@ -143,8 +137,8 @@ var PaperScript = Base.exports.PaperScript = (function(root) { // information up-to-date. function replaceCode(node, str) { var start = getOffset(node.range[0]), - end = getOffset(node.range[1]); - var insert = 0; + end = getOffset(node.range[1]), + insert = 0; // Sort insertions by their offset, so getOffest() can do its thing for (var i = insertions.length - 1; i >= 0; i--) { if (start > insertions[i][0]) { @@ -245,7 +239,7 @@ var PaperScript = Base.exports.PaperScript = (function(root) { var view = scope.getView(), // Only create a tool object if something resembling a tool handler // definition is contained in the code. - tool = /\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)/.test(code) + tool = /\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b/.test(code) ? new Tool() : null, toolHandlers = tool ? tool._events : [], @@ -255,71 +249,69 @@ var PaperScript = Base.exports.PaperScript = (function(root) { // injecting a code line that defines them as variables. // They are exported again at the end of the function. handlers = ['onFrame', 'onResize'].concat(toolHandlers), - res; + // compile a list of paramter names for all variables that need to + // appear as globals inside the script. At the same time, also + // collect their values, so we can pass them on as arguments in the + // function call. + params = [], + args = [], + func; code = compile(code); - // compile a list of paramter names for all variables that need to - // appear as globals inside the script. At the same time, also collect - // their values, so we can pass them on as arguments in the function - // call. - var params = ['_$_', '$_', 'view', 'tool'], - args = [_$_, $_ , view, tool]; - // Look through all enumerable properties on the scope and expose these - // too as pseudo-globals. - for (var key in scope) { - if (!/^_/.test(key)) { - params.push(key); - args.push(scope[key]); + function expose(scope, hidden) { + // Look through all enumerable properties on the scope and expose + // these too as pseudo-globals, but only if they seem to be in use. + for (var key in scope) { + if ((hidden || !/^_/.test(key)) && new RegExp( + '\\b' + key.replace(/\$/g, '\\$') + '\\b').test(code)) { + params.push(key); + args.push(scope[key]); + } } } + expose({ _$_: _$_, $_: $_, view: view, tool: tool }, true); + expose(scope); // Finally define the handler variable names as parameters and compose // the string describing the properties for the returned object at the // end of the code execution, so we can retrieve their values from the // function call. handlers = Base.each(handlers, function(key) { - params.push(key); - this.push(key + ': ' + key); + // Check for each handler explicitely and only return them if they + // seem to exist. + if (new RegExp('\\s+' + key + '\\b').test(code)) { + params.push(key); + this.push(key + ': ' + key); + } }, []).join(', '); // We need an additional line that returns the handlers in one object. - code += '\nreturn { ' + handlers + ' };'; + if (handlers) + code += '\nreturn { ' + handlers + ' };'; /*#*/ if (__options.environment == 'browser') { - if (root.InstallTrigger) { // Firefox - // Add a semi-colon at the start so Firefox doesn't swallow empty - // lines and shift error messages. - code = ';' + code; - // On Firefox, all error numbers inside evaled code are relative to - // the line where the eval happened. Totally silly, but that's how - // it is. So we're calculating the base of lineNumbers, to remove it - // again from reported errors. Luckily, Firefox is the only browser - // where we can define the lineNumber for exceptions. - var handle = PaperScript.handleException; - if (!handle) { - handle = PaperScript.handleException = function(e) { - throw e.lineNumber >= lineNumber - ? new Error(e.message, e.fileName, - e.lineNumber - lineNumber) - : e; - }; - // We're using a crazy hack to detect wether the library is - // minified or not: By generating a second error on the 2nd line - // and using the difference in line numbers to calculate the - // offset to the eval, it works in both casees. - var lineNumber = new Error().lineNumber; - lineNumber += (new Error().lineNumber - lineNumber) * 3; - } - try { - res = new Function(params, code).apply(scope, args); - // NOTE: in order for the calculation of the above lineNumber - // offset to work, we cannot add any statements before the above - // line of code, nor can we put it into a separate function. - } catch (e) { - handle(e); - } + if (window.InstallTrigger || window.chrome) { // Firefox and Chrome + // On Firefox, all error numbers inside dynamically compiled code + // are relative to the line where the eval / compilation happened. + // To fix this issue, we're temporarily inserting a new script + // tag. We also use this on Chrome to fix an issue with compiled + // functions: + // https://code.google.com/p/chromium/issues/detail?id=331655 + var script = document.createElement('script'), + head = document.head; + // Do not add a new-line before the code on Chrome since the error + // messages are shifted by one line there... + if (!window.chrome) + code = '\n' + code; + script.appendChild(document.createTextNode( + 'paper._execute = function(' + params + ') {' + code + '\n}' + )); + head.appendChild(script); + func = paper._execute; + head.removeChild(script); } else { - res = new Function(params, code).apply(scope, args); + func = Function(params, code); } /*#*/ } else { // !__options.environment == 'browser' - res = new Function(params, code).apply(scope, args); + func = Function(params, code); /*#*/ } // !__options.environment == 'browser' + var res = func.apply(scope, args) || {}; // Now install the 'global' tool and view handlers, and we're done! Base.each(toolHandlers, function(key) { var value = res[key]; @@ -404,15 +396,21 @@ var PaperScript = Base.exports.PaperScript = (function(root) { path = require('path'); require.extensions['.pjs'] = function(module, uri) { - var source = compile(fs.readFileSync(uri, 'utf8')), - scope = new PaperScope(); - scope.__filename = uri; - scope.__dirname = path.dirname(uri); - // Expose core methods and values - scope.require = require; - scope.console = console; - execute(source, scope); - module.exports = scope; + // Requiring a PaperScript on Node.js returns an initialize method which + // needs to receive a Canvas object when called and returns the + // PaperScope. + module.exports = function(canvas) { + var source = compile(fs.readFileSync(uri, 'utf8')), + scope = new PaperScope(); + scope.setup(canvas); + scope.__filename = uri; + scope.__dirname = path.dirname(uri); + // Expose core methods and values + scope.require = require; + scope.console = console; + execute(source, scope); + return scope; + }; }; /*#*/ } // __options.environment == 'node' @@ -423,4 +421,6 @@ var PaperScript = Base.exports.PaperScript = (function(root) { }; /*#*/ } // !__options.environment == 'browser' -})(this); +// Pass on `this` as the binding object, so we can reference Acorn both in +// development and in the built library. +}).call(this); diff --git a/src/docs/global.js b/src/docs/global.js index 979ea441..3a33ab89 100644 --- a/src/docs/global.js +++ b/src/docs/global.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/dom/DomElement.js b/src/dom/DomElement.js index 46fa1ec7..624df695 100644 --- a/src/dom/DomElement.js +++ b/src/dom/DomElement.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -46,7 +46,7 @@ var DomElement = new function() { return res; } - return { + return /** @lends DomElement */{ create: function(nodes, parent) { var isArray = Array.isArray(nodes), res = create(isArray ? nodes : arguments, isArray ? parent : null); diff --git a/src/dom/DomEvent.js b/src/dom/DomEvent.js index 49b66407..3426edfa 100644 --- a/src/dom/DomEvent.js +++ b/src/dom/DomEvent.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -15,7 +15,7 @@ * @namespace * @private */ -var DomEvent = { +var DomEvent = /** @lends DomEvent */{ add: function(el, events) { for (var type in events) el.addEventListener(type, events[type], false); diff --git a/src/dom/node.js b/src/dom/node.js index 4b391ba9..d31840ed 100644 --- a/src/dom/node.js +++ b/src/dom/node.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/export.js b/src/export.js index c9bc9e32..014ff75f 100644 --- a/src/export.js +++ b/src/export.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/item/ChangeFlag.js b/src/item/ChangeFlag.js index 23b825b2..0ae08015 100644 --- a/src/item/ChangeFlag.js +++ b/src/item/ChangeFlag.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/item/Group.js b/src/item/Group.js index 179bfe77..01e35900 100644 --- a/src/item/Group.js +++ b/src/item/Group.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/item/HitResult.js b/src/item/HitResult.js index 83eb80e8..16f97fcd 100644 --- a/src/item/HitResult.js +++ b/src/item/HitResult.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/item/Item.js b/src/item/Item.js index 3c79091b..f1dbfbf3 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -1804,12 +1804,15 @@ var Item = Base.extend(Callback, /** @lends Item# */{ * data string. * * The options object offers control over some aspects of the SVG export: + * options.asString: {@code Boolean} – wether the JSON is returned as + * a {@code Object} or a {@code String}. * options.precision: {@code Number} – the amount of fractional * digits in numbers used in JSON data. * * @name Item#exportJSON * @function - * @param {Object} [options={ precision: 5 }] the serialization options + * @param {Object} [options={ asString: true, precision: 5 }] the + * serialization options * @return {String} the exported JSON data */ @@ -1836,8 +1839,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{ * Exports the item with its content and child items as an SVG DOM. * * The options object offers control over some aspects of the SVG export: - * options.asString: {@code Boolean} – wether a SVG node or a String - * is to be returned. + * options.asString: {@code Boolean} – wether a SVG node or a + * {@code String} is to be returned. * options.precision: {@code Number} – the amount of fractional * digits in numbers used in SVG data. * options.matchShapes: {@code Boolean} – wether imported path @@ -2718,6 +2721,9 @@ var Item = Base.extend(Callback, /** @lends Item# */{ // 'children', 'fill-gradients', 'fill-patterns', 'stroke-patterns', // 'lines'. Default: ['objects', 'children'] transform: function(matrix /*, applyMatrix */) { + // Bail out immediatelly if there is nothing to do + if (matrix.isIdentity()) + return this; // Calling _changed will clear _bounds and _position, but depending // on matrix we can calculate and set them again. var bounds = this._bounds, diff --git a/src/item/Layer.js b/src/item/Layer.js index 16afd1ce..e4d6424e 100644 --- a/src/item/Layer.js +++ b/src/item/Layer.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/item/PlacedSymbol.js b/src/item/PlacedSymbol.js index 4277c44f..e498b7a0 100644 --- a/src/item/PlacedSymbol.js +++ b/src/item/PlacedSymbol.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/item/Raster.js b/src/item/Raster.js index ba70fad1..66c131bd 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/item/Shape.js b/src/item/Shape.js index 3e6ce6cd..8f847ab8 100644 --- a/src/item/Shape.js +++ b/src/item/Shape.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/load.js b/src/load.js index a679cfa3..ddbf4854 100644 --- a/src/load.js +++ b/src/load.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/net/Http.js b/src/net/Http.js index d4d05832..662bbcc1 100644 --- a/src/net/Http.js +++ b/src/net/Http.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/options.js b/src/options.js index 4c5f915a..55bc09d8 100644 --- a/src/options.js +++ b/src/options.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/paper.js b/src/paper.js index 3b695514..fe82b5d8 100644 --- a/src/paper.js +++ b/src/paper.js @@ -2,8 +2,8 @@ * Paper.js v*#=* __options.version - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -13,16 +13,16 @@ * *** * - * straps.js - Class inheritance library with support for bean-style accessors + * Straps.js - Class inheritance library with support for bean-style accessors * * Copyright (c) 2006 - 2013 Juerg Lehni - * http://lehni.org/ + * http://scratchdisk.com/ * * Distributed under the MIT license. * *** * - * acorn.js + * Acorn.js * http://marijnhaverbeke.nl/acorn/ * * Acorn is a tiny, fast JavaScript parser written in JavaScript, diff --git a/src/path/CompoundPath.js b/src/path/CompoundPath.js index 3d6725a5..658887a6 100644 --- a/src/path/CompoundPath.js +++ b/src/path/CompoundPath.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/path/Curve.js b/src/path/Curve.js index 34d39842..c3e61998 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -555,7 +555,7 @@ statics: { }, getParameterOf: function(v, x, y) { - // Handle beginnings and end seperately, as they are not detected + // Handle beginnings and end separately, as they are not detected // sometimes. var tolerance = /*#=*/ Numerical.TOLERANCE; if (Math.abs(v[0] - x) < tolerance && Math.abs(v[1] - y) < tolerance) @@ -674,7 +674,7 @@ statics: { c = v1 - v0, count = Numerical.solveQuadratic(a, b, c, roots), // Add some tolerance for good roots, as t = 0 / 1 are added - // seperately anyhow, and we don't want joins to be added with + // separately anyhow, and we don't want joins to be added with // radiuses in getStrokeBounds() tMin = /*#=*/ Numerical.TOLERANCE, tMax = 1 - tMin; @@ -1090,12 +1090,13 @@ new function() { // Scope for methods that require numerical integration b = 1; var isZero = Numerical.isZero; // See if the curve is linear by checking p1 == c1 and p2 == c2 - if (isZero(v[0] - v[2]) && isZero(v[1] - v[3]) + if (a === 0 && b === 1 + && isZero(v[0] - v[2]) && isZero(v[1] - v[3]) && isZero(v[6] - v[4]) && isZero(v[7] - v[5])) { // Straight line var dx = v[6] - v[0], // p2x - p1x dy = v[7] - v[1]; // p2y - p1y - return (b - a) * Math.sqrt(dx * dx + dy * dy); + return Math.sqrt(dx * dx + dy * dy); } var ds = getLengthIntegrand(v); return Numerical.integrate(ds, a, b, getIterations(a, b)); diff --git a/src/path/CurveLocation.js b/src/path/CurveLocation.js index b4ade4db..f04845c5 100644 --- a/src/path/CurveLocation.js +++ b/src/path/CurveLocation.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/path/Path.Constructors.js b/src/path/Path.Constructors.js index 004f4b71..967b1ad9 100644 --- a/src/path/Path.Constructors.js +++ b/src/path/Path.Constructors.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/path/Path.js b/src/path/Path.js index a41aa476..9c8c0c01 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/path/PathFitter.js b/src/path/PathFitter.js index b179529e..3b1d0d42 100644 --- a/src/path/PathFitter.js +++ b/src/path/PathFitter.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -15,6 +15,11 @@ // from "Graphics Gems", Academic Press, 1990 // Modifications and optimisations of original algorithm by Juerg Lehni. +/** + * @name PathFitter + * @class + * @private + */ var PathFitter = Base.extend({ initialize: function(path, error) { this.points = []; diff --git a/src/path/PathFlattener.js b/src/path/PathFlattener.js index adb6cf4c..81b5085e 100644 --- a/src/path/PathFlattener.js +++ b/src/path/PathFlattener.js @@ -2,14 +2,19 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * * All rights reserved. */ +/** + * @name PathFlattener + * @class + * @private + */ var PathFlattener = Base.extend({ initialize: function(path) { this.curves = []; // The curve values as returned by getValues() diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index d4ada031..65c9c370 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/path/PathItem.js b/src/path/PathItem.js index 64ce13fa..4f65ac22 100644 --- a/src/path/PathItem.js +++ b/src/path/PathItem.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/path/Segment.js b/src/path/Segment.js index 8451b115..42d1bd4b 100644 --- a/src/path/Segment.js +++ b/src/path/Segment.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/path/SegmentPoint.js b/src/path/SegmentPoint.js index 94829570..8d27022a 100644 --- a/src/path/SegmentPoint.js +++ b/src/path/SegmentPoint.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/path/SelectionState.js b/src/path/SelectionState.js index 3252cbe2..d822308e 100644 --- a/src/path/SelectionState.js +++ b/src/path/SelectionState.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/project/Project.js b/src/project/Project.js index 583c8111..c211a6af 100644 --- a/src/project/Project.js +++ b/src/project/Project.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -335,12 +335,15 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{ * a JSON data string. * * The options object offers control over some aspects of the SVG export: + * options.asString: {@code Boolean} – wether the JSON is returned as + * a {@code Object} or a {@code String}. * options.precision: {@code Number} – the amount of fractional * digits in numbers used in JSON data. * * @name Project#exportJSON * @function - * @param {Object} [options={ precision: 5 }] the serialization options + * @param {Object} [options={ asString: true, precision: 5 }] the + * serialization options * @return {String} the exported JSON data */ @@ -364,8 +367,8 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{ * all contained in one top level SVG group node. * * The options object offers control over some aspects of the SVG export: - * options.asString: {@code Boolean} – wether a SVG node or a String - * is to be returned. + * options.asString: {@code Boolean} – wether a SVG node or a + * {@code String} is to be returned. * options.precision: {@code Number} – the amount of fractional * digits in numbers used in SVG data. * options.matchShapes: {@code Boolean} – wether imported path diff --git a/src/project/Symbol.js b/src/project/Symbol.js index c13b4fd9..3b300816 100644 --- a/src/project/Symbol.js +++ b/src/project/Symbol.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/style/Color.js b/src/style/Color.js index 52bafbd9..ed73d5fe 100644 --- a/src/style/Color.js +++ b/src/style/Color.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -247,23 +247,20 @@ var Color = Base.extend(new function() { } return value; } - : name === 'hue' - ? function(value) { - // Keep negative values within modulo 360 too: - return isNaN(value) ? 0 - : ((value % 360) + 360) % 360; + : type === 'gradient' + ? function(/* value */) { + return Point.read(arguments, 0, 0, { + readNull: name === 'highlight', + clone: true + }); } - : type === 'gradient' - ? function(/* value */) { - return Point.read(arguments, 0, 0, { - readNull: name === 'highlight', - clone: true - }); - } - : function(value) { - return isNaN(value) ? 0 - : Math.min(Math.max(value, 0), 1); - }; + : function(value) { + // NOTE: We don't clamp values here, they're only + // clamped once the actual CSS values are produced. + // Gotta love the fact that isNaN(null) is false, + // while isNaN(undefined) is true. + return value == null || isNaN(value) ? 0 : value; + }; this['get' + part] = function() { return this._type === type @@ -401,7 +398,7 @@ var Color = Base.extend(new function() { * // the path and to position the gradient color: * var topLeft = view.center - [80, 80]; * var bottomRight = view.center + [80, 80]; - * + * * var path = new Path.Rectangle({ * topLeft: topLeft, * bottomRight: bottomRight, @@ -489,7 +486,6 @@ var Color = Base.extend(new function() { var slice = Array.prototype.slice, args = arguments, read = 0, - parse = true, type, components, alpha, @@ -520,8 +516,6 @@ var Color = Base.extend(new function() { } } if (!components) { - // Only parse values if we're not told to not do so - parse = !(this.__options && this.__options.dontParse); // Determine if there is a values array values = argType === 'number' ? args @@ -586,7 +580,7 @@ var Color = Base.extend(new function() { : 'rgb'; // Convert to array and parse in one loop, for efficiency var properties = types[type]; - parsers = parse && componentParsers[type]; + parsers = componentParsers[type]; this._components = components = []; for (var i = 0, l = properties.length; i < l; i++) { var value = arg[properties[i]]; @@ -600,8 +594,7 @@ var Color = Base.extend(new function() { radial: arg.radial }; } - if (parse) - value = parsers[i].call(this, value); + value = parsers[i].call(this, value); if (value != null) components[i] = value; } @@ -623,9 +616,7 @@ var Color = Base.extend(new function() { this._components = components = []; var parsers = componentParsers[this._type]; for (var i = 0, l = parsers.length; i < l; i++) { - var value = values && values[i]; - if (parse) - value = parsers[i].call(this, value); + var value = parsers[i].call(this, values && values[i]); if (value != null) components[i] = value; } @@ -656,6 +647,24 @@ var Color = Base.extend(new function() { this._owner._changed(/*#=*/ Change.STYLE); }, + /** + * Returns a copy of the components array with all values clamped to + * valid numbers, based on the type of property they represent. + */ + _clamp: function() { + var components = this._components.slice(), + properties = this._properties; + if (this._type !== 'gradient') { + for (var i = 0, l = properties.length; i < l; i++) { + var value = components[i]; + components[i] = properties[i] === 'hue' + ? ((value % 360) + 360) % 360 + : value < 0 ? 0 : value > 1 ? 1 : value; + } + } + return components; + }, + /** * @return {Number[]} the converted components as an array */ @@ -664,11 +673,11 @@ var Color = Base.extend(new function() { return this._type === type ? this._components.slice() : (converter = converters[this._type + '-' + type]) - ? converter.apply(this, this._components) + ? converter.apply(this, this._clamp()) // Convert to and from rgb if no direct converter exists : converters['rgb-' + type].apply(this, converters[this._type + '-rgb'].apply(this, - this._components)); + this._clamp())); }, /** @@ -776,6 +785,7 @@ var Color = Base.extend(new function() { /** * @name Color#clone + * @function * * Returns a copy of the color object. * @@ -815,13 +825,16 @@ var Color = Base.extend(new function() { // TODO: Support HSL / HSLA CSS3 colors directly, without conversion var components = this._convert('rgb'), alpha = hex || this._alpha == null ? 1 : this._alpha; + function convert(val) { + return Math.round((val < 0 ? 0 : val > 1 ? 1 : val) * 255); + } components = [ - Math.round(components[0] * 255), - Math.round(components[1] * 255), - Math.round(components[2] * 255) + convert(components[0]), + convert(components[1]), + convert(components[2]) ]; if (alpha < 1) - components.push(alpha); + components.push(val < 0 ? 0 : val); return hex ? '#' + ((1 << 24) + (components[0] << 16) + (components[1] << 8) @@ -1119,48 +1132,33 @@ var Color = Base.extend(new function() { } }); }, new function() { - function clamp(value, hue) { - return value < 0 - ? 0 - : hue && value > 360 - ? 360 - : !hue && value > 1 - ? 1 - : value; - } - var operators = { - add: function(a, b, hue) { - return clamp(a + b, hue); + add: function(a, b) { + return a + b; }, - subtract: function(a, b, hue) { - return clamp(a - b, hue); + subtract: function(a, b) { + return a - b; }, - multiply: function(a, b, hue) { - return clamp(a * b, hue); + multiply: function(a, b) { + return a * b; }, - divide: function(a, b, hue) { - return clamp(a / b, hue); + divide: function(a, b) { + return a / b; } }; return Base.each(operators, function(operator, name) { - // Tell the argument reader not to parse values for multiply and divide, - // so the are not clamped yet. - var options = { dontParse: /^(multiply|divide)$/.test(name) }; - - this[name] = function(/* color */) { - var color = Color.read(arguments, 0, 0, options); + this[name] = function(color) { + color = Color.read(arguments, 0, 0); var type = this._type, properties = this._properties, components1 = this._components, components2 = color._convert(type); for (var i = 0, l = components1.length; i < l; i++) - components2[i] = operator(components1[i], components2[i], - properties[i] === 'hue'); + components2[i] = operator(components1[i], components2[i]); return new Color(type, components2, this._alpha != null ? operator(this._alpha, color.getAlpha()) diff --git a/src/style/Gradient.js b/src/style/Gradient.js index 93bd9426..b26eddb1 100644 --- a/src/style/Gradient.js +++ b/src/style/Gradient.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/style/GradientStop.js b/src/style/GradientStop.js index fc1baae7..7b75de3a 100644 --- a/src/style/GradientStop.js +++ b/src/style/GradientStop.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/style/Style.js b/src/style/Style.js index 82826623..5a4d4b56 100644 --- a/src/style/Style.js +++ b/src/style/Style.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/svg/SVGExport.js b/src/svg/SVGExport.js index 1519c725..21eb7588 100644 --- a/src/svg/SVGExport.js +++ b/src/svg/SVGExport.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -55,24 +55,25 @@ new function() { attrs[center ? 'cy' : 'y'] = point.y; trans = null; } - if (matrix.isIdentity()) - return attrs; - // See if we can decompose the matrix and can formulate it as a simple - // translate/scale/rotate command sequence. - var decomposed = matrix.decompose(); - if (decomposed && !decomposed.shearing) { - var parts = [], - angle = decomposed.rotation, - scale = decomposed.scaling; - if (trans && !trans.isZero()) - parts.push('translate(' + formatter.point(trans) + ')'); - if (angle) - parts.push('rotate(' + formatter.number(angle) + ')'); - if (!Numerical.isZero(scale.x - 1) || !Numerical.isZero(scale.y - 1)) - parts.push('scale(' + formatter.point(scale) +')'); - attrs.transform = parts.join(' '); - } else { - attrs.transform = 'matrix(' + matrix.getValues().join(',') + ')'; + if (!matrix.isIdentity()) { + // See if we can decompose the matrix and can formulate it as a + // simple translate/scale/rotate command sequence. + var decomposed = matrix.decompose(); + if (decomposed && !decomposed.shearing) { + var parts = [], + angle = decomposed.rotation, + scale = decomposed.scaling; + if (trans && !trans.isZero()) + parts.push('translate(' + formatter.point(trans) + ')'); + if (angle) + parts.push('rotate(' + formatter.number(angle) + ')'); + if (!Numerical.isZero(scale.x - 1) + || !Numerical.isZero(scale.y - 1)) + parts.push('scale(' + formatter.point(scale) +')'); + attrs.transform = parts.join(' '); + } else { + attrs.transform = 'matrix(' + matrix.getValues().join(',') + ')'; + } } return attrs; } diff --git a/src/svg/SVGImport.js b/src/svg/SVGImport.js index 0fb63f12..4fac29b6 100644 --- a/src/svg/SVGImport.js +++ b/src/svg/SVGImport.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/svg/SVGNamespaces.js b/src/svg/SVGNamespaces.js index e0816a4d..81fe7617 100644 --- a/src/svg/SVGNamespaces.js +++ b/src/svg/SVGNamespaces.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/svg/SVGStyles.js b/src/svg/SVGStyles.js index ba45e554..521650fb 100644 --- a/src/svg/SVGStyles.js +++ b/src/svg/SVGStyles.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/text/PointText.js b/src/text/PointText.js index d9a119a2..465c699f 100644 --- a/src/text/PointText.js +++ b/src/text/PointText.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/text/TextItem.js b/src/text/TextItem.js index 35cd6efa..55ed163a 100644 --- a/src/text/TextItem.js +++ b/src/text/TextItem.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/tool/Tool.js b/src/tool/Tool.js index 2f72c55e..0d02490d 100644 --- a/src/tool/Tool.js +++ b/src/tool/Tool.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/tool/ToolEvent.js b/src/tool/ToolEvent.js index c1450020..45fa4040 100644 --- a/src/tool/ToolEvent.js +++ b/src/tool/ToolEvent.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/ui/CanvasView.js b/src/ui/CanvasView.js index 03137cfb..83419c11 100644 --- a/src/ui/CanvasView.js +++ b/src/ui/CanvasView.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -143,7 +143,7 @@ var CanvasView = View.extend(/** @lends CanvasView# */{ return false; } - return { + return /** @lends CanvasView# */{ /** * Returns true if event was stopped, false otherwise, whether handler * was called or not! diff --git a/src/ui/Component.js b/src/ui/Component.js index 67b762ac..7fed1d50 100644 --- a/src/ui/Component.js +++ b/src/ui/Component.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/ui/Event.js b/src/ui/Event.js index 0ad74981..a49bdac0 100644 --- a/src/ui/Event.js +++ b/src/ui/Event.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/ui/Key.js b/src/ui/Key.js index db55cda6..13d65b74 100644 --- a/src/ui/Key.js +++ b/src/ui/Key.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/ui/KeyEvent.js b/src/ui/KeyEvent.js index 0dc13c32..47966caa 100644 --- a/src/ui/KeyEvent.js +++ b/src/ui/KeyEvent.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/ui/MouseEvent.js b/src/ui/MouseEvent.js index d780ae3d..cd27f4b7 100644 --- a/src/ui/MouseEvent.js +++ b/src/ui/MouseEvent.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/ui/Palette.js b/src/ui/Palette.js index 811c1a3d..2e691713 100644 --- a/src/ui/Palette.js +++ b/src/ui/Palette.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/src/ui/View.js b/src/ui/View.js index 42ed14c9..1fe44e7e 100644 --- a/src/ui/View.js +++ b/src/ui/View.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -706,8 +706,7 @@ var View = Base.extend(Callback, /** @lends View# */{ } if (view) { var point = viewToProject(view, event); - if (dragging || new Rectangle(new Point(), - view.getViewSize()).contains(point)) + if (dragging || view.getBounds().contains(point)) tool = handleMouseMove(view, point, event); } } diff --git a/src/util/Formatter.js b/src/util/Formatter.js index c5f45e51..707ab8f9 100644 --- a/src/util/Formatter.js +++ b/src/util/Formatter.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -12,9 +12,10 @@ /** * @name Formatter + * @class * @private */ -var Formatter = Base.extend({ +var Formatter = Base.extend(/** @lends Formatter# */{ /** * @param {Number} [precision=5] the amount of fractional digits. */ diff --git a/src/util/Numerical.js b/src/util/Numerical.js index f5d717c0..7d81a1e7 100644 --- a/src/util/Numerical.js +++ b/src/util/Numerical.js @@ -2,14 +2,19 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * * All rights reserved. */ +/** + * @name Numerical + * @namespace + * @private + */ var Numerical = new function() { // Lookup tables for abscissas and weights with values for n = 2 .. 16. @@ -75,7 +80,7 @@ var Numerical = new function() { }; } - return { + return /** @lends Numerical */{ TOLERANCE: TOLERANCE, // Precision when comparing against 0 EPSILON: EPSILON, @@ -114,13 +119,13 @@ var Numerical = new function() { findRoot: function(f, df, x, a, b, n, tolerance) { for (var i = 0; i < n; i++) { var fx = f(x), - dx = fx / df(x); + // Calculate a new candidate with the Newton-Raphson method. + dx = fx / df(x), + nx = x - dx; // See if we can trust the Newton-Raphson result. If not we use // bisection to find another candiate for Newton's method. if (abs(dx) < tolerance) - return x; - // Generate a candidate for Newton's method. - var nx = x - dx; + return nx; // Update the root-bounding interval and test for containment of // the candidate. If candidate is outside the root-bounding // interval, use bisection instead. @@ -135,6 +140,9 @@ var Numerical = new function() { x = nx >= b ? 0.5 * (a + b) : nx; } } + // Return the best result even though we haven't gotten close + // enough to the root... (In paper.js this never seems to happen). + return x; }, /** diff --git a/test/lib/helpers.js b/test/lib/helpers.js index dfb53cb2..67e56053 100644 --- a/test/lib/helpers.js +++ b/test/lib/helpers.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/load.js b/test/load.js index 629aac36..2a70ae25 100644 --- a/test/load.js +++ b/test/load.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Color.js b/test/tests/Color.js index 41bbe34f..6f8a51b0 100644 --- a/test/tests/Color.js +++ b/test/tests/Color.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -51,6 +51,14 @@ test('Set color to array', function() { }); test('Creating Colors', function() { + compareColors(new Color(), new Color(0, 0, 0), + 'Color with no arguments should be black'); + + compareColors(new Color('black'), new Color(0, 0, 0), + 'Color from name (black)'); + + compareColors(new Color('red'), new Color(1, 0, 0), + 'Color from name (red)'); compareColors(new Color('#ff0000'), new Color(1, 0, 0), 'Color from hex code'); @@ -203,7 +211,7 @@ test('Saturation from black rgb', function() { test('Color#add', function() { var color = new Color(0, 1, 1); compareColors(color.add([1, 0, 0]), [1, 1, 1]); - compareColors(color.add([1, 0.5, 0]), [1, 1, 1]); + compareColors(color.add([1, 0.5, 0]), [1, 1.5, 1]); var color = new Color(0, 0.5, 0); compareColors(color.add(0.5), [0.5, 1, 0.5]); }); @@ -229,7 +237,7 @@ test('Color#divide', function() { var color = new Color(1, 1, 1); compareColors(color.divide([1, 2, 4]), [1, 0.5, 0.25]); var color = new Color(1, 0.5, 0.25); - compareColors(color.divide(0.25), [1, 1, 1]); + compareColors(color.divide(0.25), [4, 2, 1]); var color = new Color(1, 1, 1); compareColors(color.divide(4), [0.25, 0.25, 0.25]); }); diff --git a/test/tests/CompoundPath.js b/test/tests/CompoundPath.js index 1b3a2b0e..74c346ba 100644 --- a/test/tests/CompoundPath.js +++ b/test/tests/CompoundPath.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Curve.js b/test/tests/Curve.js index 3c285f42..8c7b85ac 100644 --- a/test/tests/Curve.js +++ b/test/tests/Curve.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Group.js b/test/tests/Group.js index c29a3c13..85f992d4 100644 --- a/test/tests/Group.js +++ b/test/tests/Group.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/HitResult.js b/test/tests/HitResult.js index 2d4446b6..a21d0836 100644 --- a/test/tests/HitResult.js +++ b/test/tests/HitResult.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Item.js b/test/tests/Item.js index 251db2c8..e09699b3 100644 --- a/test/tests/Item.js +++ b/test/tests/Item.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Item_Bounds.js b/test/tests/Item_Bounds.js index 3f7c35be..d8346a20 100644 --- a/test/tests/Item_Bounds.js +++ b/test/tests/Item_Bounds.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Item_Cloning.js b/test/tests/Item_Cloning.js index ff434701..ab752c9b 100644 --- a/test/tests/Item_Cloning.js +++ b/test/tests/Item_Cloning.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Item_Contains.js b/test/tests/Item_Contains.js index c26d20cb..d419e4f2 100644 --- a/test/tests/Item_Contains.js +++ b/test/tests/Item_Contains.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Item_Order.js b/test/tests/Item_Order.js index 9d295fac..0f809c22 100644 --- a/test/tests/Item_Order.js +++ b/test/tests/Item_Order.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/JSON.js b/test/tests/JSON.js index a9035dc9..f233a6a1 100644 --- a/test/tests/JSON.js +++ b/test/tests/JSON.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Layer.js b/test/tests/Layer.js index 48a56f0d..a0297d3b 100644 --- a/test/tests/Layer.js +++ b/test/tests/Layer.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Matrix.js b/test/tests/Matrix.js index 89c10c2b..25e1330a 100644 --- a/test/tests/Matrix.js +++ b/test/tests/Matrix.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Path.js b/test/tests/Path.js index 299b817a..15d0a3cf 100644 --- a/test/tests/Path.js +++ b/test/tests/Path.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Path_Bounds.js b/test/tests/Path_Bounds.js index 659e0acd..20196b13 100644 --- a/test/tests/Path_Bounds.js +++ b/test/tests/Path_Bounds.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Path_Curves.js b/test/tests/Path_Curves.js index e9c512e4..2e45a20f 100644 --- a/test/tests/Path_Curves.js +++ b/test/tests/Path_Curves.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Path_Drawing_Commands.js b/test/tests/Path_Drawing_Commands.js index d4f9b7bb..70054eb7 100644 --- a/test/tests/Path_Drawing_Commands.js +++ b/test/tests/Path_Drawing_Commands.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Path_Length.js b/test/tests/Path_Length.js index 8241e551..ee0d91a6 100644 --- a/test/tests/Path_Length.js +++ b/test/tests/Path_Length.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Path_Shapes.js b/test/tests/Path_Shapes.js index 9b91f24a..f5c3f05f 100644 --- a/test/tests/Path_Shapes.js +++ b/test/tests/Path_Shapes.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/PlacedSymbol.js b/test/tests/PlacedSymbol.js index a085d3da..63682672 100644 --- a/test/tests/PlacedSymbol.js +++ b/test/tests/PlacedSymbol.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Point.js b/test/tests/Point.js index 9ad47e4b..5cebde0b 100644 --- a/test/tests/Point.js +++ b/test/tests/Point.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Project.js b/test/tests/Project.js index 12458205..f41cc21d 100644 --- a/test/tests/Project.js +++ b/test/tests/Project.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Raster.js b/test/tests/Raster.js index 551b76f2..613cba70 100644 --- a/test/tests/Raster.js +++ b/test/tests/Raster.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Rectangle.js b/test/tests/Rectangle.js index 2f877742..07b1f406 100644 --- a/test/tests/Rectangle.js +++ b/test/tests/Rectangle.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/SVGExport.js b/test/tests/SVGExport.js index 2e7b8caf..4ad73dc8 100644 --- a/test/tests/SVGExport.js +++ b/test/tests/SVGExport.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/SVGImport.js b/test/tests/SVGImport.js index 395e572b..14db3956 100644 --- a/test/tests/SVGImport.js +++ b/test/tests/SVGImport.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Segment.js b/test/tests/Segment.js index cabf0d68..492a8c5d 100644 --- a/test/tests/Segment.js +++ b/test/tests/Segment.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Size.js b/test/tests/Size.js index 70ca9c2e..93b75028 100644 --- a/test/tests/Size.js +++ b/test/tests/Size.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/Style.js b/test/tests/Style.js index af6a7aae..88e051ab 100644 --- a/test/tests/Style.js +++ b/test/tests/Style.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * diff --git a/test/tests/TextItem.js b/test/tests/TextItem.js index 94daeb4a..1aecea59 100644 --- a/test/tests/TextItem.js +++ b/test/tests/TextItem.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. * @@ -19,7 +19,7 @@ test('PointText', function() { point: [100, 100], content: 'Hello World!' }); - equals(text.fillColor, { red: 0, green: 0, blue: 0 }, 'text.fillColor should be black by default'); + compareColors(text.fillColor, new Color(0, 0, 0), 'text.fillColor should be black by default'); comparePoints(text.point, { x: 100, y: 100 }); compareRectangles(text.bounds, { x: 100, y: 87.4, width: 77, height: 16.8 }); equals(function() { diff --git a/test/tests/load.js b/test/tests/load.js index 107d163a..986cc42a 100644 --- a/test/tests/load.js +++ b/test/tests/load.js @@ -2,8 +2,8 @@ * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ * * Distributed under the MIT license. See LICENSE file for details. *