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.

rulestext.md

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

Text in Manim

The Text class renders text using Pango/Cairo, supporting various fonts and styles.

Basic Text

from manim import *

class TextExample(Scene):
    def construct(self):
        text = Text("Hello World")
        self.play(Write(text))

Text Parameters

text = Text(
    "Hello World",
    font_size=48,           # Size (default: 48)
    color=BLUE,             # Text color
    font="Arial",           # Font family
    weight=BOLD,            # NORMAL, BOLD, etc.
    slant=ITALIC,           # NORMAL, ITALIC, OBLIQUE
    line_spacing=1.5,       # Space between lines
)

Font Size

# Using font_size parameter
small = Text("Small", font_size=24)
medium = Text("Medium", font_size=48)
large = Text("Large", font_size=72)

# Using scale after creation
text = Text("Hello").scale(2)

Custom Fonts

# Use any installed system font
text = Text("Custom Font", font="Comic Sans MS")
text = Text("Monospace", font="Courier New")
text = Text("Serif", font="Times New Roman")

Text Styling with MarkupText

Use Pango markup for mixed styling within one Text object:

class MarkupExample(Scene):
    def construct(self):
        text = MarkupText(
            f'all in red <span fgcolor="{YELLOW}">except this</span>',
            color=RED
        )
        self.play(Write(text))

Available Markup Tags

# Bold and italic
text = MarkupText('<b>Bold</b> and <i>Italic</i>')

# Colors using fgcolor
text = MarkupText('<span fgcolor="yellow">Yellow</span>')

# Subscripts and superscripts
text = MarkupText('H<sub>2</sub>O and x<sup>2</sup>')

# Font size
text = MarkupText('<big>Big</big> and <small>small</small>')

# Underline and strikethrough
text = MarkupText('<u>Underline</u> and <s>Strike</s>')

# Double underline with color
text = MarkupText('<span underline="double" underline_color="green">text</span>')

# Monospace
text = MarkupText('type <tt>help</tt> for help')

Gradients in MarkupText

# Global gradient
text = MarkupText("nice gradient", gradient=(BLUE, GREEN))

# Inline gradient
text = MarkupText(
    'nice <gradient from="RED" to="YELLOW">colored</gradient> text'
)

Escaping Special Characters

# Must escape these characters:
# > as &gt;
# < as &lt;
# & as &amp;
text = MarkupText("5 &gt; 3 and 2 &lt; 4")

Multi-line Text

# Using \n for line breaks
text = Text("Line 1\nLine 2\nLine 3")

# Using Paragraph for better control
from manim import Paragraph

para = Paragraph(
    "This is a longer text",
    "that spans multiple lines",
    "with automatic alignment",
    line_spacing=0.5
)

Coloring Parts of Text

class ColoredText(Scene):
    def construct(self):
        text = Text("Hello World")
        text[0:5].set_color(RED)    # "Hello" in red
        text[6:11].set_color(BLUE)  # "World" in blue
        self.play(Write(text))

Text with Gradients

text = Text("Gradient Text")
text.set_color_by_gradient(RED, YELLOW, GREEN)

Accessing Characters

text = Text("ABCDE")

# Individual characters
text[0]  # 'A'
text[1]  # 'B'

# Slices
text[0:3]  # 'ABC'
text[-1]   # 'E'

# Iterate
for char in text:
    char.set_color(random_color())

Text Positioning

# Standard positioning methods work
text = Text("Hello")
text.to_edge(UP)
text.to_corner(UL)
text.move_to(ORIGIN)
text.next_to(other_mobject, DOWN)

Best Practices

  1. Use Text for regular text - Simple and fast
  2. Use MarkupText for mixed styles - When you need multiple colors/weights
  3. Use MathTex for math - Text doesn't render LaTeX
  4. Install fonts system-wide - Manim uses system fonts
  5. Keep font_size consistent - Use the same size for related text

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.