aboutsummaryrefslogtreecommitdiffstats
path: root/src/bbox.js
blob: 22c5bcf6b4583b729338e1821c9d93413a83ca0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
SVG.BBox = function(element) {
  var box
  
  /* actual, native bounding box */
  try {
    box = element.node.getBBox()
  } catch(e) {
    box = {
      x:      element.node.clientLeft
    , y:      element.node.clientTop
    , width:  element.node.clientWidth
    , height: element.node.clientHeight
    }
  }
  
  /* include translations on x an y */
  this.x = box.x + element.trans.x
  this.y = box.y + element.trans.y
  
  /* plain width and height */
  this.width  = box.width  * element.trans.scaleX
  this.height = box.height * element.trans.scaleY
  
  /* add the center */
  this.cx = this.x + this.width / 2
  this.cy = this.y + this.height / 2
  
}