Rectangle coordinates after transform

后端 未结 1 1778
萌比男神i
萌比男神i 2020-12-16 21:34

I am currently drawing a rectangle with a transformation on his parent element (g). The resulting svg is this;



        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 22:04

    I found the solution myself;

    var matrix = shape.getCTM();
    
    // transform a point using the transformed matrix
    var position = svg.createSVGPoint();
    position.x = $(shape).attr("x");
    position.y = $(shape).attr("y");
    position = position.matrixTransform(matrix);
    

    0 讨论(0)
提交回复
热议问题