A highly optimized and generalized Manim project that creates mesmerizing epicycle animations from any image using Fourier transforms.
- ✅ Multi-format support: Works with SVG, PNG, and JPG images
- ✅ Highly configurable: All settings in one easy-to-edit config file
- ✅ Optimized performance: Efficient FFT-based calculations
- ✅ Clean architecture: Modular, well-documented code
- ✅ Flexible visualization: Toggle circles, arrows, and customize colors
Ensure you have the required dependencies:
pip install manim pillow scipy svgpathtoolsFor PNG/JPG to SVG conversion (optional):
# Install ImageMagick and Potrace
# Windows: Download from official websites
# Linux: sudo apt-get install imagemagick potrace
# Mac: brew install imagemagick potrace-
Configure your animation in
config.py:IMAGE_PATH = 'images/your_image.svg' # or .png, .jpg N_VECTORS = 300 # Number of epicycles NUM_SAMPLES = 10000 # Sampling resolution ANIMATION_DURATION = 50.0 # Animation length in seconds
-
Run the animation:
# Quick preview (low quality) manim -pql fourier_drawing.py FourierDrawing # High quality render manim -pqh fourier_drawing.py FourierDrawing # 4K quality manim -pqk fourier_drawing.py FourierDrawing
All settings are in config.py:
IMAGE_PATH: Path to your image file (SVG, PNG, or JPG)
N_VECTORS: Number of epicycles (100-500 recommended)NUM_SAMPLES: Sampling resolution (1000-10000 recommended)
ANIMATION_DURATION: Duration in seconds for one complete cyclePAUSE_AT_END: Pause duration after completing the drawing
DRAW_CIRCLES: Show/hide rotating circlesDRAW_ARROWS: Show/hide rotating vectorsSHOW_TRACER_DOT: Show/hide the drawing point- Various color and style options
d:/Python/Manim/
├── config.py # Main configuration file
├── fourier_drawing.py # Main animation script
├── helpers/
│ ├── fourier_calc.py # Fourier transform calculations
│ └── complex_to_np.py # Utility functions
├── images/
│ ├── vectorize.py # PNG/JPG to SVG converter
│ └── [your images]
└── media/ # Rendered videos (created automatically)
The script automatically handles PNG/JPG files by detecting edges. For better results, you can convert them to SVG first:
cd images
python vectorize.py your_image.jpg output.svgThen update config.py:
IMAGE_PATH = 'images/output.svg'- Start small: Begin with
N_VECTORS=100andNUM_SAMPLES=1000for quick tests - Simple images work best: High-contrast, simple shapes produce cleaner results
- Adjust duration: Longer durations (50-100s) look smoother but take longer to render
- Quality vs. Speed:
- More vectors = more detail but slower rendering
- More samples = smoother paths but slower preprocessing
| Setting | Fast | Balanced | High Quality |
|---|---|---|---|
| N_VECTORS | 50-100 | 200-300 | 500-1000 |
| NUM_SAMPLES | 1000-2000 | 5000-10000 | 10000-20000 |
| Render time | <1 min | 2-5 min | 10+ min |
pip install pillowpip install svgpathtools- Check the file path in
config.py - Ensure the image file exists
- Try using an absolute path
- Increase
ANIMATION_DURATIONinconfig.py - Ensure
PAUSE_AT_ENDis set to a positive value
- Increase
NUM_SAMPLESfor smoother paths - Increase
N_VECTORSfor more detail - Use higher render quality:
-pqhor-pqk
See the images/ directory for example images and their settings:
- Simple logo (N_VECTORS=100, NUM_SAMPLES=2000, Duration=20s)
- Complex drawing (N_VECTORS=500, NUM_SAMPLES=10000, Duration=60s)
This project is open source and available for educational purposes.
Built with:
- Manim Community
- NumPy, SciPy
- svgpathtools
- Pillow (PIL)