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?
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.
精彩评论