Merge remote branch 'origin/master'

This commit is contained in:
Jonathan Puckey 2011-06-30 13:56:02 +02:00
commit 1d6b5e23c8
5 changed files with 135 additions and 130 deletions

View file

@ -262,7 +262,7 @@ about the mouse event.</p>
<ul><b>Type:</b>
<li>
<tt>function</tt>
<tt>Function</tt>
</li>
</ul>
@ -315,7 +315,7 @@ move by setting the <a href="../classes/Tool.html#eventinterval" onclick="return
<ul><b>Type:</b>
<li>
<tt>function</tt>
<tt>Function</tt>
</li>
</ul>
@ -368,7 +368,7 @@ about the mouse event.</p>
<ul><b>Type:</b>
<li>
<tt>function</tt>
<tt>Function</tt>
</li>
</ul>
@ -422,7 +422,7 @@ mouse event.</p>
<ul><b>Type:</b>
<li>
<tt>function</tt>
<tt>Function</tt>
</li>
</ul>

View file

@ -17,9 +17,9 @@
<h1>View</h1>
<p>The View object wraps a canvas element and handles drawing and user
interaction trhough mouse and keyboard for it. It offer means to scroll the
interaction through mouse and keyboard for it. It offer means to scroll the
view, find the currently visible bounds in project coordinates, or the
center, both useful fo constructing artwork that should appear centered on
center, both useful for constructing artwork that should appear centered on
screen.</p>
</div>
@ -295,7 +295,7 @@ event.</p>
<ul><b>Type:</b>
<li>
<tt>function</tt>
<tt>Function</tt>
</li>
</ul>
@ -347,7 +347,7 @@ function onFrame(event) {
<ul><b>Type:</b>
<li>
<tt>function</tt>
<tt>Function</tt>
</li>
</ul>

File diff suppressed because one or more lines are too long

79
dist/paper.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1043,50 +1043,7 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
* @bean
*/
getBounds: function() {
return this._getBounds(false);
},
/**
* The bounding rectangle of the item including stroke width.
*
* @type Rectangle
* @bean
*/
getStrokeBounds: function() {
return this._getBounds(true);
},
_getBounds: function(includeStroke) {
var children = this._children;
// TODO: What to return if nothing is defined, e.g. empty Groups?
// Scriptographer behaves weirdly then too.
if (!children || children.length == 0)
return new Rectangle();
var getBounds = includeStroke ? 'getStrokeBounds' : 'getBounds',
x1 = Infinity,
x2 = -Infinity,
y1 = x1,
y2 = x2;
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
if (child._visible) {
var rect = child[getBounds]();
x1 = Math.min(rect.x, x1);
y1 = Math.min(rect.y, y1);
x2 = Math.max(rect.x + rect.width, x2);
y2 = Math.max(rect.y + rect.height, y2);
}
}
var bounds = Rectangle.create(x1, y1, x2 - x1, y2 - y1);
return includeStroke ? bounds : this._createBounds(bounds);
},
/**
* Creates a LinkedRectangle that when modified calls #setBounds().
*/
_createBounds: function(rect) {
return LinkedRectangle.create(this, 'setBounds',
rect.x, rect.y, rect.width, rect.height);
return this._getBounds('getBounds');
},
setBounds: function(rect) {
@ -1110,6 +1067,52 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
this.transform(matrix);
},
/**
* The bounding rectangle of the item including stroke width.
*
* @type Rectangle
* @bean
*/
getStrokeBounds: function() {
return this._getBounds('getStrokeBounds');
},
/**
* Loops through all children, gets their bounds and finds the bounds around
* all of them.
*/
_getBounds: function(getter) {
var children = this._children;
// TODO: What to return if nothing is defined, e.g. empty Groups?
// Scriptographer behaves weirdly then too.
if (!children || children.length == 0)
return new Rectangle();
var x1 = Infinity,
x2 = -Infinity,
y1 = x1,
y2 = x2;
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
if (child._visible) {
var rect = child[getter]();
x1 = Math.min(rect.x, x1);
y1 = Math.min(rect.y, y1);
x2 = Math.max(rect.x + rect.width, x2);
y2 = Math.max(rect.y + rect.height, y2);
}
}
var bounds = Rectangle.create(x1, y1, x2 - x1, y2 - y1);
return getter == 'getBounds' ? this._createBounds(bounds) : bounds;
},
/**
* Creates a LinkedRectangle that when modified calls #setBounds().
*/
_createBounds: function(rect) {
return LinkedRectangle.create(this, 'setBounds',
rect.x, rect.y, rect.width, rect.height);
},
/**
* The bounding rectangle of the item including stroke width and controls.
*/