I want to rotate e.g. a svg-rect around a certain point without using transform-origin, say only using chained translates and (origin-)rotates.
Due to my research I found out you do that this way:
but when I use
transform="translate(-100, -50) rotate(30) translate(100, 50)"
it turns out to be rendered at the wrong position compared to
transform="rotate(30, 100, 50)"
I have made a fiddle for this: http://jsfiddle.net/VYmrX/. The blue rect is the original rect, the green one is for comparison and the red one is transformed with the approach from above. I want it to be rotated around its center (100, 50).
How can I obtain that without using the transform-origin?
You're nearly there but it's the other way round,
transform="translate(100, 50) rotate(30) translate(-100, -50)"
is equivalent to transform="rotate(30, 100, 50)"
You kind of need to read multiple transforms from right to left as it is the rightmost part that is applied first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With