Reanimate is:

  • An animation library - a system for turning code into movies, similar to 3b1b's manim of YouTube fame.
  • User friendly - extensively documented with example animations covering the entire API.
  • Cross-platform - works on Linux, Mac and Windows.

Getting started

Viewing a basic animation

$ git clone https://github.com/Lemmih/reanimate.git
$ cd reanimate/
$ stack build
$ stack ./examples/doc_andThen.hs

Running the above code should open a browser window containing this animation:

Toggle doc_andThen.hs source code.

  #!/usr/bin/env stack
-- stack runghc --package reanimate
module Main(main) where

import Reanimate
import Reanimate.Builtin.Documentation

main :: IO ()
main = reanimate $ docEnv $ drawBox `andThen` drawCircle
  


Checking dependencies

If something doesn't work, you can run a check for run-time dependencies like this:

$ stack ./examples/doc_andThen.hs check
reanimate checks:
  Has ffmpeg:                        4.1.3-0ubuntu1
  Has dvisvgm:                       /usr/bin/dvisvgm
  Has povray:                        /usr/bin/povray
  Has blender:                       2.82
  Has rsvg-convert:                  2.44.10
  Has inkscape:                      0.92.4
  Has convert:                       6.9.10-14
  Has LaTeX:                         /usr/bin/latex
  Has LaTeX package 'babel':         OK
  Has LaTeX package 'preview':       OK
  Has LaTeX package 'amsmath':       OK
  Has XeLaTeX:                       /usr/bin/xelatex
  Has XeLaTeX package 'ctex':        OK

None of these dependencies are vital but the functionality of reanimate will be reduced if they are missing. For example, without 'ffmpeg', you won't be able to generate stand-alone video files (but can still view animations in a browser window). Without 'LaTeX' and 'dvisvgm', you won't be able use LaTeX for typesetting.

Rendering animations

reanimate has builtin support for rendering animations to video files and gifs. To render an animation with default options, use the 'render' command:

$ stack ./examples/doc_andThen.hs render

For computationally intense animations, use the --compile flag to compile your animation script and run it using all available cores:

$ stack ./examples/doc_andThen.hs render --compile

If the defaults are too aggressive for you tastes, change them directly or use a different preset:

$ stack ./examples/doc_andThen.hs render --preset high --fps 10

Rendering to gifs automatically does two passes and uses a color palette to improve the quality and size of the gif. GIFs are, by default, rendered at 24 fps with a resolution of 320x180:

$ stack ./examples/doc_andThen.hs render --format gif

Learning resources