Get BBox of a GROUP of Raphael objects?

4.2k views Asked by At

What's the best way to get the bounding box of several Raphael objects as a whole?

Can I put them all in a set and call mySet.getBBox()?

Or do I need to loop through them all, get bbox for each one and calculate the overall height and width?

(Also, I can't use SVG directly - I need VML support.)

1

There are 1 answers

2
peteorpeter On BEST ANSWER

Uh. It's really easy. (Thanks @Dylan):

var paper = Raphael ('test', 100, 100);

var circles = paper.set();

var c1 = paper.circle(70,30,10);
var c2 = paper.circle(50,10,10);
var c3 = paper.circle(10,80,10);

circles.push(c1, c2, c3);

alert(c3.getBBox().width); // --> 20

alert(circles.getBBox().width); // --> 80