or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

animations.mdcameras.mdcoordinate-systems.mdindex.mdmobjects.mdrendering.mdscenes.mdutilities.md

index.mddocs/

0

# Manim

1

2

A comprehensive Python library for creating mathematical animations. Manim (Mathematical Animation Engine) provides a powerful API for programmatically generating precise animated videos, particularly for educational mathematics and science content. It supports both 2D and 3D animations with customizable rendering engines.

3

4

## Package Information

5

6

- **Package Name**: manim

7

- **Version**: 0.19.0

8

- **Language**: Python

9

- **Installation**: `pip install manim`

10

- **Requires**: Python ≥ 3.8

11

12

## Core Imports

13

14

```python

15

import manim

16

```

17

18

Common patterns for working with animations:

19

20

```python

21

from manim import *

22

```

23

24

Or selective imports:

25

26

```python

27

from manim import Scene, Circle, Create, Write, Text

28

```

29

30

## Basic Usage

31

32

```python

33

from manim import *

34

35

class MyScene(Scene):

36

def construct(self):

37

# Create a circle and text

38

circle = Circle(radius=2, color=BLUE)

39

text = Text("Hello, Manim!", font_size=48)

40

41

# Position text below circle

42

text.next_to(circle, DOWN, buff=0.5)

43

44

# Animate creation

45

self.play(Create(circle))

46

self.play(Write(text))

47

48

# Transform and rotate

49

self.play(

50

circle.animate.set_color(RED).scale(0.5),

51

text.animate.rotate(PI/4)

52

)

53

self.wait(1)

54

```

55

56

## Architecture

57

58

Manim follows a hierarchical architecture designed for mathematical precision and extensibility:

59

60

### Core Components

61

62

- **Scene**: The main canvas and animation orchestrator that manages mobjects, coordinates rendering, and handles the animation timeline

63

- **Mobject**: Mathematical objects (the visual elements) including geometry, text, graphs, and 3D shapes

64

- **Animation**: Transformation classes that define how mobjects change over time, from simple movements to complex mathematical transitions

65

- **Camera**: Viewing system that controls perspective, zoom, and coordinate mappings for both 2D and 3D rendering

66

- **Renderer**: Backend engines (Cairo for 2D, OpenGL for 3D) that convert mathematical descriptions into visual output

67

68

### Design Philosophy

69

70

This architecture enables Manim's core strength: **programmatic precision**. Every visual element is defined mathematically, ensuring reproducible, scalable animations that maintain accuracy across different output formats and resolutions. The separation between mathematical description (mobjects) and temporal behavior (animations) allows for complex transformations while preserving the underlying mathematical relationships.

71

72

## Capabilities

73

74

### Scene Management

75

76

Core scene classes and animation orchestration system for managing the animation lifecycle, mobject placement, and rendering coordination.

77

78

```python { .api }

79

class Scene:

80

def construct(self) -> None: ...

81

def play(*animations, **kwargs) -> None: ...

82

def add(*mobjects) -> None: ...

83

def remove(*mobjects) -> None: ...

84

def wait(duration: float = 1.0) -> None: ...

85

86

class MovingCameraScene(Scene):

87

def setup(self) -> None: ...

88

89

class ThreeDScene(Scene):

90

def set_camera_orientation(phi: float, theta: float) -> None: ...

91

```

92

93

[Scenes](./scenes.md)

94

95

### Animation System

96

97

Comprehensive animation framework including creation, transformation, indication, and composition animations with precise timing control and mathematical interpolation.

98

99

```python { .api }

100

class Animation:

101

def __init__(mobject: Mobject, run_time: float = 1.0, rate_func: Callable = smooth) -> None: ...

102

103

# Creation animations

104

def Create(mobject: Mobject, **kwargs) -> Animation: ...

105

def Write(mobject: Mobject, **kwargs) -> Animation: ...

106

def DrawBorderThenFill(mobject: VMobject, **kwargs) -> Animation: ...

107

108

# Transform animations

109

def Transform(mobject: Mobject, target: Mobject, **kwargs) -> Animation: ...

110

def ReplacementTransform(mobject: Mobject, target: Mobject, **kwargs) -> Animation: ...

111

def FadeTransform(mobject: Mobject, target: Mobject, **kwargs) -> Animation: ...

112

113

# Animation composition

114

def AnimationGroup(*animations, **kwargs) -> Animation: ...

115

def Succession(*animations, **kwargs) -> Animation: ...

116

```

117

118

[Animations](./animations.md)

119

120

### Mathematical Objects

121

122

Extensive library of mathematical objects including 2D geometry, 3D shapes, text rendering, graphs, and coordinate systems with precise mathematical properties.

123

124

```python { .api }

125

# Base classes

126

class Mobject:

127

def shift(vector: np.ndarray) -> Self: ...

128

def rotate(angle: float, axis: np.ndarray = OUT) -> Self: ...

129

def scale(factor: float) -> Self: ...

130

131

class VMobject(Mobject):

132

def set_color(color: str) -> Self: ...

133

def set_stroke(color: str = None, width: float = None) -> Self: ...

134

def set_fill(color: str = None, opacity: float = None) -> Self: ...

135

136

# Geometry

137

def Circle(radius: float = 1.0, **kwargs) -> Circle: ...

138

def Square(side_length: float = 2.0, **kwargs) -> Square: ...

139

def Line(start: np.ndarray = LEFT, end: np.ndarray = RIGHT, **kwargs) -> Line: ...

140

def Arrow(start: np.ndarray = ORIGIN, end: np.ndarray = RIGHT, **kwargs) -> Arrow: ...

141

142

# Text and LaTeX

143

def Text(text: str, font_size: float = 48, **kwargs) -> Text: ...

144

def MathTex(*tex_strings: str, **kwargs) -> MathTex: ...

145

def Tex(*tex_strings: str, **kwargs) -> Tex: ...

146

```

147

148

[Mathematical Objects](./mobjects.md)

149

150

### Coordinate Systems

151

152

Mathematical coordinate systems and graphing utilities including 2D/3D axes, number lines, polar coordinates, and function plotting with automatic scaling and labeling.

153

154

```python { .api }

155

class Axes(CoordinateSystem):

156

def __init__(x_range: Sequence[float] = None, y_range: Sequence[float] = None, **kwargs) -> None: ...

157

def plot(function: Callable, x_range: Sequence[float] = None, **kwargs) -> ParametricFunction: ...

158

def get_graph(function: Callable, x_range: Sequence[float] = None, **kwargs) -> ParametricFunction: ...

159

160

class NumberPlane(Axes):

161

def __init__(x_range: Sequence[float] = None, y_range: Sequence[float] = None, **kwargs) -> None: ...

162

163

class ThreeDAxes(Axes):

164

def __init__(x_range: Sequence[float] = None, y_range: Sequence[float] = None, z_range: Sequence[float] = None, **kwargs) -> None: ...

165

166

class NumberLine(Line):

167

def __init__(x_range: Sequence[float] = [-8, 8, 1], **kwargs) -> None: ...

168

def number_to_point(number: float) -> np.ndarray: ...

169

def point_to_number(point: np.ndarray) -> float: ...

170

```

171

172

[Coordinate Systems](./coordinate-systems.md)

173

174

### Camera System

175

176

Flexible camera system supporting 2D and 3D perspectives, camera movement, zooming, and multi-camera setups for complex visual presentations.

177

178

```python { .api }

179

class Camera:

180

def __init__(pixel_height: int = None, pixel_width: int = None, **kwargs) -> None: ...

181

def capture_mobjects(mobjects: list[Mobject]) -> None: ...

182

183

class MovingCamera(Camera):

184

def __init__(frame: Mobject = None, **kwargs) -> None: ...

185

186

class ThreeDCamera(Camera):

187

def set_euler_angles(phi: float = None, theta: float = None, gamma: float = None) -> None: ...

188

def add_fixed_orientation_mobjects(*mobjects: Mobject) -> None: ...

189

```

190

191

[Cameras](./cameras.md)

192

193

### Rendering System

194

195

Backend rendering engines and output management supporting multiple formats, quality settings, and both real-time preview and high-quality export.

196

197

```python { .api }

198

class CairoRenderer:

199

def __init__(camera: Camera, skip_animations: bool = False, **kwargs) -> None: ...

200

201

class OpenGLRenderer:

202

def __init__(camera: Camera, **kwargs) -> None: ...

203

204

# Configuration

205

from manim import config

206

config.pixel_height = 1080

207

config.pixel_width = 1920

208

config.frame_rate = 60

209

config.output_file = "my_animation.mp4"

210

```

211

212

[Rendering](./rendering.md)

213

214

### Utilities

215

216

Essential utility functions including mathematical operations, color management, rate functions, file operations, and debugging tools for animation development.

217

218

```python { .api }

219

# Constants and directions

220

ORIGIN: np.ndarray

221

UP: np.ndarray

222

DOWN: np.ndarray

223

LEFT: np.ndarray

224

RIGHT: np.ndarray

225

PI: float

226

TAU: float

227

228

# Rate functions

229

def linear(t: float) -> float: ...

230

def smooth(t: float) -> float: ...

231

def ease_in_out_cubic(t: float) -> float: ...

232

def there_and_back(t: float) -> float: ...

233

234

# Color utilities

235

RED: str

236

BLUE: str

237

GREEN: str

238

def interpolate_color(color1: str, color2: str, alpha: float) -> str: ...

239

240

# Space operations

241

def normalize(vector: np.ndarray) -> np.ndarray: ...

242

def angle_of_vector(vector: np.ndarray) -> float: ...

243

def rotate_vector(vector: np.ndarray, angle: float, axis: np.ndarray = OUT) -> np.ndarray: ...

244

```

245

246

[Utilities](./utilities.md)