Created
March 24, 2013 02:36
-
-
Save iros/5230224 to your computer and use it in GitHub Desktop.
transform svg element around its center
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// transform around center: | |
// formula: matrix(sx, 0, 0, sy, cx-sx*cx, cy-sy*cy) | |
var b = el.getBBox(); | |
var center = [b.x + b.width/2, b.y + b.height/2]; | |
var factor = 1.8; | |
el.attr('transform','matrix(' + factor + ', 0, 0, ' + factor + ', ' + | |
(center[0] - factor * center[0]) + | |
',' + (center[1] - factor * center[1])+')'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment