ANN: Animations.jl

Hi there,

Animations.jl is a package for creating (unsurprisingly) animations, useful when you’re making animated visualizations and want to quickly lay down a timeline of changing values together with easing functions. I added all the functionality I needed that eases the pain of doing this manually. Maybe once it’s fun to transform a sine function into an easing function yourself, but not every time. Also repetitions and delays are common but annoying to implement correctly so you don’t have problems at keyframe borders. Syntax example:

using Animations

anim = Animation(
    0, 0,
    sineio(n=3, yoyo=true),
    2, 10,
    linear(),
    3, 20
)

anim_alternative_syntax = Animation(
    [0, 2, 3], [0, 10, 20], [sineio(n=3, yoyo=true), linear()]
)

value = anim(t)

You can animate numbers, arrays, colors, or add your own methods for custom types based on linear interpolation. You can loop keyframed animations or put multiple together in sequences, as well as loop sequences or sequence loops etc. so I hope all bases are covered… Additionally, the values outside of an animation are the same as at the endpoints, which reduces the amount of keyframes you need to set in most cases. You can also “animate” between discrete things like strings if you use discrete step easing functions, like this:

labelanim = Animation([0, 0.25, 0.5, 0.75, 1], ["first", "second", "third", "fourth", "fifth"], noease())
label = labelanim(t)

which in my opinion is better than writing chains of

label = if t < 0.25
    "first"
elseif 0.25 <= t <= 0.5
    "second"
elseif
elseif
elseif...

I hope other people will also find it useful and create beautiful and engaging animations to better convey their research.

14 Likes

Thanks, can you please give information about the backends etc in the README?

Do you mean the backends I used for the examples? You can click on the gifs and I’ve linked them to the source files for those animations. They use Layered.jl which is my own little vector graphics library that uses Cairo.

This looks interesting!

Have you thought of any animations involving graphs? Two examples might be combining with:

and in LightGraphs.jl there is an example in the source " It is often useful to track the evolution of the graph as vertices are added, you can access the graph from the t th stage of this algorithm by accessing the first t vertices with g[1:t]":

It seems very good. Unfortunately, I did not understand well the parameters of the Animation, could you explain them a little? I suggest you to document at the least the most important functions Documentation · The Julia Language (I can help you with that). Also, you can also use Documenter.jl, it is very simple and very useful for dumentation.

1 Like

Good point, haven’t gotten to real documentation, yet :slight_smile: I hoped it would be mostly self-explanatory, but that’s hard to judge if you’re the author

1 Like

I’ve added documentation here: https://jkrumbiegel.github.io/Animations.jl/dev/. Explanations are using static plots so far as I’m having a bit of trouble getting the code for gifs to work on Travis CI

3 Likes

Thanks you a lot. Now I understand the functions, and I can use them.