0

I try to rotate rectangle around his central point but I can't understand how it is working. Is there simple code in svg that make the issue without Cos Sin function or complex code. I try after some alot of testing and I finally sucsses but if I want to resize the retangle or to move it to centeral page all be mess,can you give me intentness how to do that? thanks. jsfiddle.net

my code:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect x="10" y="10" height="100" width="100"
         style="stroke:#FF0000; fill: #9C4100">

        <animateTransform
            attributeName="transform"
            begin="0s"
            dur="40s"
            type="rotate"
            from="0 60 60"
            to="360 60 60"
            repeatCount="1" 
        />
    </rect>
<circle id="pointA" cx="60" cy="60" r="48" />
</svg>​
WendiKidd
  • 4,333
  • 4
  • 33
  • 50

1 Answers1

2

Center your images on origo and "transform" them to the desired position. I believe you want something like this;

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
 <g transform="translate(250,200)">
   <rect x="-50" y="-50" height="100" width="100"
     style="stroke:#FF0000; fill: #9C4100">

    <animateTransform
        attributeName="transform"
        begin="0s"
        dur="20s"
        type="rotate"
        from="0"
        to="360"
        repeatCount="1" 
    />
   <animateTransform attributeName="transform"
    type="scale" from="1" to="2" 
    additive="sum" begin="0" dur="20s" fill="freeze"/>
  </rect>
  <circle id="pointA" cx="0" cy="0" r="48" />
</g>
</svg>
lgekman
  • 5,451
  • 1
  • 13
  • 13