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.

rulespositioning.md

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

Positioning in Manim

Methods for placing and moving mobjects in the scene.

Coordinate System

Manim uses a coordinate system where:

  • Origin (0, 0, 0) is at the center of the screen
  • X-axis: LEFT (-) to RIGHT (+)
  • Y-axis: DOWN (-) to UP (+)
  • Z-axis: IN (-) to OUT (+) (for 3D)

Direction Constants

UP = np.array([0, 1, 0])
DOWN = np.array([0, -1, 0])
LEFT = np.array([-1, 0, 0])
RIGHT = np.array([1, 0, 0])
ORIGIN = np.array([0, 0, 0])

# Diagonals
UL = UP + LEFT      # Upper left
UR = UP + RIGHT     # Upper right
DL = DOWN + LEFT    # Lower left
DR = DOWN + RIGHT   # Lower right

move_to

Move to an absolute position.

from manim import *

class MoveToExample(Scene):
    def construct(self):
        circle = Circle()

        # Move to origin
        circle.move_to(ORIGIN)

        # Move to specific coordinates
        circle.move_to(RIGHT * 2 + UP * 1)

        # Move to another mobject's position
        square = Square().shift(LEFT * 2)
        circle.move_to(square)

        # Move to a specific point of another mobject
        circle.move_to(square.get_top())

shift

Move relative to current position.

class ShiftExample(Scene):
    def construct(self):
        circle = Circle()

        # Shift in one direction
        circle.shift(RIGHT)
        circle.shift(UP * 2)

        # Shift in multiple directions
        circle.shift(RIGHT * 2 + UP * 1)

        # Chain shifts
        circle.shift(LEFT).shift(DOWN)

next_to

Position relative to another mobject.

class NextToExample(Scene):
    def construct(self):
        square = Square()
        circle = Circle()
        triangle = Triangle()

        # Place circle to the right of square
        circle.next_to(square, RIGHT)

        # With buffer (spacing)
        triangle.next_to(square, DOWN, buff=0.5)

        # Aligned to specific edge
        circle.next_to(square, RIGHT, aligned_edge=UP)

buff Parameter

# Default buffer
circle.next_to(square, RIGHT)  # Uses DEFAULT_MOBJECT_TO_MOBJECT_BUFFER

# Custom buffer
circle.next_to(square, RIGHT, buff=0)    # No gap
circle.next_to(square, RIGHT, buff=1)    # 1 unit gap
circle.next_to(square, RIGHT, buff=0.5)  # Half unit gap

align_to

Align edges with another mobject.

class AlignToExample(Scene):
    def construct(self):
        square = Square().shift(LEFT)
        circle = Circle().shift(RIGHT)

        # Align circle's left edge with square's left edge
        circle.align_to(square, LEFT)

        # Align tops
        circle.align_to(square, UP)

        # Align to a point
        circle.align_to(ORIGIN, DOWN)

Edge Methods

Position at screen edges.

class EdgeExample(Scene):
    def construct(self):
        # To screen edges
        text1 = Text("Top").to_edge(UP)
        text2 = Text("Bottom").to_edge(DOWN)
        text3 = Text("Left").to_edge(LEFT)
        text4 = Text("Right").to_edge(RIGHT)

        # With buffer
        text5 = Text("Buffered").to_edge(UP, buff=1)

Corner Methods

Position at screen corners.

class CornerExample(Scene):
    def construct(self):
        t1 = Text("UL").to_corner(UL)
        t2 = Text("UR").to_corner(UR)
        t3 = Text("DL").to_corner(DL)
        t4 = Text("DR").to_corner(DR)

        # With buffer
        t5 = Text("Buffered").to_corner(UL, buff=0.5)

center

Center on screen or another mobject.

mobject.center()           # Center on screen
mobject.center_on(other)   # Center on another mobject (custom helper)

Getting Positions

circle = Circle()

# Get various points
circle.get_center()        # Center point
circle.get_top()           # Top edge center
circle.get_bottom()        # Bottom edge center
circle.get_left()          # Left edge center
circle.get_right()         # Right edge center
circle.get_corner(UL)      # Upper left corner
circle.get_corner(DR)      # Lower right corner
circle.get_start()         # Start of path
circle.get_end()           # End of path

Animated Positioning

class AnimatedPosition(Scene):
    def construct(self):
        square = Square()
        self.add(square)

        # Animate movement
        self.play(square.animate.shift(RIGHT * 2))
        self.play(square.animate.move_to(UP * 2))
        self.play(square.animate.to_edge(LEFT))

Best Practices

  1. Use next_to for relative positioning - Maintains relationships
  2. Use move_to for absolute positioning - Precise coordinates
  3. Use shift for relative adjustments - Quick tweaks
  4. Use to_edge/to_corner for screen positioning - Responsive layouts
  5. Adjust buff for visual spacing - Don't let elements crowd

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.