Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top