All skills
adithya-s-k avatar

/manimgl-best-practices

@2375ac0
by Adithya S Kadithya-s-k/manim_skill1.1k stars
94

Trigger when: (1) User mentions "manimgl" or "ManimGL" or "3b1b manim", (2) Code contains `from manimlib import *`, (3) User runs `manimgl` CLI commands, (4) Working with InteractiveScene, self.frame, self.embed(), ShowCreation(), or ManimGL-specific patterns. Best practices for ManimGL (Grant Sanderson's 3Blue1Brown version) - OpenGL-based animation engine with interactive development. Covers InteractiveScene, Tex with t2c, camera frame control, interactive mode (-se flag), 3D rendering, and checkpoint_paste() workflow. NOT for Manim Community Edition (which uses `manim` imports and `manim` CLI).

Use this Skill: https://skilld.dev/gh/adithya-s-k/manim_skill/manimgl-best-practices

This session only. Nothing lands on disk.

rulescli.md

≈2.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Command Line Interface in ManimGL

ManimGL uses the manimgl command for rendering scenes. It offers powerful flags for different workflows.

Basic Usage

Running a Scene

# Basic syntax
manimgl scene_file.py SceneName

# Example
manimgl my_animation.py SquareToCircle

Auto-Select Scene

# If only one scene in file, it runs automatically
manimgl my_animation.py

# If multiple scenes, presents a menu to choose from
manimgl my_animations.py

Common Flags

Writing to File

# Write to file (no preview)
manimgl scene.py MyScene -w

# Write and open the file
manimgl scene.py MyScene -o

# Show final frame only
manimgl scene.py MyScene -s

# Save final frame as image and show
manimgl scene.py MyScene -so

Interactive Mode

# Skip to line 15 and enter interactive mode
manimgl scene.py MyScene -se 15

# Interactive mode at specific line
manimgl scene.py MyScene --skip_animations --embed 20

Display Options

# Fullscreen window
manimgl scene.py MyScene -f

# Custom window size
manimgl scene.py MyScene --resolution 1920,1080

# Hide progress bar
manimgl scene.py MyScene --quiet

Quality and Resolution

Resolution Presets

# Low quality (for testing)
manimgl scene.py MyScene -l

# Medium quality
manimgl scene.py MyScene -m

# High quality (1080p)
manimgl scene.py MyScene -h

# 4K quality
manimgl scene.py MyScene --uhd

# Custom resolution
manimgl scene.py MyScene --resolution 2560,1440

Frame Rate

# Set frame rate (default is 60)
manimgl scene.py MyScene --frame_rate 30

# Lower frame rate for faster renders
manimgl scene.py MyScene --frame_rate 15

Advanced Flags

Skip to Specific Animation

# Skip to nth animation
manimgl scene.py MyScene -n 5

# Skip animations (instant mode)
manimgl scene.py MyScene --skip_animations

Output Options

# Specify output file
manimgl scene.py MyScene -o output.mp4

# Save as GIF
manimgl scene.py MyScene --format gif

# Transparent background
manimgl scene.py MyScene --transparent

Configuration

# Use custom config file
manimgl scene.py MyScene --config_file custom_config.yml

# Set specific config values
manimgl scene.py MyScene --config camera_config.frame_rate=30

Interactive Development

The -se Flag

The -se (skip and embed) flag is ManimGL's killer feature:

# Drop into interactive shell at line 15
manimgl scene.py MyScene -se 15

In the interactive shell:

# Use abbreviated commands (no self.)
play(circle.animate.shift(RIGHT))
add(Square())
remove(circle)
wait(2)

# Copy code to clipboard, then:
checkpoint_paste()              # Run with animations
checkpoint_paste(skip=True)     # Run instantly
checkpoint_paste(record=True)   # Record while running

# Interactive camera control
touch()  # Press 'd' + mouse to rotate, 'z' + scroll to zoom

# Exit
exit()

File Organization

Running from Different Directories

# From same directory as manimlib/
manimgl project/scene.py MyScene

# With absolute path
manimgl /full/path/to/scene.py MyScene

# With relative path
manimgl ../other_project/scene.py MyScene

Combining Flags

Common Combinations

# High quality, write and open
manimgl scene.py MyScene -h -o

# Low quality, fullscreen, for testing
manimgl scene.py MyScene -l -f

# Skip animations, final frame only
manimgl scene.py MyScene -s --skip_animations

# Interactive at line 20, low quality
manimgl scene.py MyScene -l -se 20

# Save as GIF, high quality
manimgl scene.py MyScene -h --format gif -o

Workflow Examples

Development Workflow

# 1. Initial testing (low quality, fast)
manimgl scene.py MyScene -l

# 2. Interactive debugging at specific point
manimgl scene.py MyScene -l -se 25

# 3. Check final frame
manimgl scene.py MyScene -s

# 4. Final render (high quality, save and open)
manimgl scene.py MyScene -h -o

Quick Preview Workflow

# Show final frame immediately
manimgl scene.py MyScene -s

# If it looks good, render full animation
manimgl scene.py MyScene -o

Batch Rendering

# Render multiple scenes
for scene in Scene1 Scene2 Scene3; do
    manimgl scenes.py $scene -h -w
done

Debugging Flags

Verbose Output

# Show detailed output
manimgl scene.py MyScene --verbose

# Show all debug info
manimgl scene.py MyScene --debug

Profiling

# Show performance stats
manimgl scene.py MyScene --profile

# Detailed timing information
manimgl scene.py MyScene --timing

Configuration Override

Temporary Config Changes

# Override window size
manimgl scene.py MyScene --config window_config.size=fullscreen

# Override output directory
manimgl scene.py MyScene --config directories.output=/tmp/manim

# Multiple overrides
manimgl scene.py MyScene \
    --config camera_config.frame_rate=30 \
    --config camera_config.pixel_width=1280

Help and Information

Getting Help

# Show all available flags
manimgl --help

# Show version
manimgl --version

# List scenes in file without running
manimgl scene.py --list_scenes

Full CLI Reference

All Major Flags

# Quality/Resolution
-l, --low_quality           # 480p, 15fps
-m, --medium_quality        # 720p, 30fps
-h, --high_quality          # 1080p, 60fps
--uhd                       # 4K, 60fps
--resolution WIDTHxHEIGHT   # Custom resolution

# Output
-w, --write_file            # Write to file
-o, --open                  # Write and open
-s, --show_last_frame       # Show final frame
--format FORMAT             # Output format (mp4, gif, png)
--transparent               # Transparent background

# Playback
-f, --fullscreen            # Fullscreen window
-n NUM, --skip_to NUM       # Skip to animation number
--skip_animations           # Skip all animations

# Interactive
-e, --embed                 # Drop into IPython shell
--skip_animations --embed   # Interactive at end (skip animations)
-se LINE, --skip_and_embed  # Interactive at line number

# Configuration
--config_file FILE          # Custom config file
--config KEY=VALUE          # Override config value

# Debugging
--verbose                   # Verbose output
--debug                     # Debug mode
--quiet                     # Minimize output
--profile                   # Performance profiling

# Other
--version                   # Show version
--help                      # Show help
--list_scenes               # List scenes in file

Best Practices

  1. Use -l for development: Fast iteration with low quality
  2. Use -se for debugging: Interactive mode at problem points
  3. Use -s for quick checks: Verify final frame before full render
  4. Use -h -o for final: High quality output when ready
  5. Combine flags wisely: -l -f for fullscreen testing
  6. Custom configs: Use different configs for different projects
  7. Script common commands: Create shell aliases for frequent tasks

Common Aliases

Add to .bashrc or .zshrc:

# Quick preview
alias mgl='manimgl -l'

# Final render
alias mgf='manimgl -h -o'

# Interactive debug
alias mgd='manimgl -l -se'

# Show final frame
alias mgs='manimgl -s'

Troubleshooting

Common Issues

# Scene not found
manimgl scene.py  # Lists all scenes if you don't specify

# Can't find manimlib
# Ensure you're in the directory with manimlib/ or use full paths

# Window not showing
# Check window_config in custom_config.yml

# Poor performance
# Use -l flag, reduce frame_rate, or lower resolution

Example Commands

# Simple preview
manimgl examples/basic_animations.py SquareToCircle

# High quality render
manimgl examples/basic_animations.py SquareToCircle -h -o

# Interactive debugging at line 30
manimgl examples/basic_animations.py SquareToCircle -se 30

# Save as GIF
manimgl examples/basic_animations.py SquareToCircle --format gif -o

# Custom resolution
manimgl examples/basic_animations.py SquareToCircle --resolution 2560,1440

# Skip to 5th animation and show
manimgl examples/basic_animations.py SquareToCircle -n 5

# Fullscreen, low quality for testing
manimgl examples/basic_animations.py SquareToCircle -l -f

Source: SKILL.md on GitHub

No alerts17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill is an educational resource for the ManimGL mathematical animation library, providing best practices and functional examples. All code patterns, including CLI boilerplate and external asset references, are standard and safe for the intended use cases.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    1/107 files flagged

  • ZeroLeaks5mo

    1 finding · Score: 86/100

Signed by skilld at 2375ac0. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago

README badge

README badge for adithya-s-k/manim_skill/manimgl-best-practices