diff options
author | wout <wout@impinc.co.uk> | 2013-08-22 15:30:15 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-08-22 15:30:15 +0100 |
commit | 0ceb9b29401e26181d0b05cf8fed4c6aa1627447 (patch) | |
tree | 1d61b8ea4d172e82f3a0116032e178f34ec3639b /dist/svg.js | |
parent | bd58094c43ab78bec28ec97e62e71af9ad2febb4 (diff) | |
download | svg.js-0ceb9b29401e26181d0b05cf8fed4c6aa1627447.tar.gz svg.js-0ceb9b29401e26181d0b05cf8fed4c6aa1627447.zip |
Added merge() method to SVG.RBox
Diffstat (limited to 'dist/svg.js')
-rw-r--r-- | dist/svg.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/dist/svg.js b/dist/svg.js index 84b8892..0753468 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js v0.32-3-gd93be6c - svg regex default color array number viewbox bbox rbox element parent container fx event defs group arrange mask clip gradient doc shape use rect ellipse line poly path plotable image text textpath nested sugar set memory loader - svgjs.com/license */ +/* svg.js v0.32-4-gbd58094 - svg regex default color array number viewbox bbox rbox element parent container fx event defs group arrange mask clip gradient doc shape use rect ellipse line poly path plotable image text textpath nested sugar set memory loader - svgjs.com/license */ ;(function() { this.SVG = function(element) { @@ -685,6 +685,27 @@ this.cy = this.y + this.height / 2 } + + // + SVG.extend(SVG.RBox, { + // merge rect box with another, return a new instance + merge: function(box) { + var b = new SVG.RBox() + + /* 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 the center */ + b.cx = b.x + b.width / 2 + b.cy = b.y + b.height / 2 + + return b + } + + }) SVG.Element = function(node) { /* make stroke value accessible dynamically */ |