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.

rulestex.md

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

ManimGL LaTeX (Tex Class)

Tex vs MathTex

Important: ManimGL uses Tex class (not MathTex like ManimCE).

# ManimGL - use Tex with capital R raw strings
formula = Tex(R"\int_0^1 x^2 \, dx = \frac{1}{3}")

# NOT like ManimCE:
# formula = MathTex(r"\int...")  # Wrong for ManimGL

Raw Strings with Capital R

Always use capital R for raw strings to avoid escaping issues:

# Good - capital R
Tex(R"\frac{a}{b}")
Tex(R"\vec{v}")
Tex(R"\sum_{n=1}^{\infty}")

# Also works but less readable
Tex("\\frac{a}{b}")

Color Mapping with t2c

Use t2c (tex_to_color) parameter to color specific parts:

equation = Tex(
    R"E = mc^2",
    t2c={"E": BLUE, "m": GREEN, "c": YELLOW}
)

For more complex coloring:

formula = Tex(
    R"\vec{F} = m\vec{a}",
    t2c={
        R"\vec{F}": BLUE,
        R"\vec{a}": RED,
        "m": GREEN,
    }
)

set_color_by_tex

Color parts after creation:

formula = Tex(R"\sum_{n=1}^{\infty} \frac{1}{n^2}")
formula.set_color_by_tex("n", BLUE)
formula.set_color_by_tex(R"\infty", YELLOW)

Isolating Substrings

Get parts of a formula for animation:

formula = Tex(R"a^2 + b^2 = c^2")

# Access by index
a_squared = formula[0]  # "a^2"

# Or use isolate parameter
formula = Tex(
    R"a^2", "+", R"b^2", "=", R"c^2",
)
# Now formula[0] is "a^2", formula[1] is "+", etc.

Text vs Tex

# Regular text
text = Text("Hello World")

# LaTeX math
math = Tex(R"\pi \approx 3.14159")

# Mixed (use TexText for text in math context)
mixed = TexText("The value of ", R"$\pi$", " is important")

TexText

For text that may contain inline math:

sentence = TexText(
    "The area is ", R"$\pi r^2$", ".",
    t2c={R"$\pi r^2$": YELLOW}
)

Aligned Equations

equations = Tex(R"""
    \begin{align*}
    f(x) &= x^2 + 2x + 1 \\
    &= (x + 1)^2
    \end{align*}
""")

Common LaTeX Symbols

# Greek letters
Tex(R"\alpha, \beta, \gamma, \delta, \theta, \phi, \pi")

# Operators
Tex(R"\sum, \prod, \int, \oint, \partial")

# Relations
Tex(R"\leq, \geq, \neq, \approx, \equiv")

# Sets
Tex(R"\in, \subset, \cup, \cap, \emptyset")

# Arrows
Tex(R"\rightarrow, \leftarrow, \Rightarrow, \Leftrightarrow")

# Fractions
Tex(R"\frac{a}{b}, \dfrac{a}{b}")

# Roots
Tex(R"\sqrt{x}, \sqrt[3]{x}")

# Matrices
Tex(R"\begin{pmatrix} a & b \\ c & d \end{pmatrix}")

Font Size

# Use font_size parameter
small = Tex(R"\pi", font_size=24)
large = Tex(R"\pi", font_size=72)

# Or scale after creation
small.scale(1.5)

Backstroke for Readability

When placing text over colored backgrounds:

label = Tex(R"f(x)")
label.set_backstroke(BLACK, 5)  # Black outline

Debugging LaTeX

If LaTeX doesn't render:

  1. Check for missing packages in your LaTeX installation
  2. Try simpler expressions first
  3. Check the intermediate .tex files in the output directory
  4. Use \text{} for regular text inside math

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