Ryan
Ryan

Reputation: 2112

Getting information from a Raphael object

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?

Upvotes: 1

Views: 1677

Answers (1)

Rafael
Rafael

Reputation: 18522

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.

Upvotes: 3

Related Questions