18.10.2009

SVG and rotations

While building a exporting facility into bunch of geometry-generation classes, I ran into simple, yet interesting problems related to the way transforming happens in SVG.

Thus, here are some notes related to transforming SVG-elements.

Some ways to rotate SVG-elements.

Attribute transform:

<rect x="25" y="50" width="150" height="100" transform="rotate(-45 100 100)">
</rect>


Enclosing inside a group:

<g transform="rotate(45)"> <!-- graphics elements go here --> </g>


Enclosing inside a use:

<pre><defs>
<rect id="MyRect" width="60" height="10">
</rect>
</defs></pre><use x="20" y="10" href="#MyRect">
</use>