Define PaperScope#paper as a reference to the local scope.

And use it to fix Raster JSON example.
This commit is contained in:
Jürg Lehni 2013-11-01 11:46:31 +01:00
parent c76dae5b06
commit df80eb2f23
2 changed files with 13 additions and 1 deletions

View file

@ -15,7 +15,7 @@
</script>
<script type="text/paperscript" canvas="canvas2">
window.importJSON = function(json) {
project.activate();
paper.activate();
console.log(json);
project.importJSON(json);
}

View file

@ -113,6 +113,18 @@ var PaperScope = Base.extend(/** @lends PaperScope# */{
return this._tool;
},
/**
* A reference to the local scope. This is required, so `paper` will always
* refer to the local scope, even when calling into it from another scope.
* `paper.activate();` will have to be called in such a situation.
* @type PaperScript
* @private
* @bean
*/
getPaper: function() {
return this;
},
/**
* The list of available tools.
* @name PaperScope#tools