Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate the coordinate of a SVG object after rotation and scaling?

I wants to know the coordinates of a SVG object (i.e ending x and y coordinates if starting x,y coordinates and height,widths are known to us) after rotation and scaling of that SVG object.

Is there any way to calculate Ending coordinates of the SVG objects after rotation ?

If anybody knows please help me to solve this problem.

like image 244
Babu Avatar asked Nov 08 '22 16:11

Babu


1 Answers

BBox method is helpful to get your starting and end point after or before applying the shape or object.

You can select the object using d3 or jquery
        if you are using d3 the select in this way 
                    var rect = d3.select(selecteObject);
        if jquery then 
                   var rect = $(selecteObject);
                   var newx = rect.node().getBBox().x;
                   var newy = rect.node().getBBox().y;
                   var neww = rect.node().getBBox().width;
                   var newh = rect.node().getBBox().height;
                   var endCodinatex = newx + neww;
                   var endCodinatY = newy + newh;
like image 192
nitesh singh Avatar answered Nov 15 '22 06:11

nitesh singh