views:

218

answers:

1

I'm using the raphael javascript svg rendering engine. If I use the following code

var canvas = Raphael("canvas",700,500);
var circ = canvas.circle(30,20,10);

some_function(circ);

is there any way for some_function to extract the 30, 20 or 10 from the circle object that has been created?

+1  A: 

One solution that might work is using the attr method

function some_function(circle){
   return [circle.attr('cx'), circle.attr('cy'), circle.attr('r')]
}

which will return array of values

or

function some_function(circle){
   return circle.attr(['cx','cy','r']);
}

which will return object literal containing all attributes as keys.

Rafael
Awesome! Thank you! I knew you could set the attributes with the attr method; I missed the part of the documentation that let you get it too.
Ryan