component-designlisted
Install: claude install-skill choxos/MathVizAgent
# Component Design
Patterns for creating reusable, well-structured Manim components.
## VGroup Subclass Pattern
### Basic Structure
```python
class MyComponent(VGroup):
"""Reusable visualization component"""
def __init__(self, param1, param2, **kwargs):
super().__init__(**kwargs)
# Store parameters
self.param1 = param1
self.param2 = param2
# Build component
self._build()
def _build(self):
"""Construct the component's mobjects"""
# Create child mobjects
self.part_a = Circle(radius=self.param1)
self.part_b = Square(side_length=self.param2)
# Position relative to each other
self.part_b.next_to(self.part_a, RIGHT)
# Add to self (VGroup)
self.add(self.part_a, self.part_b)
```
### Usage
```python
# Create instance
component = MyComponent(1.0, 0.5)
# It's a VGroup, so all VGroup methods work
component.scale(0.5)
component.move_to(LEFT * 2)
component.set_color(BLUE)
# Animate
self.play(Create(component))
self.play(component.animate.shift(RIGHT * 3))
```
## Real-World Example: Distribution Plot
```python
from scipy.stats import norm
class DistributionPlot(VGroup):
"""Self-contained probability distribution visualization"""
def __init__(
self,
func, # Distribution function
x_range=(-3, 3), # Domain
color=BLUE,
show_axes=True,
**kwargs
):
super().__init__(**kwar