animation#

Utility functions for animations.

Functions

check_step(easing_function)

Decorator to check if the step is a float or int and if it is between 0 and 1.

ease_in_out_quadratic(step)

An ease-in and ease-out quadratic function to generate animation steps (slow to fast to slow).

ease_in_out_sine(step)

An ease-in and ease-out sinusoidal function to generate animation steps (slow to fast to slow).

ease_in_sine(step)

An ease-in sinusoidal function to generate animation steps (slow to fast).

ease_out_sine(step)

An ease-out sinusoidal function to generate animation steps (fast to slow).

linear(step)

A linear function to generate animation steps.

stitch_gif_animation(output_dir, ...[, ...])

Stitch frames together into a GIF animation.

data_morph.plotting.animation.check_step(easing_function: Callable[[int | float], int | float]) Callable[[int | float], int | float][source]#

Decorator to check if the step is a float or int and if it is between 0 and 1.

Parameters:

easing_function (Callable) – The easing function to be checked.

Returns:

The easing function with the check for the step.

Return type:

Callable

data_morph.plotting.animation.ease_in_out_quadratic(step: int | float) int | float[source]#

An ease-in and ease-out quadratic function to generate animation steps (slow to fast to slow).

Parameters:

step (int or float) – The current step of the animation, from 0 to 1.

Returns:

The eased value at the current step, from 0.0 to 1.0.

Return type:

int or float

data_morph.plotting.animation.ease_in_out_sine(step: int | float) float[source]#

An ease-in and ease-out sinusoidal function to generate animation steps (slow to fast to slow).

Parameters:

step (int or float) – The current step of the animation, from 0 to 1.

Returns:

The eased value at the current step, from 0.0 to 1.0.

Return type:

float

data_morph.plotting.animation.ease_in_sine(step: int | float) float[source]#

An ease-in sinusoidal function to generate animation steps (slow to fast).

Parameters:

step (int or float) – The current step of the animation, from 0 to 1.

Returns:

The eased value at the current step, from 0.0 to 1.0.

Return type:

float

data_morph.plotting.animation.ease_out_sine(step: int | float) float[source]#

An ease-out sinusoidal function to generate animation steps (fast to slow).

Parameters:

step (int or float) – The current step of the animation, from 0 to 1.

Returns:

The eased value at the current step, from 0.0 to 1.0.

Return type:

float

data_morph.plotting.animation.linear(step: int | float) int | float[source]#

A linear function to generate animation steps.

Parameters:

step (int or float) – The current step of the animation, from 0 to 1.

Returns:

The eased value at the current step, from 0.0 to 1.0.

Return type:

int or float

data_morph.plotting.animation.stitch_gif_animation(output_dir: str | Path, start_shape: str, target_shape: str | Shape, keep_frames: bool = False, forward_only_animation: bool = False) None[source]#

Stitch frames together into a GIF animation.

Parameters:
  • output_dir (str or pathlib.Path) – The output directory to save the animation to. Note that the frames to stitch together must be in here as well.

  • start_shape (str) – The starting shape.

  • target_shape (str or Shape) – The target shape for the morphing.

  • keep_frames (bool, default False) – Whether to keep the individual frames after creating the animation.

  • forward_only_animation (bool, default False) – Whether to only play the animation in the forward direction rather than animating in both forward and reverse.

See also

PIL.Image

Frames are stitched together with Pillow.