开发者

Getting information from a Raphael object

开发者 https://www.devze.com 2022-12-14 23:08 出处:网络
I\'m using the raphael javascript svg rendering engine.If I use the following code var canvas = Raphael("canvas",700,500);

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号