diff options
author | wout <wout@impinc.co.uk> | 2014-06-28 18:39:11 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-06-28 18:39:11 +0200 |
commit | 2260f5789b48dd92dccf0dd734cf59cf957e4d52 (patch) | |
tree | 2c94e66afe60e45f34db6ced5f24069ab4466c72 /src/bbox.js | |
parent | 0d11ad263f193e8a585e7676deb8a60a8c103ef6 (diff) | |
download | svg.js-2260f5789b48dd92dccf0dd734cf59cf957e4d52.tar.gz svg.js-2260f5789b48dd92dccf0dd734cf59cf957e4d52.zip |
Added new SVG.Line class and working on SVG.Matrix
Diffstat (limited to 'src/bbox.js')
-rwxr-xr-x | src/bbox.js | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/bbox.js b/src/bbox.js index c68bec5..1632a02 100755 --- a/src/bbox.js +++ b/src/bbox.js @@ -2,19 +2,19 @@ SVG.BBox = function(element) { var box - /* initialize zero box */ + // Initialize zero box this.x = 0 this.y = 0 this.width = 0 this.height = 0 - /* get values if element is given */ + // Get values if element is given if (element) { try { - /* actual, native bounding box */ + // Actual, native bounding box box = element.node.getBBox() } catch(e) { - /* fallback for some browsers */ + // Fallback for some browsers box = { x: element.node.clientLeft , y: element.node.clientTop @@ -23,16 +23,16 @@ SVG.BBox = function(element) { } } - /* include translations on x an y */ + // Include translations on x an y this.x = box.x + element.trans.x this.y = box.y + element.trans.y - /* plain width and height */ + // Plain width and height this.width = box.width * element.trans.scaleX this.height = box.height * element.trans.scaleY } - /* add center, right and bottom */ + // Add center, right and bottom boxProperties(this) } @@ -41,18 +41,15 @@ SVG.BBox = function(element) { SVG.extend(SVG.BBox, { // merge bounding box with another, return a new instance merge: function(box) { - var b = new SVG.BBox() + var b = new SVG.BBox - /* merge box */ + // Merge box b.x = Math.min(this.x, box.x) b.y = Math.min(this.y, box.y) b.width = Math.max(this.x + this.width, box.x + box.width) - b.x b.height = Math.max(this.y + this.height, box.y + box.height) - b.y - /* add center, right and bottom */ - boxProperties(b) - - return b + return boxProperties(b) } })
\ No newline at end of file |