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.

rulescolors.md

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

Colors in Manim

Manim provides predefined color constants and supports custom colors.

Color Constants

Primary Colors

RED, GREEN, BLUE
YELLOW, ORANGE, PINK, PURPLE
WHITE, BLACK, GREY (or GRAY)

Color Variants (Shades)

Most colors have variants from _A (lightest) to _E (darkest):

BLUE_A, BLUE_B, BLUE_C, BLUE_D, BLUE_E
RED_A, RED_B, RED_C, RED_D, RED_E
GREEN_A, GREEN_B, GREEN_C, GREEN_D, GREEN_E
GREY_A, GREY_B, GREY_C, GREY_D, GREY_E

Common Named Colors

TEAL, TEAL_A, TEAL_B, TEAL_C, TEAL_D, TEAL_E
GOLD, GOLD_A, GOLD_B, GOLD_C, GOLD_D, GOLD_E
MAROON, MAROON_A, MAROON_B, MAROON_C, MAROON_D, MAROON_E
PURPLE, PURPLE_A, PURPLE_B, PURPLE_C, PURPLE_D, PURPLE_E

Special Colors

PURE_RED, PURE_GREEN, PURE_BLUE  # RGB primaries
LIGHT_GREY, DARK_GREY
LIGHTER_GREY, DARKER_GREY
LIGHT_BROWN, DARK_BROWN

Using Colors

Setting Color on Creation

circle = Circle(color=RED)
square = Square(color=BLUE, fill_color=GREEN, fill_opacity=0.5)
text = Text("Hello", color=YELLOW)

Setting Color After Creation

circle = Circle()
circle.set_color(RED)

Hex Colors

# Use hex strings
circle = Circle(color="#FF5733")
square = Square(color="#2ECC71")

# RGB values (0-1 range)
from manim import rgb_to_color
custom = rgb_to_color([0.5, 0.2, 0.8])

Fill vs Stroke Color

square = Square()
square.set_fill(RED, opacity=0.8)      # Interior color
square.set_stroke(BLUE, width=4)       # Border color

Combined Styling

square = Square(
    color=BLUE,            # Sets both fill and stroke
    fill_opacity=0.5,      # Fill transparency
    stroke_width=4         # Border thickness
)

Gradients

Color Gradient on Mobject

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

Gradient Along Path

line = Line(LEFT * 3, RIGHT * 3)
line.set_color_by_gradient(BLUE, GREEN, YELLOW)

Color Interpolation

Create colors between two colors:

from manim import interpolate_color

# Get color halfway between RED and BLUE
mid_color = interpolate_color(RED, BLUE, 0.5)

# Create a range of colors
colors = [interpolate_color(RED, BLUE, alpha) for alpha in np.linspace(0, 1, 10)]

ManimColor Class

For advanced color manipulation, use ManimColor directly:

from manim import ManimColor

# Create from various formats
color1 = ManimColor("#FF0000")           # From hex
color2 = ManimColor((0.0, 1.0, 0.5))     # From RGB floats (0-1)
color3 = ManimColor([255, 165, 0])       # From RGB ints (0-255)

# Color manipulation methods
lighter = color1.lighter()               # Lighter version
darker = color1.darker()                 # Darker version
inverted = color1.invert()               # Inverted color
with_alpha = color1.opacity(0.5)         # With 50% opacity

# Convert formats
hex_str = color1.to_hex()                # To hex string
rgb = color1.to_rgb()                    # To RGB float array
hsv = color1.to_hsv()                    # To HSV array

# Interpolation
mixed = color1.interpolate(color2, 0.5)  # Blend two colors

Opacity

# Set opacity (0 = transparent, 1 = opaque)
circle = Circle(fill_opacity=0.5, stroke_opacity=0.8)

# Modify opacity
circle.set_opacity(0.5)         # Both fill and stroke
circle.set_fill_opacity(0.7)    # Fill only
circle.set_stroke_opacity(0.3)  # Stroke only

Color by Value

Color mobjects based on a value (useful for data visualization):

class ColorByValue(Scene):
    def construct(self):
        dots = VGroup(*[Dot() for _ in range(10)]).arrange(RIGHT)

        for i, dot in enumerate(dots):
            # Color from blue (cold) to red (hot)
            dot.set_color(interpolate_color(BLUE, RED, i / 9))

        self.add(dots)

Random Colors

from manim import random_color, random_bright_color

circle = Circle(color=random_color())
square = Square(color=random_bright_color())

Color Lists for Animations

class ColorCycle(Scene):
    def construct(self):
        circle = Circle()
        self.add(circle)

        colors = [RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE]
        for color in colors:
            self.play(circle.animate.set_color(color), run_time=0.5)

Best Practices

  1. Use color variants for depth - BLUE_E for shadows, BLUE_A for highlights
  2. Maintain color consistency - Use the same colors for related concepts
  3. Use opacity for layering - Semi-transparent fills show overlapping
  4. Consider colorblind accessibility - Avoid red-green only distinctions
  5. Use gradients sparingly - They can be distracting

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.