Animation delegates for Material Design progress indicators.

Contents

Animation delegates for Material Design progress indicators.#

Animation delegates for Material Design progress indicators.

This module implements the animation algorithms used by the linear and circular indeterminate progress indicators. The implementations are based on the original Android Material Components library and reproduce the behavior of the corresponding Material animations.

The module provides animators for:

  • linear indeterminate (disjoint);

  • linear indeterminate (contiguous);

  • circular indeterminate (retreat);

  • circular indeterminate (advanced).

Each animator calculates the current geometry of the animated indicator from the elapsed animation time and returns normalized values that can be used by the rendering layer.

Ported from the Android Material Components library.

API - kivymd.uix.exprogressindicator.animators#

class kivymd.uix.exprogressindicator.animators.LinearIndeterminateDisjointAnimator#

Animator for the Material Design linear indeterminate progress indicator using the disjoint animation style.

The animation consists of two independent line segments whose head and tail positions are animated with individual cubic Bézier interpolators.

Ported from the Android Material Components implementation (LinearIndeterminateDisjointAnimatorDelegate).

INTERPOLATORS#
DURATION_TO_MOVE_SEGMENT_ENDS = [533, 567, 850, 750]#
DELAY_TO_MOVE_SEGMENT_ENDS = [1267, 1000, 333, 0]#
TOTAL_DURATION_IN_MS = 1800#
LOOP_DELAY = 20#
get_fraction_in_range(playtime, start, duration)#

Returns the normalized animation fraction for the specified time range.

Parameters:
  • playtime – Current animation playtime in milliseconds.

  • start – Start time of the animation interval in milliseconds.

  • duration – Duration of the animation interval in milliseconds.

Returns:

Normalized value in the range [0.0, 1.0].

compute_bar(playtime, head_idx, tail_idx)#

Computes the start and end positions of an animated line segment.

Parameters:
  • playtime – Current animation playtime in milliseconds.

  • head_idx – Interpolator index for the segment head.

  • tail_idx – Interpolator index for the segment tail.

Returns:

Tuple containing the normalized start and end positions of the segment.

bars(time_sec)#

Calculates the current state of the disjoint linear indicator.

Parameters:

time_sec – Current animation time in seconds.

Returns:

Two animated line segments represented as:

(
    (start1, end1),
    (start2, end2),
)

class kivymd.uix.exprogressindicator.animators.LinearIndeterminateContiguousAnimator#

Animator for the Material Design linear indeterminate progress indicator using the contiguous animation style.

The progress indicator is divided into three connected segments that move continuously across the track while cycling through the color palette.

Ported from the Android Material Components implementation (LinearIndeterminateContiguousAnimatorDelegate).

INTERPOLATOR#
TOTAL_DURATION_IN_MS = 667#
DURATION_PER_CYCLE_IN_MS = 333#
last_cycle_count#
current_indices = [0, 0, 0]#
len_palette = 0#
get_fraction_in_range(playtime, start, duration)#

Returns the normalized animation fraction for the specified time range.

Parameters:
  • playtime – Current animation playtime in milliseconds.

  • start – Start time of the animation interval in milliseconds.

  • duration – Duration of the animation interval in milliseconds.

Returns:

Animation progress.

bars(time_sec)#

Calculates the current state of the contiguous linear indicator.

Parameters:

time_sec – Current animation time in seconds.

Returns:

Three contiguous segments represented as:

(
    (start0, end0, color_index0),
    (start1, end1, color_index1),
    (start2, end2, color_index2),
)

class kivymd.uix.exprogressindicator.animators.CircularIndeterminateRetreatAnimator#

Animator for the Material Design circular indeterminate progress indicator using the retreat animation style.

The animation continuously rotates the indicator while expanding and shrinking the visible arc. The active color changes after each rotation cycle.

Ported from the Android Material Components implementation (CircularIndeterminateRetreatAnimatorDelegate).

INTERPOLATOR#
TOTAL_DURATION_MS = 6000#
DURATION_SPIN_MS = 500#
DURATION_GROW_MS = 3000#
DURATION_SHRINK_MS = 3000#
DELAY_SPINS_MS = [0, 1500, 3000, 4500]#
CONSTANT_ROTATION_DEGREES = 1080#
SPIN_ROTATION_DEGREES = 90#
END_FRACTION_RANGE = [0.1, 0.87]#
get_fraction_in_range(playtime, start, duration)#

Returns the normalized animation fraction for the specified time range.

Parameters:
  • playtime – Current animation playtime in milliseconds.

  • start – Start time of the animation interval in milliseconds.

  • duration – Duration of the animation interval in milliseconds.

Returns:

Normalized value in the range [0.0, 1.0].

bars(time_sec)#

Calculates the current state of the retreat circular indicator.

Parameters:

time_sec – Current animation time in seconds.

Returns:

Tuple containing:

(
    rotation_in_radians,
    (
        start_fraction,
        end_fraction,
        color_index,
    ),
)

class kivymd.uix.exprogressindicator.animators.CircularIndeterminateAdvancedAnimator#

Animator for the Material Design circular indeterminate progress indicator using the advanced animation style.

The animation expands and collapses the arc while smoothly rotating around the circle. Color transitions are synchronized with each animation cycle.

Ported from the Android Material Components implementation (CircularIndeterminateAdvanceAnimatorDelegate).

INTERPOLATOR#
TOTAL_DURATION_MS = 5400#
TOTAL_CYCLES = 4#
DURATION_EXPAND = 667#
DURATION_COLLAPSE = 667#
DURATION_FADE_IN = 333#
DELAY_EXPAND = [0, 1350, 2700, 4050]#
DELAY_COLLAPSE = [667, 2017, 3367, 4717]#
DELAY_FADE_IN = [1000, 2350, 3700, 5050]#
TAIL_DEGREES_OFFSET#
EXTRA_DEGREES_PER_CYCLE = 250#
CONSTANT_ROTATION_DEGREES = 1520#
get_fraction_in_range(playtime, start, duration)#

Returns the normalized animation fraction for the specified time range.

Parameters:
  • playtime – Current animation playtime in milliseconds.

  • start – Start time of the animation interval in milliseconds.

  • duration – Duration of the animation interval in milliseconds.

Returns:

Normalized value in the range [0.0, 1.0].

get_color(time_sec, playtime_ms)#

Calculates the current color transition.

Parameters:
  • time_sec – Current animation time in seconds.

  • playtime_ms – Current animation playtime in milliseconds.

Returns:

Tuple containing the start color index, end color index, and interpolation factor.

bars(time_sec)#

Calculates the current state of the advanced circular indicator.

Parameters:

time_sec – Current animation time in seconds.

Returns:

Tuple containing:

(
    rotation,
    (
        start_fraction,
        end_fraction,
        (
            start_color_index,
            end_color_index,
            color_lerp,
        ),
    ),
)

The rotation value is always 0 because the rotation is already encoded into the calculated arc fractions.