Skip to contents

Base class for all animations. An Animation takes a mobject through a continuous transformation parameterised by alpha in 0, 1.

Subclasses override interpolate_mobject(alpha) to define the motion. The lifecycle is: begin() -> repeated interpolate(alpha) -> finish().

Public fields

mobject

The mobject being animated

run_time

Duration in seconds

rate_func

Easing function name or function

name

Human-readable name

remover

Whether to remove the mobject after animation

suspend_mobject_updating

Pause updaters during animation

starting_mobject

Snapshot of mobject at begin()

is_introduced

Whether this animation introduces the mobject

Methods


Method new()

Create a new Animation

Usage

Animation$new(
  mobject = NULL,
  run_time = 1,
  rate_func = "smooth",
  name = NULL,
  remover = FALSE,
  suspend_mobject_updating = TRUE,
  ...
)

Arguments

mobject

The mobject to animate

run_time

Duration in seconds

rate_func

Easing function (name or function)

name

Optional name

remover

Remove mobject when done

suspend_mobject_updating

Pause updaters

...

Additional parameters stored in private$params


Method begin()

Called before the animation starts. Saves a copy of the starting mobject state.

Usage

Animation$begin()


Method finish()

Called after the animation ends. Ensures the mobject is in its final state.

Usage

Animation$finish()


Method interpolate()

Apply easing and delegate to interpolate_mobject.

Usage

Animation$interpolate(alpha)

Arguments

alpha

Raw progress in 0, 1


Method interpolate_mobject()

Override in subclasses to define the actual transformation.

Usage

Animation$interpolate_mobject(alpha)

Arguments

alpha

Eased progress in 0, 1


Method get_all_mobjects()

Get all mobjects involved in this animation

Usage

Animation$get_all_mobjects()

Returns

List of mobjects


Method copy()

Create a copy of this animation

Usage

Animation$copy()


Method is_introducer()

Check if this animation is an introducer (adds mobject to scene)

Usage

Animation$is_introducer()


Method is_remover()

Check if this animation is a remover (removes mobject from scene)

Usage

Animation$is_remover()


Method to_anim_spec()

Convert to a timeline-compatible animation spec (legacy bridge)

Usage

Animation$to_anim_spec(start_time = 0)

Arguments

start_time

Start time in the scene timeline

Returns

A list compatible with the existing rendering pipeline


Method print()

Print animation summary

Usage

Animation$print()


Method clone()

The objects of this class are cloneable with this method.

Usage

Animation$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.