Scale path from center

后端 未结 3 762
渐次进展
渐次进展 2020-12-06 04:37

I have the following SVG graphic:



        
3条回答
  •  执笔经年
    2020-12-06 05:09

    If you know the coordinates of the center point, then you can combine a translate and scale in one transformation. The translation is calculated as: (1 - scale) * currentPosition.

    If the center is (10, 20) and you are scaling by 3 then translate by (1 - 3)*10, (1 - 3)*20 = (-20, -40):

    
        
    
    

    The transformations are applied in reverse order from the one they are declared, so in the example, above, the scale is performed first and then the translate. Scaling affects the coordinates so the translation here is in scaled coordinates.

    You can calculate the center point programmatically using element.getBBox().

提交回复
热议问题