animation_radius interface

This page explains the animation_radius method interface.

What interface is this?

The animation_radius method interface creates an ap.AnimationRadius instance. You can animate radius with it.

This interface exists on a GraphicsBase subclass, such as the Circle class.

Basic usage

The following example sets the radius animation (from 50 to 100) with the animation_radius method:

import apysc as ap

DURATION: int = 1000


def on_animation_complete_1(e: ap.AnimationEvent[ap.Circle], options: dict) -> None:
    """
    The handler that the animation calls when its end.

    Parameters
    ----------
    e : AnimationEvent
        Event instance.
    options : dict
        Optional arguments dictionary.
    """
    circle: ap.Circle = e.this.target
    circle.animation_radius(
        radius=50,
        duration=DURATION,
        easing=ap.Easing.EASE_OUT_QUINT,
    ).animation_complete(on_animation_complete_2).start()


def on_animation_complete_2(e: ap.AnimationEvent[ap.Circle], options: dict) -> None:
    """
    The handler that the animation calls when its end.

    Parameters
    ----------
    e : AnimationEvent
        Event instance.
    options : dict
        Optional arguments dictionary.
    """
    circle: ap.Circle = e.this.target
    circle.animation_radius(
        radius=100,
        duration=DURATION,
        easing=ap.Easing.EASE_OUT_QUINT,
    ).animation_complete(on_animation_complete_1).start()


ap.Stage(
    stage_width=200,
    stage_height=200,
    background_color=ap.Color("#333"),
    stage_elem_id="stage",
)
sprite: ap.Sprite = ap.Sprite()
sprite.graphics.begin_fill(color=ap.Color("#0af"))
circle: ap.Circle = sprite.graphics.draw_circle(x=100, y=100, radius=50)
circle.animation_radius(
    radius=100,
    duration=DURATION,
    easing=ap.Easing.EASE_OUT_QUINT,
).animation_complete(on_animation_complete_1).start()

ap.save_overall_html(dest_dir_path="./animation_radius_basic_usage/")

animation_radius API

Note: the document build script generates and updates this API document section automatically. Maybe this section is duplicated compared with previous sections.

[Interface signature] animation_radius(self, *, radius: Union[int, apysc._type.int.Int], duration: Union[int, apysc._type.int.Int] = 3000, delay: Union[int, apysc._type.int.Int] = 0, easing: apysc._animation.easing.Easing = <Easing.LINEAR: 'function(x) {return x;}'>) -> apysc._animation.animation_radius.AnimationRadius


[Interface summary]

Set the radius animation setting.


[Parameters]

  • radius: Int or int

    • The final radius of the animation.

  • duration: Int or int, default 3000

    • Milliseconds before an animation ends.

  • delay: Int or int, default 0

    • Milliseconds before an animation starts.

  • easing: Easing, default Easing.LINEAR

    • Easing setting.


[Returns]

  • animation_radius: AnimationRadius

    • Created animation setting instance.


[Notes]

To start this animation, you need to call the start method of the returned instance.


[Examples]

>>> import apysc as ap
>>> stage: ap.Stage = ap.Stage()
>>> sprite: ap.Sprite = ap.Sprite()
>>> sprite.graphics.begin_fill(color=ap.Color("#0af"))
>>> circle: ap.Circle = sprite.graphics.draw_circle(x=100, y=100, radius=50)
>>> _ = circle.animation_radius(
...     radius=100,
...     duration=1500,
...     easing=ap.Easing.EASE_OUT_QUINT,
... ).start()

[References]