or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

3d-objects.mdadvanced-animations.mdanimation-system.mdboolean-operations.mdcoordinate-systems.mdindex.mdinteractive-controls.mdmathematical-objects.mdmatrix-visualization.mdprobability-stats.mdscene-framework.mdtext-and-latex.mdutilities-and-constants.mdvalue-tracking.mdvector-fields.md

animation-system.mddocs/

0

# Animation System

1

2

ManimGL's animation system provides over 80 animation classes for transforming mathematical objects over time. The system includes base animation functionality, transform animations, creation effects, movement, indication, and specialized mathematical animations with precise timing control.

3

4

## Capabilities

5

6

### Base Animation Classes

7

8

Foundation classes that provide core animation functionality and composition.

9

10

```python { .api }

11

class Animation:

12

def __init__(self, mobject, **kwargs):

13

"""

14

Base class for all animations.

15

16

Parameters:

17

- mobject: Mobject to animate

18

- run_time: float, animation duration in seconds (default: 1.0)

19

- rate_func: function, timing function (default: smooth)

20

- reverse_rate_function: bool, reverse timing function

21

"""

22

23

def interpolate(self, alpha):

24

"""

25

Interpolate animation at given progress.

26

27

Parameters:

28

- alpha: float, animation progress (0-1)

29

30

Returns:

31

None

32

"""

33

34

class AnimationGroup(Animation):

35

def __init__(self, *animations, **kwargs):

36

"""

37

Group multiple animations to play simultaneously.

38

39

Parameters:

40

- animations: Animation instances to group

41

- lag_ratio: float, stagger start times (0=simultaneous, 1=sequential)

42

"""

43

44

class Succession(AnimationGroup):

45

def __init__(self, *animations, **kwargs):

46

"""

47

Play animations sequentially one after another.

48

49

Parameters:

50

- animations: Animation instances to play in sequence

51

"""

52

53

class LaggedStart(AnimationGroup):

54

def __init__(self, animation_or_mobjects, **kwargs):

55

"""

56

Start animations with staggered timing.

57

58

Parameters:

59

- animation_or_mobjects: Animation or mobjects to stagger

60

- lag_ratio: float, delay between starts (default: 0.05)

61

"""

62

63

class LaggedStartMap(LaggedStart):

64

def __init__(self, animation_class, mobjects, **kwargs):

65

"""

66

Apply lagged start to multiple objects with same animation.

67

68

Parameters:

69

- animation_class: Animation class to apply

70

- mobjects: List of mobjects to animate

71

"""

72

```

73

74

### Transform Animations

75

76

Animations that change objects from one state to another, including morphing, scaling, and property changes.

77

78

```python { .api }

79

class Transform(Animation):

80

def __init__(self, mobject, target_mobject, **kwargs):

81

"""

82

Morph one mobject into another.

83

84

Parameters:

85

- mobject: Source mobject

86

- target_mobject: Target mobject to transform into

87

- path_arc: float, arc path for transformation

88

- replace_mobject_with_target_in_scene: bool, replace after transform

89

"""

90

91

class ReplacementTransform(Transform):

92

def __init__(self, mobject, target_mobject, **kwargs):

93

"""

94

Replace one object with another during transformation.

95

96

Parameters:

97

- mobject: Object to be replaced

98

- target_mobject: Replacement object

99

"""

100

101

class TransformFromCopy(Transform):

102

def __init__(self, mobject, target_mobject, **kwargs):

103

"""

104

Transform from a copy, leaving original unchanged.

105

106

Parameters:

107

- mobject: Original mobject (unchanged)

108

- target_mobject: Target of transformation

109

"""

110

111

class ClockwiseTransform(Transform):

112

def __init__(self, mobject, target_mobject, **kwargs):

113

"""Transform with clockwise rotation."""

114

115

class CounterclockwiseTransform(Transform):

116

def __init__(self, mobject, target_mobject, **kwargs):

117

"""Transform with counterclockwise rotation."""

118

119

class MoveToTarget(Animation):

120

def __init__(self, mobject, **kwargs):

121

"""

122

Move object to its target state (set via .generate_target()).

123

124

Parameters:

125

- mobject: Mobject with target state set

126

"""

127

128

class ApplyMethod(Transform):

129

def __init__(self, method, *args, **kwargs):

130

"""

131

Apply a method as an animation.

132

133

Parameters:

134

- method: Bound method to apply

135

- args: Method arguments

136

"""

137

138

class ApplyFunction(Transform):

139

def __init__(self, function, mobject, **kwargs):

140

"""

141

Apply a function transformation as animation.

142

143

Parameters:

144

- function: Function to apply to mobject

145

- mobject: Target mobject

146

"""

147

148

class FadeToColor(Animation):

149

def __init__(self, mobject, color, **kwargs):

150

"""

151

Animate color change.

152

153

Parameters:

154

- mobject: Object to recolor

155

- color: Target color

156

"""

157

158

class ScaleInPlace(Animation):

159

def __init__(self, mobject, scale_factor, **kwargs):

160

"""

161

Scale object around its center.

162

163

Parameters:

164

- mobject: Object to scale

165

- scale_factor: Scaling factor

166

"""

167

168

class ShrinkToCenter(ScaleInPlace):

169

def __init__(self, mobject, **kwargs):

170

"""Shrink object to its center point."""

171

172

class Restore(Animation):

173

def __init__(self, mobject, **kwargs):

174

"""

175

Restore object to previously saved state.

176

177

Parameters:

178

- mobject: Object to restore (must have saved state)

179

"""

180

181

class ApplyMatrix(Animation):

182

def __init__(self, matrix, mobject, **kwargs):

183

"""

184

Apply matrix transformation.

185

186

Parameters:

187

- matrix: 3x3 transformation matrix

188

- mobject: Object to transform

189

"""

190

```

191

192

### Creation and Destruction Animations

193

194

Animations for revealing and removing objects with various visual effects.

195

196

```python { .api }

197

class ShowCreation(Animation):

198

def __init__(self, vmobject, **kwargs):

199

"""

200

Progressively reveal a vectorized mobject.

201

202

Parameters:

203

- vmobject: VMobject to reveal

204

- lag_ratio: float, stagger submobject reveals

205

"""

206

207

class Uncreate(ShowCreation):

208

def __init__(self, vmobject, **kwargs):

209

"""Reverse of ShowCreation - progressively hide object."""

210

211

class DrawBorderThenFill(Animation):

212

def __init__(self, vmobject, **kwargs):

213

"""

214

First draw border, then fill interior.

215

216

Parameters:

217

- vmobject: VMobject to draw and fill

218

- stroke_width: float, border thickness during drawing

219

- stroke_color: Border color during drawing

220

"""

221

222

class Write(DrawBorderThenFill):

223

def __init__(self, vmobject, **kwargs):

224

"""

225

Writing animation optimized for text.

226

227

Parameters:

228

- vmobject: Text or TeX object to write

229

- lag_ratio: float, stagger character/word reveals

230

"""

231

232

class ShowIncreasingSubsets(Animation):

233

def __init__(self, group, **kwargs):

234

"""

235

Reveal submobjects progressively.

236

237

Parameters:

238

- group: Group or VGroup with submobjects

239

- int_func: function, controls subset progression

240

"""

241

242

class ShowSubmobjectsOneByOne(ShowIncreasingSubsets):

243

def __init__(self, group, **kwargs):

244

"""Show submobjects one by one sequentially."""

245

246

class AddTextWordByWord(Succession):

247

def __init__(self, text_mobject, **kwargs):

248

"""

249

Add text word by word.

250

251

Parameters:

252

- text_mobject: Text mobject to reveal word by word

253

- run_time: float, total time for all words

254

"""

255

```

256

257

### Fade Animations

258

259

Animations for gradually appearing and disappearing objects with various fade effects.

260

261

```python { .api }

262

class FadeIn(Animation):

263

def __init__(self, mobject, **kwargs):

264

"""

265

Fade object into view.

266

267

Parameters:

268

- mobject: Object to fade in

269

- shift: np.array, movement during fade

270

- scale: float, scaling during fade

271

"""

272

273

class FadeOut(Animation):

274

def __init__(self, mobject, **kwargs):

275

"""

276

Fade object out of view.

277

278

Parameters:

279

- mobject: Object to fade out

280

- shift: np.array, movement during fade

281

- scale: float, scaling during fade

282

"""

283

284

class FadeInFromPoint(FadeIn):

285

def __init__(self, mobject, point, **kwargs):

286

"""

287

Fade in from specific point.

288

289

Parameters:

290

- mobject: Object to fade in

291

- point: np.array, starting point

292

"""

293

294

class FadeOutToPoint(FadeOut):

295

def __init__(self, mobject, point, **kwargs):

296

"""

297

Fade out to specific point.

298

299

Parameters:

300

- mobject: Object to fade out

301

- point: np.array, ending point

302

"""

303

304

class FadeInFromLarge(FadeIn):

305

def __init__(self, mobject, scale_factor=2, **kwargs):

306

"""Fade in while shrinking from large size."""

307

308

class FadeOutToSmall(FadeOut):

309

def __init__(self, mobject, scale_factor=0, **kwargs):

310

"""Fade out while shrinking to small size."""

311

312

class VFadeIn(Animation):

313

def __init__(self, vmobject, **kwargs):

314

"""

315

Vectorized fade in for VMobjects.

316

317

Parameters:

318

- vmobject: VMobject to fade in

319

"""

320

321

class VFadeOut(Animation):

322

def __init__(self, vmobject, **kwargs):

323

"""

324

Vectorized fade out for VMobjects.

325

326

Parameters:

327

- vmobject: VMobject to fade out

328

"""

329

```

330

331

### Movement Animations

332

333

Animations for moving objects along paths and through space.

334

335

```python { .api }

336

class Homotopy(Animation):

337

def __init__(self, homotopy_function, mobject, **kwargs):

338

"""

339

Continuous deformation animation.

340

341

Parameters:

342

- homotopy_function: function(x, y, z, t) -> (x', y', z')

343

- mobject: Object to deform

344

"""

345

346

class PhaseFlow(Animation):

347

def __init__(self, function, mobject, **kwargs):

348

"""

349

Vector field flow animation.

350

351

Parameters:

352

- function: Vector field function

353

- mobject: Object to move through field

354

"""

355

356

class MoveAlongPath(Animation):

357

def __init__(self, mobject, path, **kwargs):

358

"""

359

Move object along specified path.

360

361

Parameters:

362

- mobject: Object to move

363

- path: VMobject path to follow

364

- rotate: bool, rotate object to follow path tangent

365

"""

366

367

class Rotating(Animation):

368

def __init__(self, mobject, **kwargs):

369

"""

370

Continuous rotation animation.

371

372

Parameters:

373

- mobject: Object to rotate

374

- axis: np.array, rotation axis

375

- radians: float, total rotation angle

376

- about_point: np.array, rotation center

377

"""

378

379

class Rotate(Animation):

380

def __init__(self, mobject, angle, **kwargs):

381

"""

382

Single rotation animation.

383

384

Parameters:

385

- mobject: Object to rotate

386

- angle: float, rotation angle in radians

387

- axis: np.array, rotation axis

388

- about_point: np.array, rotation center

389

"""

390

```

391

392

### Indication Animations

393

394

Animations for highlighting and drawing attention to objects.

395

396

```python { .api }

397

class FocusOn(Transform):

398

def __init__(self, focus_point, **kwargs):

399

"""

400

Focus attention on specific point.

401

402

Parameters:

403

- focus_point: np.array or Mobject, point to focus on

404

- opacity: float, focus indicator opacity

405

- color: Focus indicator color

406

"""

407

408

class Indicate(Transform):

409

def __init__(self, mobject, **kwargs):

410

"""

411

Indicate object with emphasis effect.

412

413

Parameters:

414

- mobject: Object to indicate

415

- scale_factor: float, emphasis scaling

416

- color: Indication color

417

"""

418

419

class Flash(AnimationGroup):

420

def __init__(self, point, **kwargs):

421

"""

422

Flash effect at specified point.

423

424

Parameters:

425

- point: np.array, flash location

426

- color: Flash color

427

- flash_radius: float, flash size

428

- num_lines: int, number of flash lines

429

"""

430

431

class CircleIndicate(Indicate):

432

def __init__(self, mobject, **kwargs):

433

"""

434

Circle indication around object.

435

436

Parameters:

437

- mobject: Object to circle

438

- circle_color: Circle color

439

"""

440

441

class ShowPassingFlash(ShowCreation):

442

def __init__(self, vmobject, **kwargs):

443

"""

444

Passing flash effect along object.

445

446

Parameters:

447

- vmobject: Path for flash to follow

448

- time_width: float, flash duration

449

"""

450

451

class ShowCreationThenDestruction(Succession):

452

def __init__(self, vmobject, **kwargs):

453

"""Show creation followed immediately by destruction."""

454

455

class ShowCreationThenFadeOut(Succession):

456

def __init__(self, vmobject, **kwargs):

457

"""Show creation followed by fade out."""

458

459

class AnimationOnSurroundingRectangle(AnimationGroup):

460

def __init__(self, mobject, **kwargs):

461

"""Animate a rectangle surrounding the mobject."""

462

463

class WiggleOutThenIn(Animation):

464

def __init__(self, mobject, **kwargs):

465

"""

466

Wiggle animation effect.

467

468

Parameters:

469

- mobject: Object to wiggle

470

- scale_value: float, wiggle amplitude

471

- rotation_angle: float, wiggle rotation

472

"""

473

474

class TurnInsideOut(Transform):

475

def __init__(self, mobject, **kwargs):

476

"""Turn object inside out transformation."""

477

```

478

479

### Growing Animations

480

481

Animations for objects that grow or shrink with directional effects.

482

483

```python { .api }

484

class GrowFromPoint(Transform):

485

def __init__(self, mobject, point, **kwargs):

486

"""

487

Grow object from specific point.

488

489

Parameters:

490

- mobject: Object to grow

491

- point: np.array, growth origin point

492

"""

493

494

class GrowFromCenter(GrowFromPoint):

495

def __init__(self, mobject, **kwargs):

496

"""Grow object from its center."""

497

498

class GrowFromEdge(GrowFromPoint):

499

def __init__(self, mobject, edge, **kwargs):

500

"""

501

Grow object from specified edge.

502

503

Parameters:

504

- mobject: Object to grow

505

- edge: np.array, edge direction (UP, DOWN, LEFT, RIGHT)

506

"""

507

508

class GrowArrow(GrowFromPoint):

509

def __init__(self, arrow, **kwargs):

510

"""

511

Specialized growth for arrows.

512

513

Parameters:

514

- arrow: Arrow object to grow

515

"""

516

517

class SpinInFromNothing(GrowFromCenter):

518

def __init__(self, mobject, **kwargs):

519

"""Grow with spinning effect."""

520

```

521

522

### Update Animations

523

524

Animations that continuously update objects based on functions or other objects.

525

526

```python { .api }

527

class UpdateFromFunc(Animation):

528

def __init__(self, mobject, update_function, **kwargs):

529

"""

530

Update object using custom function.

531

532

Parameters:

533

- mobject: Object to update

534

- update_function: function(mobject, dt) -> None

535

- suspend_mobject_updating: bool, suspend other updates

536

"""

537

538

class UpdateFromAlphaFunc(UpdateFromFunc):

539

def __init__(self, mobject, update_function, **kwargs):

540

"""

541

Update object using alpha-based function.

542

543

Parameters:

544

- mobject: Object to update

545

- update_function: function(mobject, alpha) -> None

546

"""

547

548

class MaintainPositionRelativeTo(Animation):

549

def __init__(self, mobject, tracked_mobject, **kwargs):

550

"""

551

Maintain relative position to another object.

552

553

Parameters:

554

- mobject: Object to maintain position

555

- tracked_mobject: Object to track

556

"""

557

558

class CyclicReplace(Transform):

559

def __init__(self, *mobjects, **kwargs):

560

"""

561

Cyclically replace objects in sequence.

562

563

Parameters:

564

- mobjects: Objects to cycle through

565

"""

566

```

567

568

## Usage Examples

569

570

### Basic Animation

571

572

```python

573

from manimgl import *

574

575

class BasicAnimation(Scene):

576

def construct(self):

577

circle = Circle(color=BLUE)

578

square = Square(color=RED)

579

580

# Transform circle into square

581

self.play(ShowCreation(circle))

582

self.play(Transform(circle, square))

583

self.wait()

584

```

585

586

### Animation Composition

587

588

```python

589

class CompositionExample(Scene):

590

def construct(self):

591

objects = [Circle(), Square(), Triangle()]

592

593

# Stagger creation

594

self.play(LaggedStartMap(ShowCreation, objects, lag_ratio=0.3))

595

596

# Simultaneous animations

597

self.play(AnimationGroup(

598

FadeOut(objects[0]),

599

Rotate(objects[1], PI/4),

600

objects[2].animate.shift(UP)

601

))

602

self.wait()

603

```

604

605

### Custom Update Animation

606

607

```python

608

class UpdateExample(Scene):

609

def construct(self):

610

dot = Dot()

611

612

def update_dot(mobject, dt):

613

mobject.shift(RIGHT * dt)

614

615

self.add(dot)

616

self.play(UpdateFromFunc(dot, update_dot), run_time=3)

617

self.wait()

618

```