Reanimate is a library for programmatically generating animations with a twist towards mathematics / 2D vector drawings. A lot of inspiration was drawn from 3b1b's manim library.
Reanimate aims at being a batteries-included way of gluing together different technologies: SVG as a universal image format, LaTeX for typesetting, ffmpeg for video encoding, inkscape/imagemagick for rasterization, potrace for vectorization, blender/povray for 3D graphics, and Haskell for scripting.
In more practical terms, reanimate is a library for turning code like this:
main = reanimate $ docEnv $ playThenReverseA drawCircle
... into animations like this:
If you like what you see, boost reanimate's visibility with a star ⭐ or consider becoming a sponsor ❤.
Reanimate is built using the Haskell Tool Stack. For installation instructions, see: https://docs.haskellstack.org/en/stable/README/
Optionally, you can install one or more of these programs to enable additional features:
- ffmpeg, enables rendering animations to video files.
- latex, enables mathematical typesetting.
- inkscape/imagemagick, enables SVG->PNG convertions.
- potrace, enables PNG->SVG tracing.
- povray, enables raytracing.
- blender, enables 3D graphics.
I highly recommend that you install at least 'ffmpeg' and 'latex'.
Reanimate ships with a web-based viewer and automatic code reloading. To get a small demo up and running, clone the repository, run one of the examples (this will install the library), and wait for a browser window to open:
$ git clone https://github.com/reanimate/reanimate.git
$ cd reanimate/
$ stack build
$ stack ./examples/doc_drawCircle.hs
This should render the doc_drawCircle
example in a new browser window. If you then change the
animation source code, the browser window will automatically reload and show the updated animation.
It's also possible to use cabal instead of stack:
$ git clone https://github.com/reanimate/reanimate.git
$ cd reanimate/
$ cabal v2-build
$ # Workaround for a cabal bug: https://github.com/haskell/cabal/issues/6235
$ export reanimate_datadir=`pwd`
$ cabal v2-exec -- runhaskell examples/doc_drawCircle.hs --ghc ghc
If you'd rather use nix to build an environment with all of the system dependencies mentioned previously do:
$ git clone https://github.com/reanimate/reanimate.git
$ cd reanimate/
$ nix-shell
[nix-shell:./reanimate]$ cabal v2-build --write-ghc-environment-files=always
If you have cachix available run cachix use cdodev
before you drop into the nix shell. This will significantly speed things up!
This will write a file in the working directory like
.ghc.environment.x86_64-linux-8.8.3
which will enable commands like runhaskell
to pick up reanimate.
Now, still within the nix-shell
you can run:
[nix-shell:./reanimate]$ reanimate_datadir=. runhaskell examples/doc_drawCircle.hs --ghc `which ghc`
- API reference: https://hackage.haskell.org/package/reanimate/docs/Reanimate.html
- Core concepts: https://reanimate.readthedocs.io/en/latest/introduction/
- Design overview: https://reanimate.readthedocs.io/en/latest/glue_tut/
- N-Queens tutorial (somewhat dated, uses reanimate from October 2019): https://williamyaoh.com/posts/2020-05-31-reanimate-nqueens-tutorial.html
- You can also ask questions in the discord channel: https://discord.gg/Qs28Dv6
- Cross-platform. Official support for Linux, MacOS, and Windows.
- Well-documented. API reference documentation include GIFs to illustrate behavior, and in-depth tutorial/explanation articles are hosted on readthedocs.io.
- Advanced type-setting via LaTeX.
- Voice control: Align animation timings with a transcript.
- 3D graphics: Built-in support for integrating povray and blender.
- Mapping: Built-in support for GeoJSON and map projections.
- Online playground for toying with reanimate scripts.
- Easy-to-use font selection when using latex/xelatex/luatex.
- Polygon morphing framework with support for several algorithms, including: linear interpolation, as-rigid-as-possible interpolation, and intersection-free interpolation.
- Built-in tools for creating presentations.
- David Himmelstrup.
- Jan Hrcek.
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
- Huge thanks to 3b1b's manim which inspired this library.
- Thanks to svg-tree for their SVG library.
- Thanks to CthulhuDen/chiphunk for making a 2D physics library easily available.
- Thanks to Peter Johnson for reserving the 'reanimate' organization on GitHub.
Completed animations are uploaded to the Reanimated Science channel.
Animation snippets are uploaded to the Reanimated Science Shorts channel.