All skills
adithya-s-k avatar

/manimce-best-practices

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

Trigger when: (1) User mentions "manim" or "Manim Community" or "ManimCE", (2) Code contains `from manim import *`, (3) User runs `manim` CLI commands, (4) Working with Scene, MathTex, Create(), or ManimCE-specific classes. Best practices for Manim Community Edition - the community-maintained Python animation engine. Covers Scene structure, animations, LaTeX/MathTex, 3D with ThreeDScene, camera control, styling, and CLI usage. NOT for ManimGL/3b1b version (which uses `manimlib` imports and `manimgl` CLI).

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

This session only. Nothing lands on disk.

rulescamera.md

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

Camera Control

Control what the viewer sees with camera manipulation.

MovingCameraScene

For 2D scenes with camera movement (zoom, pan).

from manim import *

class CameraExample(MovingCameraScene):
    def construct(self):
        circle = Circle()
        square = Square().shift(RIGHT * 3)
        self.add(circle, square)

        # Access camera frame
        # self.camera.frame is the viewable area

Zooming

Zoom In/Out by Scaling Frame

class ZoomExample(MovingCameraScene):
    def construct(self):
        dots = VGroup(*[Dot() for _ in range(100)])
        dots.arrange_in_grid(10, 10, buff=0.3)
        self.add(dots)

        # Zoom in (make frame smaller)
        self.play(self.camera.frame.animate.scale(0.5))
        self.wait()

        # Zoom out (make frame larger)
        self.play(self.camera.frame.animate.scale(4))

Zoom to Specific Width

class ZoomToWidth(MovingCameraScene):
    def construct(self):
        text = Text("Focus on me!")
        self.add(text)

        # Zoom to fit text with padding
        self.play(
            self.camera.frame.animate.set(width=text.width * 1.5)
        )

Panning

Move Camera to Location

class PanExample(MovingCameraScene):
    def construct(self):
        c1 = Circle().shift(LEFT * 3)
        c2 = Circle().shift(RIGHT * 3)
        self.add(c1, c2)

        # Pan to first circle
        self.play(self.camera.frame.animate.move_to(c1))
        self.wait()

        # Pan to second circle
        self.play(self.camera.frame.animate.move_to(c2))

Combined Zoom and Pan

class ZoomAndPan(MovingCameraScene):
    def construct(self):
        square = Square().shift(LEFT * 2)
        triangle = Triangle().shift(RIGHT * 2)
        self.add(square, triangle)

        # Zoom in and pan simultaneously
        self.play(
            self.camera.frame.animate.scale(0.5).move_to(square)
        )
        self.wait()

        # Move to triangle (still zoomed)
        self.play(self.camera.frame.animate.move_to(triangle))

Save and Restore Camera State

class SaveRestoreCamera(MovingCameraScene):
    def construct(self):
        circle = Circle()
        self.add(circle)

        # Save current state
        self.camera.frame.save_state()

        # Make changes
        self.play(self.camera.frame.animate.scale(0.3).move_to(circle))
        self.wait()

        # Restore to saved state
        self.play(Restore(self.camera.frame))

auto_zoom

Automatically zoom to fit mobjects.

class AutoZoomExample(MovingCameraScene):
    def construct(self):
        squares = VGroup(*[
            Square().shift(RIGHT * i + UP * j)
            for i in range(-2, 3) for j in range(-2, 3)
        ])
        self.add(squares)

        # Zoom to fit specific mobject
        self.play(self.camera.auto_zoom(squares[0]))
        self.wait()

        # Zoom to fit all with margin
        self.play(self.camera.auto_zoom(squares, margin=1))

3D Camera (ThreeDScene)

class ThreeDCameraExample(ThreeDScene):
    def construct(self):
        axes = ThreeDAxes()
        sphere = Sphere()
        self.add(axes, sphere)

        # Set initial camera orientation
        self.set_camera_orientation(
            phi=75 * DEGREES,    # Angle from z-axis
            theta=-45 * DEGREES  # Angle around z-axis
        )

Animated Camera Rotation

class RotatingCamera(ThreeDScene):
    def construct(self):
        axes = ThreeDAxes()
        self.add(axes)

        self.set_camera_orientation(phi=75 * DEGREES, theta=0)

        # Continuous rotation
        self.begin_ambient_camera_rotation(rate=0.2)
        self.wait(5)
        self.stop_ambient_camera_rotation()

Move 3D Camera

class Move3DCamera(ThreeDScene):
    def construct(self):
        axes = ThreeDAxes()
        self.add(axes)

        self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES)

        # Animate camera movement
        self.move_camera(
            phi=45 * DEGREES,
            theta=45 * DEGREES,
            run_time=3
        )

Camera Background

class CameraBackground(Scene):
    def construct(self):
        # Set background color
        self.camera.background_color = BLUE_E

        circle = Circle()
        self.add(circle)

Best Practices

  1. Use MovingCameraScene for zoom/pan - Regular Scene camera is static
  2. Save state before complex movements - Easy to restore
  3. Use auto_zoom for dynamic content - Automatically fits content
  4. Keep camera movements smooth - Don't make viewers dizzy
  5. Use 3D camera rotation sparingly - Can be disorienting

Source: SKILL.md on GitHub

No alerts17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill is a comprehensive educational resource for the Manim Community Edition library. It provides best practices, templates, and example scripts for creating mathematical animations and visualizations. No security risks or malicious patterns were identified.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    37 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 6668663. 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
  • Python
  • manim
  • animation
  • latex
  • mathtex
  • 3d
  • rendering
  • scene
  • visualization

README badge

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

Provides best practices and patterns for Manim Community Edition, the Python animation library for mathematical visualizations. Covers Scene structure, animations, LaTeX rendering, 3D graphics, positioning, and CLI usage with organized rule files, working examples, and templates.

Generated from the current SKILL.md.

Does this skill cover ManimGL or just Manim Community Edition?
Only Manim Community Edition (ManimCE). It does not apply to ManimGL/3b1b version, which uses `manimlib` imports and the `manimgl` CLI instead.
What topics are included in this skill?
Scene structure, mobjects, animations (creation, transformation, groups), text and LaTeX rendering, styling, positioning, 3D visualization, timing and updaters, camera control, CLI usage, and common geometric shapes.
Does this skill include working examples?
Yes. It includes five complete example files demonstrating basic animations, math visualization, updater patterns, graph plotting, and 3D visualization, plus three scene templates for 2D, camera-controlled, and 3D scenes.
What should I do if text rendering fails in my Manim scripts?
Check your manimpango installation requirements, as text rendering failures often stem from manimpango configuration issues. The skill also recommends running `manim checkhealth` to verify your overall installation.
How do I render a scene with different quality levels?
Use quality flags with the manim CLI: `-ql` for low quality (fast, development), `-qm` for medium, `-qh` for high, and `-qk` for 4K. For example: `manim -pqh scene.py MyScene`.

Generated from the current SKILL.md. These answers refresh after source changes.