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.

rulesstyling.md

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

Styling Mobjects

Control the visual appearance of mobjects with fill, stroke, and opacity settings.

Fill Properties

Fill controls the interior of shapes.

from manim import *

class FillExample(Scene):
    def construct(self):
        # Set fill on creation
        circle = Circle(fill_color=BLUE, fill_opacity=0.8)

        # Set fill after creation
        square = Square()
        square.set_fill(RED, opacity=0.5)

        self.add(circle, square)

Fill Methods

mobject.set_fill(color=RED)                    # Color only
mobject.set_fill(RED, opacity=0.5)             # Color and opacity
mobject.set_fill(opacity=0.5)                  # Opacity only
mobject.set_fill_color(RED)                    # Color only (alternative)
mobject.set_fill_opacity(0.5)                  # Opacity only (alternative)

Stroke Properties

Stroke controls the outline/border of shapes.

class StrokeExample(Scene):
    def construct(self):
        # Set stroke on creation
        circle = Circle(stroke_color=BLUE, stroke_width=4)

        # Set stroke after creation
        square = Square()
        square.set_stroke(RED, width=8)

        self.add(circle, square)

Stroke Methods

mobject.set_stroke(color=RED)                  # Color only
mobject.set_stroke(RED, width=4)               # Color and width
mobject.set_stroke(width=4)                    # Width only
mobject.set_stroke(opacity=0.5)                # Opacity only
mobject.set_stroke_color(RED)                  # Color only (alternative)
mobject.set_stroke_width(4)                    # Width only (alternative)
mobject.set_stroke_opacity(0.5)                # Opacity only (alternative)

Stroke Width Reference

# Common stroke widths
DEFAULT_STROKE_WIDTH = 4
thin = 1
normal = 4
thick = 8
very_thick = 12

Combined Styling

class CombinedStyling(Scene):
    def construct(self):
        square = Square()
        square.set_fill(BLUE, opacity=0.5)
        square.set_stroke(YELLOW, width=6)
        self.add(square)

Method Chaining

square = Square().set_fill(RED, 0.5).set_stroke(WHITE, 4)

The set_style Method

Set multiple style properties at once:

square = Square()
square.set_style(
    fill_color=BLUE,
    fill_opacity=0.5,
    stroke_color=WHITE,
    stroke_width=4,
    stroke_opacity=1
)

Opacity

Control transparency of mobjects:

# Overall opacity
mobject.set_opacity(0.5)  # Affects both fill and stroke

# Separate opacities
mobject.set_fill_opacity(0.8)
mobject.set_stroke_opacity(0.3)

# Fade effect
mobject.fade(0.5)  # 0.5 = 50% faded (opposite of opacity)

Background Rectangle

Add a background behind text or other mobjects:

class BackgroundExample(Scene):
    def construct(self):
        text = Text("Important!")
        bg = BackgroundRectangle(text, fill_opacity=0.8, buff=0.1)
        group = VGroup(bg, text)
        self.add(group)

Applying Style to Submobjects

# Apply to all submobjects (family=True, default)
group.set_fill(RED, opacity=0.5, family=True)

# Apply only to parent, not submobjects
group.set_fill(RED, opacity=0.5, family=False)

Style Based on Position

class GradientFill(Scene):
    def construct(self):
        squares = VGroup(*[Square() for _ in range(5)]).arrange(RIGHT)

        for i, sq in enumerate(squares):
            opacity = (i + 1) / 5
            sq.set_fill(BLUE, opacity=opacity)

        self.add(squares)

Copying Style

# Copy style from another mobject
source = Circle().set_fill(RED, 0.5).set_stroke(WHITE, 4)
target = Square()
target.match_style(source)  # Now has same fill and stroke

Best Practices

  1. Use fill_opacity for shapes - Fully opaque fills can hide other elements
  2. Consistent stroke width - Pick a width and stick with it
  3. Contrast fill and stroke - Different colors help definition
  4. Use BackgroundRectangle for readability - Behind text on busy backgrounds
  5. Chain methods for concise code - But break lines if too long

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.