/prosvg

Programmatic SVG images and animations

Primary LanguagePythonMIT LicenseMIT

ProSVG - Programmatic SVG with Python

Demo

This module works using Python's native xml module, with functions and classes to intuitively create SVG graphics

One of the goals of this module is to easily plot mathematical functions using svg <path> tags.

Script used to generate the image above

Animations

Programmatic SVG Basic Transformations Plotting Functions Parametric Equations 3D Animations 3D Equations

With a focus on geometry and mathematics, svg objects can be animated with this module.

View the complete animation

How it Works

Similar to 3blue1brown's manim, the animation module renders the svg file as an image and pipes it to ffmpeg.

  1. Increase animation time by dt
  2. Update svg objects (transformations, movement, etc.)
  3. If an animation has exceeded its runtime, it will be removed from the object
  4. Convert svg to png using CairoSVG
  5. Pipe png image to FFmpeg
  6. Repeat until the animation ends

Installation

  1. Clone and cd into the repository
  2. Run pip install .