Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get absolute position of a SVG element

Suppose this snippet code with svg.js

var g1 = draw.group();
var g2 = g1.group();
g2.move(100,100);
var g3 = g2.group();
g3.rect(200,200);

Now, how i can get the absolute position of this rect?
Thanks for any help

like image 256
frogatto Avatar asked Dec 15 '25 16:12

frogatto


1 Answers

You can use the rbox function, which takes the translations into account.

Here is an example:

var draw = SVG('paper');
var g1 = draw.group();
var g2 = g1.group();
g2.move(100,100);
var g3 = g2.group();
var rect = g3.rect(200,200);

console.log(rect.rbox());
like image 77
Nils Avatar answered Dec 17 '25 04:12

Nils



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!