diff --git a/build/preprocess.sh b/build/preprocess.sh index ae32f850..83fcd483 100755 --- a/build/preprocess.sh +++ b/build/preprocess.sh @@ -31,7 +31,7 @@ # stripped Formated but without comments # compressed Uses UglifyJS to reduce file size -VERSION=0.2 +VERSION=0.21 DATE=$(git log -1 --pretty=format:%ad) COMMAND="./prepro.js -d '{ \"version\": $VERSION, \"date\": \"$DATE\" }' -d '$4' $2" diff --git a/dist/docs/classes/CompoundPath.html b/dist/docs/classes/CompoundPath.html index c946fad8..8332fcf7 100644 --- a/dist/docs/classes/CompoundPath.html +++ b/dist/docs/classes/CompoundPath.html @@ -2584,18 +2584,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/Group.html b/dist/docs/classes/Group.html index 09964e3b..9b4b70bf 100644 --- a/dist/docs/classes/Group.html +++ b/dist/docs/classes/Group.html @@ -1789,18 +1789,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/Item.html b/dist/docs/classes/Item.html index 9528318c..fb3be929 100644 --- a/dist/docs/classes/Item.html +++ b/dist/docs/classes/Item.html @@ -1654,18 +1654,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/Layer.html b/dist/docs/classes/Layer.html index c9bfc7b2..244196e1 100644 --- a/dist/docs/classes/Layer.html +++ b/dist/docs/classes/Layer.html @@ -1748,18 +1748,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/Path.html b/dist/docs/classes/Path.html index 36231796..c31da42a 100644 --- a/dist/docs/classes/Path.html +++ b/dist/docs/classes/Path.html @@ -4900,18 +4900,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/PathItem.html b/dist/docs/classes/PathItem.html index 70b21cfa..4cce21b1 100644 --- a/dist/docs/classes/PathItem.html +++ b/dist/docs/classes/PathItem.html @@ -2481,18 +2481,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/PlacedItem.html b/dist/docs/classes/PlacedItem.html index 18e366cf..efbc37cf 100644 --- a/dist/docs/classes/PlacedItem.html +++ b/dist/docs/classes/PlacedItem.html @@ -1695,18 +1695,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/PlacedSymbol.html b/dist/docs/classes/PlacedSymbol.html index de697a13..0b7c7db8 100644 --- a/dist/docs/classes/PlacedSymbol.html +++ b/dist/docs/classes/PlacedSymbol.html @@ -1781,18 +1781,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/PointText.html b/dist/docs/classes/PointText.html index 20cb8112..2ebd14af 100644 --- a/dist/docs/classes/PointText.html +++ b/dist/docs/classes/PointText.html @@ -1744,18 +1744,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/Raster.html b/dist/docs/classes/Raster.html index bbe7eae3..21c0e17a 100644 --- a/dist/docs/classes/Raster.html +++ b/dist/docs/classes/Raster.html @@ -2365,18 +2365,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/TextItem.html b/dist/docs/classes/TextItem.html index afc089b0..1a9860a6 100644 --- a/dist/docs/classes/TextItem.html +++ b/dist/docs/classes/TextItem.html @@ -1802,18 +1802,19 @@ points.

options.type: Only hit test again a certain item type: PathItem, Raster, TextItem, etc.

options.fill: Boolean - Hit test the fill of items.

-

options.stroke: Boolean - Hit test the curves of path items, -taking into account stroke width.

-

options.segment: Boolean - Hit test for segment.point of -Path items.

+

options.stroke: Boolean - Hit test the curves of path +items, taking into account stroke width.

+

options.segment: Boolean - Hit test for +segment.point of Path items.

options.handles: Boolean - Hit test for the handles (segment.handleIn / segment.handleOut) of path segments.

-

options.ends: Boolean - Only hit test for the first or last -segment points of open path items.

-

options.bounds: Boolean - Hit test the corners and side-centers -of the bounding rectangle of items (item.bounds).

-

options.center: Boolean - Hit test the rectangle.center -of the bounding rectangle of items (item.bounds).

+

options.ends: Boolean - Only hit test for the first or +last segment points of open path items.

+

options.bounds: Boolean - Hit test the corners and +side-centers of the bounding rectangle of items (item.bounds).

+

options.center: Boolean - Hit test the +rectangle.center of the bounding rectangle of items +(item.bounds).

options.guide: Boolean - Hit test items that have item.guide set to true.

options.selected: Boolean - Only hit selected items.

diff --git a/dist/docs/classes/Tool.html b/dist/docs/classes/Tool.html index 4a07cfce..8c5f0347 100644 --- a/dist/docs/classes/Tool.html +++ b/dist/docs/classes/Tool.html @@ -518,6 +518,62 @@ keys.

+ +

Methods

+ + +
+ + +
+ + +
+ + +
+ +
+ diff --git a/dist/docs/classes/View.html b/dist/docs/classes/View.html index ad23c19a..bfcb8e9e 100644 --- a/dist/docs/classes/View.html +++ b/dist/docs/classes/View.html @@ -50,8 +50,9 @@ screen.

  • canvas: -Canvas - +HTMLCanvasElement / String +— The canvas object that this +view should wrap, or the String id that represents it
  • @@ -379,6 +380,58 @@ function onResize(event) {

    Methods

    +
    + + +
    + + +
    + + +
    + +
    +
    +
    + + +
    + +
    diff --git a/dist/docs/resources/js/paper.js b/dist/docs/resources/js/paper.js index b5a250ea..ea11ce94 100644 --- a/dist/docs/resources/js/paper.js +++ b/dist/docs/resources/js/paper.js @@ -1,5 +1,5 @@ /*! - * Paper.js v0.2 + * Paper.js v0.21 * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. @@ -13,7 +13,7 @@ * * All rights reserved. * - * Date: Mon Aug 1 12:03:23 2011 +0100 + * Date: Tue Aug 2 10:08:08 2011 +0100 * *** * @@ -303,9 +303,12 @@ this.Base = Base.inject({ toString: function() { return '{ ' + Base.each(this, function(value, key) { - var type = typeof value; - this.push(key + ': ' + (type === 'number' ? Base.formatNumber(value) - : type === 'string' ? "'" + value + "'" : value)); + if (key.charAt(0) != '_') { + var type = typeof value; + this.push(key + ': ' + (type === 'number' + ? Base.formatNumber(value) + : type === 'string' ? "'" + value + "'" : value)); + } }, []).join(', ') + ' }'; }, @@ -406,7 +409,7 @@ var PaperScope = this.PaperScope = Base.extend({ PaperScope._scopes[this._id] = this; }, - version: 0.2, + version: 0.21, evaluate: function(code) { var res = PaperScript.evaluate(code, this); @@ -476,6 +479,33 @@ var PaperScope = this.PaperScope = Base.extend({ } }); +var PaperScopeItem = Base.extend({ + + initialize: function(activate) { + this._scope = paper; + this._index = this._scope[this._list].push(this) - 1; + if (activate || !this._scope[this._reference]) + this.activate(); + }, + + activate: function() { + if (!this._scope) + return false; + this._scope[this._reference] = this; + return true; + }, + + remove: function() { + if (this._index == null) + return false; + Base.splice(this._scope[this._list], null, this._index, 1); + if (this._scope[this._reference] == this) + this._scope[this._reference] = null; + this._scope = null; + return true; + } +}); + var Point = this.Point = Base.extend({ initialize: function(arg0, arg1) { if (arg1 !== undefined) { @@ -1623,14 +1653,15 @@ var Line = this.Line = Base.extend({ } }); -var Project = this.Project = Base.extend({ +var Project = this.Project = PaperScopeItem.extend({ + _list: 'projects', + _reference: 'project', + initialize: function() { - this._scope = paper; - this._index = this._scope.projects.push(this) - 1; + this.base(true); this._currentStyle = new PathStyle(); this._selectedItems = {}; this._selectedItemCount = 0; - this.activate(); this.layers = []; this.symbols = []; this.activeLayer = new Layer(); @@ -1649,25 +1680,6 @@ var Project = this.Project = Base.extend({ this._currentStyle.initialize(style); }, - activate: function() { - if (this._scope) { - this._scope.project = this; - return true; - } - return false; - }, - - remove: function() { - if (this._scope) { - Base.splice(this._scope.projects, null, this._index, 1); - if (this._scope.project == this) - this._scope.project = null; - this._scope = null; - return true; - } - return false; - }, - getIndex: function() { return this._index; }, @@ -6470,12 +6482,16 @@ DomEvent.requestAnimationFrame = new function() { }; }; -var View = this.View = Base.extend({ +var View = this.View = PaperScopeItem.extend({ + _list: 'views', + _reference: 'view', + initialize: function(canvas) { - this._scope = paper; - this._index = this._scope.views.push(this) - 1; + this.base(); var size; - if (canvas && canvas instanceof HTMLCanvasElement) { + if (typeof canvas === 'string') + canvas = document.getElementById(canvas); + if (canvas instanceof HTMLCanvasElement) { this._canvas = canvas; if (PaperScript.hasAttribute(canvas, 'resize')) { var offset = DomElement.getOffset(canvas, true), @@ -6530,6 +6546,17 @@ var View = this.View = Base.extend({ this._scope._redrawNotified = false; }, + remove: function() { + if (!this.base()) + return false; + if (View._focused == this) + View._focused = null; + delete View._views[this._id]; + DomEvent.remove(this._canvas, this._events); + this._canvas = this._events = this._onFrame = null; + return true; + }, + getCanvas: function() { return this._canvas; }, @@ -6623,22 +6650,6 @@ var View = this.View = Base.extend({ return true; }, - activate: function() { - this._scope.view = this; - }, - - remove: function() { - if (this._index == null) - return false; - if (View._focused == this) - View._focused = null; - delete View._views[this._id]; - Base.splice(this._scope.views, null, this._index, 1); - DomEvent.remove(this._canvas, this._events); - this._scope = this._canvas = this._events = this._onFrame = null; - return true; - }, - projectToView: function(point) { return this._matrix._transformPoint(Point.read(arguments)); }, @@ -7046,9 +7057,12 @@ var ToolEvent = this.ToolEvent = Event.extend({ } }); -var Tool = this.Tool = Base.extend({ +var Tool = this.Tool = PaperScopeItem.extend({ + _list: 'tools', + _reference: 'tool', + initialize: function() { - this._scope = paper; + this.base(); this._firstMove = true; this._count = 0; this._downCount = 0; @@ -7675,7 +7689,7 @@ var parse_js=new function(){function W(a,b,c){var d=[];for(var e=0;e