Using SVG for animations

This is NOT a support forum. You are welcome to discuss software issues here, but all issues should be reported on Launchpad if you want them fixed.
dult
Posts: 1
Joined: Thu Apr 03, 2014 4:49 am

Using SVG for animations

Postby dult » Thu Apr 03, 2014 4:57 am

Hello everyone,

New to the forum here.
I really like using inkscape, it is a great software for illustrations, graphics, cover, etc. I really enjoy using open-source software because I find it to be more realible as closed-source.
Currently I use blender for motion graphics, and export them as video. But I searched the web for a simple animation program to create basic animations.
I don't mean moving characters or something as advanced as flash. I'm talking about and IDE, where we link pre made media (jpg png svg mp4 etc) and then organize them visually and animate some aspects (position, size, rotation). Ideally it would export in svg+js for a self-contained package.
I use sozi but something with animatable objects in a non programming environment would be great.
Does anyone know of such an app?

Thanks in advance.

hvfrancesco
Posts: 1
Joined: Fri Apr 04, 2014 10:23 pm

Re: Using SVG for animations

Postby hvfrancesco » Fri Apr 04, 2014 10:59 pm

maybe you should check Synfig, it's a very powerful vector based animation program, maybe a bit complex, but the learning curve it is not so steep.
You may also have a look at this code:
https://github.com/hvfrancesco/freestylesvg
Are a set of simple scripts that allow you to export multi-layered or even animated svg from blender thanks to freestyle integration

SmithWillSuffice
Posts: 1
Joined: Sun Jul 06, 2014 5:44 pm

Re: Using SVG for animations

Postby SmithWillSuffice » Sun Jul 06, 2014 5:58 pm

Hey all,
I just fiddled around with Inkscape, swftools and GIMP. It's easy to draw animations with inkscape. You do not need any extensions really.

Here're my notes:

Creating Animations Using Inscape, GIMP and swftools
==========================================

Note:
The output format I'm focusing on here is SWF, but if you have the exported PNG
frames then IageMagick's "convert" tool will also work to create an animated gif.
(e.g., `convert -delay 10 -loop 0 *.png animaion.gif` )

Since Inkscape currently does not have full suport form animation creation we
need to combine a few tools. But it's painless, and I cannto really imagine how
special animation modules/extensions for Inkscape woul make the work any
more efficient. The only tedious stuff is the drawing ofr frames and labelling
frames/layers. Inkscape has interpolation between objects to help with creation
of motion, so it's all rather cool.

Using GIMP after drawing your frames as Inkscape layers is the way to go, since
it allows us to avoid exporting individual frames. We can do it all as a batch process.
Or almost all. The only tedium is,
(a) drawing each frame (this can never be avoided when doing animation, but at
least in Inkscape you can run interpolations!), and
(b) you need to name the layers alpha-numerically, which probably means doing
the layer naming manually I think. Although you can try the defaults with use a "3",

Layer
layer#1
Layer#2
Layer#3

Inkscape does not however preserve the alpha-numeric order, if you move a
layer around, it's name stays the same. So don't move layers. Instead build
an animation by copy & paste into layers, and heavily using Duplicate layers.


A.1 Overview of SVG Conversion to SWF
---------------------------------------------------------------

First see below for ways to export Inkscape layers to separate animaion frames
into PNG files.

Then use the swftools package binary, `png2swf`. So first grab this:

$ sudo apt-get install swftools


A.2 Summary of SWF Animation from SVG Layers
--------------------------------------------------------------------------
0. In GIMP install python-fu and the export_layers extension.
(See section 19.3 for the instructions).
1. Create SVG in Inkscape using labelled layers as your movie frames.
2. File > Save As ... choose the format GIMP xcf (layers)
3. Open the saved .xcf file in Gimp:
- first open GIMP
- then open the sved.xcf file by choosing "Open as Layers...". (Ctrl-Alt-o)
4. File > Export Layers in GIMP and chosoe file forat "png. ANd choose a
directory, etc...
5. In a console `cd` to the layers directory you just save to...
... and run `png2swf ....`


A.3 Animated SWF from Layers (Overview)
-------------------------------------------------------------
Step 1. Make a SVG with layers, each layer a frame in your intended animation.

Setp 2. Export each layer as a bitmap, numbered in order. (See 19.2 below)

(these should be the only PNG files in the wd for conveience, or you can use
filename patterns next... in step 3)

Step 3. Roll-up the PNG images as a SWF animation,

e.g., something like,
$ png2swf -o myanimation.swf -r 10 *.png



B. Export Layers to Multiple Files
----------------------------------------------

B.1 Using GIMP Export Layers...
--------------------------------------------------
First we need python-fu to work in Gimp:

$ sudo apt-get remove --purge gimp
$ sudo apt-get install python-cairo-dev python-gobject-2-dev python-gtk2-dev
$ sudo apt-get install gimp gimp-data-extras

Next, download export_layers:
https://github.com/khalim19/gimp-plugin-export-layers

Unzip the archive and copy contents to ~/gimp-<ver>/plug-ins/

$ unzip gimp-plugin-export-layers-2.0.zip
$ cp -r gimp-plugin-export-layers-2.0/export_layers/ ~/.gimp-2.8/plug-ins/
$ cp gimp-plugin-export-layers-2.0/export_layers.py ~/.gimp-2.8/plug-ins/

Create your SVG layers in Inkscape.
You should label the layers in alpha-numeric order.
e.g., frmae 1 could be "f0", frame 2="f1", etc....

File > Save As ... choose the file format: Gimp (xcf)
Open the .xcf file in Gimp.
Choose Export Layers
Select an export director
In the Export Layers dialog choose a File format: e.g., png

Gimp should then create the image files, "f0.png", "f1.png", "f2.png", ... etc
one for each layer of the original Inkscape SVG picture.

Open a termninal.

`cd` to the exported layers directory.

We also need swftools:

$ sudo apt-get install swftools

We're almost done...


My test project was a ball moving to the top right and changing from sphere
to ellipse.

For a 2 frames per second animation run,
$ png2swf -r 2 -o balls.swf f*

The argument "f*" will shell glob expand of course, so it is really short for,

f0.png f10.png f11.png f1.png f2.png f3.png f4.png f5.png f6.png f7.png f8.png f9.png

So we first need to rename the layer images,

$ rename 's/(\d).png/f0$1.png/' f*

or if you have hundreds of frames,

$ rename 's/f(\d).png/f00$1.png/' f* ; rename 's/f(\d\d).png/f0$1.png/' f*

To check: for my test 12 frame animation...

$ echo f*
f00.png f01.png f02.png f03.png f04.png f05.png f06.png f07.png f08.png f09.png f10.png f11.png

$ png2swf -r 2 -o balls.swf f*


Play the animation in Firefox:

$ sudo apt-get install browser-plugin-gnash

$ firefox ./balls.swf &

Or a standalone SWF player:

$ sudo apt-get install gnash
$ gnash ./balls.swf &



B.2 Using svg-objects-export to Export Layers
--------------------------------------------------------------------

The following script purportedly allows for batch export (from command line) a set of
objects using inkscape, each to its own file.

https://github.com/berteh/svg-objects-export

But I have not tested it so I will not write notes about it. It looks like a good alternative
to using the GUI and mouse clicking.


C. That's All Folks
---------------------------

Those are just my rough notes, feel free to edit or suggest improvements. And apologies for any spelling errors. (I type fast and furiously.)

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Using SVG for animations

Postby v1nce » Sun Jul 06, 2014 11:06 pm

As more and more platform drop support for SWF it will be smarter to do it the other way around. Use Flash Pro 2014 and export your animation as svg.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Using SVG for animations

Postby brynn » Mon Jul 07, 2014 8:58 am

There's a whole block of info and links about Animation and Inkscape, on this page: http://forum.inkscapecommunity.com/index.php


Return to “Discuss Software Issues”