Animations

class manimlib.animation.animation.Animation(mobject, **kwargs)
Parameters

Mobject (Mobject) -- TODO

CONFIG parameters

"run_time": DEFAULT_ANIMATION_RUN_TIME, # 2 seconds
"rate_func": smooth,  # See Rate functions below
"submobject_mode": "all_at_once",
"lag_factor": 2,

Rate functions

See

manimlib/utils/rate_functions.py
def linear(t):
    return t

def smooth(t, inflection=10.0):
    error = sigmoid(-inflection / 2)
    return np.clip(
        (sigmoid(inflection * (t - 0.5)) - error) / (1 - 2 * error),
        0, 1,
    )

def rush_into(t, inflection=10.0):
    return 2 * smooth(t / 2.0, inflection)

def rush_from(t, inflection=10.0):
    return 2 * smooth(t / 2.0 + 0.5, inflection) - 1

def slow_into(t):
    return np.sqrt(1 - (1 - t) * (1 - t))

def double_smooth(t):
    if t < 0.5:
        return 0.5 * smooth(2 * t)
    else:
        return 0.5 * (1 + smooth(2 * t - 1))

def there_and_back(t, inflection=10.0):
    new_t = 2 * t if t < 0.5 else 2 * (1 - t)
    return smooth(new_t, inflection)

def there_and_back_with_pause(t, pause_ratio=1. / 3):
    a = 1. / pause_ratio
    if t < 0.5 - pause_ratio / 2:
        return smooth(a * t)
    elif t < 0.5 + pause_ratio / 2:
        return 1
    else:
        return smooth(a - a * t)

def running_start(t, pull_factor=-0.5):
    return bezier([0, 0, pull_factor, pull_factor, 1, 1, 1])(t)

def not_quite_there(func=smooth, proportion=0.7):
    def result(t):
        return proportion * func(t)
    return result

def wiggle(t, wiggles=2):
    return there_and_back(t) * np.sin(wiggles * np.pi * t)

def squish_rate_func(func, a=0.4, b=0.6):
    def result(t):
        if a == b:
            return a

        if t < a:
            return func(0)
        elif t > b:
            return func(1)
        else:
            return func((t - a) / (b - a))

    return result

def lingering(t):
    return squish_rate_func(lambda t: t, 0, 0.8)(t)


def exponential_decay(t, half_life=0.1):
    # The half-life should be rather small to minimize
    # the cut-off error at the end
    return 1 - np.exp(-t / half_life)

Submobject modes

"lagged_start"
"smoothed_lagged_start"
"one_at_a_time"
"all_at_once"

See get_sub_alpha from:

manimlib/animation/animation.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    def get_sub_alpha(self, alpha, index, num_submobjects):
        if self.submobject_mode in ["lagged_start", "smoothed_lagged_start"]:
            prop = float(index) / num_submobjects
            if self.submobject_mode is "smoothed_lagged_start":
                prop = smooth(prop)
            lf = self.lag_factor
            return np.clip(lf * alpha - (lf - 1) * prop, 0, 1)
        elif self.submobject_mode == "one_at_a_time":
            lower = float(index) / num_submobjects
            upper = float(index + 1) / num_submobjects
            return np.clip((alpha - lower) / (upper - lower), 0, 1)
        elif self.submobject_mode == "all_at_once":
            return alpha
        raise Exception("Invalid submobject mode")

Tree

.
├── AnimationGroup
│   ├── AnimationOnSurroundingRectangle
│   │   ├── ShowCreationThenDestructionAround
│   │   ├── ShowCreationThenFadeAround
│   │   └── ShowPassingFlashAround
│   └── Flash
├── ApplyToCenters
├── ChangingDecimal
│   └── ChangeDecimalToValue
├── DrawBorderThenFill
│   └── Write
├── EmptyAnimation
├── Homotopy
│   ├── ApplyWave
│   ├── ComplexHomotopy
│   └── SmoothedVectorizedHomotopy
├── LaggedStart
├── MaintainPositionRelativeTo
├── MoveAlongPath
├── PhaseFlow
├── Rotating
├── ShowIncreasingSubsets
├── ShowPartial
│   ├── ShowCreation
│   │   └── Uncreate
│   └── ShowPassingFlash
│       └── ShowCreationThenDestruction
├── Succession
│   └── ShowCreationThenFadeOut
├── Transform
│   ├── FadeIn
│   ├── FadeInAndShiftFromDirection
│   │   └── FadeInFromDown
│   ├── FadeInFromLarge
│   ├── FadeOut
│   │   └── FadeOutAndShift
│   │       └── FadeOutAndShiftDown
│   ├── FocusOn
│   ├── GrowFromPoint
│   │   ├── GrowArrow
│   │   ├── GrowFromCenter
│   │   │   └── SpinInFromNothing
│   │   └── GrowFromEdge
│   ├── Indicate
│   │   └── CircleIndicate
│   ├── Rotate
│   ├── ShrinkToCenter
│   └── TurnInsideOut
├── UpdateFromAlphaFunc
├── UpdateFromFunc
├── VFadeIn
├── Vibrate
└── WiggleOutThenIn