Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recording and saving an SVG animation as an animated GIF [closed]

Is there a library or tool for recording and saving an SVG animation as an animated GIF?

The SVG geometries are animated with JavaScript and D3.js, and their colors and opacities are animated with CSS 3.

like image 204
Jisike Avatar asked Jan 23 '14 21:01

Jisike


People also ask

Can you convert SVG animation to GIF?

If you need to convert animated SVG images to GIFs, you can convert animated SVG to GIF with an online converter or record animated SVG with a GIF recorder.

Can SVGs be animated?

SVG supports the ability to change vector graphics over time, to create animated effects. SVG content can be animated in the following ways: Using SVG's animation elements [svg-animation]. SVG document fragments can describe time-based modifications to the document's elements.

Why is my SVG not animating?

One of the most common reasons why the SVG animation doesn't work is the use of <img> tags to add the SVG. The SVG might be visible on the website, but the animation will not start. You can easily fix this by replacing all <img> tags with an <object> tag.


1 Answers

I found that simply using a screen capture program with gif recording feature satisfies all my needs, and it is reliable and clean. There are several such screen capture programs. I found LICEcap solid.

Here is (almost verbatim) my procedure from question mentioned above:

The solution uses a tool called LICEcap, a screen capture utility for Win and Mac. Steps are following:

  1. Download LICEcap here and install it. Now, if you start this program, it will have a rather unusual shape, just a thin frame, and everything inside the frame will be transparent: enter image description here

  2. Go to the window with your d3.js animation and prepare everything so that you could start animation at some point. Lets say we want to record this example from d3js.org: enter image description here

  3. Now start LICEcap and position it over the area you want to have in your animated gif: enter image description here

  4. Make sure that you enter at least 20 fps in the bottom left edit box, otherwise the recording will be low quality. Press record. A dialog will first appear, and you choose here whether you want your gif to be in an infinite loop, or just repeated once, or any number of times. Also an interesting option is to add some visual clues for mouse clicks. Choose also filename, and press Save. enter image description here

  5. Now you do whatever you have to do to trigger animations. I pressed several times buttons Grouped and Stacked. After I decided its enough, I pressed Stop. Resulting file is: enter image description here

That's it!

like image 130
VividD Avatar answered Oct 11 '22 17:10

VividD