※この翻訳ドキュメントはスクリプトによって出力・同期されています。内容が怪しそうな場合はGitHubにissueを追加したり英語の原文の確認をお願いします。
animation_rotation_around_center インターフェイス¶
このページではanimation_rotation_around_centerメソッドのインターフェイスについて説明します。
インターフェイス概要¶
animation_rotation_around_centerメソッドのインターフェイスはap.AnimationRotationAroundCenterクラスのインスタンスを生成します。そのインスタンスを使用して対象のインスタンスの中央座標で回転のアニメーションを設定することができます。
このインターフェイスはRectangleやCircleクラスなどのGraphicsBaseのサブクラスで存在します。
基本的な使い方¶
以下の例では0度から90度の回転のアニメーションをanimation_rotation_around_centerメソッドを使って設定しています。
import apysc as ap
DURATION: int = 1000
def on_animation_complete_1(e: ap.AnimationEvent[ap.Rectangle], options: dict) -> None:
    """
    The handler that the animation calls when its end.
    Parameters
    ----------
    e : AnimationEvent
        Event instance.
    options : dict
        Optional arguments dictionary.
    """
    rectangle: ap.Rectangle = e.this.target
    rectangle.animation_rotation_around_center(
        rotation_around_center=0,
        duration=1000,
        easing=ap.Easing.EASE_OUT_QUINT,
    ).animation_complete(on_animation_complete_2).start()
def on_animation_complete_2(e: ap.AnimationEvent[ap.Rectangle], options: dict) -> None:
    """
    The handler that the animation calls when its end.
    Parameters
    ----------
    e : AnimationEvent
        Event instance.
    options : dict
        Optional arguments dictionary.
    """
    rectangle: ap.Rectangle = e.this.target
    rectangle.animation_rotation_around_center(
        rotation_around_center=90,
        duration=1000,
        easing=ap.Easing.EASE_OUT_QUINT,
    ).animation_complete(on_animation_complete_1).start()
ap.Stage(
    stage_width=150,
    stage_height=150,
    background_color=ap.Color("#333"),
    stage_elem_id="stage",
)
sprite: ap.Sprite = ap.Sprite()
sprite.graphics.begin_fill(color=ap.Color("#0af"))
rectangle: ap.Rectangle = sprite.graphics.draw_rect(x=50, y=50, width=50, height=50)
rectangle.animation_rotation_around_center(
    rotation_around_center=90,
    duration=1000,
    easing=ap.Easing.EASE_OUT_QUINT,
).animation_complete(on_animation_complete_1).start()
ap.save_overall_html(dest_dir_path="./animation_rotation_around_center_basic_usage/")
animation_rotation_around_center API¶
特記事項: このAPIドキュメントはドキュメントビルド用のスクリプトによって自動で生成・同期されています。そのためもしかしたらこの節の内容は前節までの内容と重複している場合があります。
[インターフェイスの構造] animation_rotation_around_center(self, *, rotation_around_center: 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_rotation_around_center.AnimationRotationAroundCenter
[インターフェイス概要]
中央座標を使用した回転のアニメーションの設定を行います。
[引数]
rotation_around_center: Int or int回転のアニメーションの回転量の最終値。
duration: Int or int, default 3000アニメーション完了までのミリ秒。
delay: Int or int, default 0アニメーション開始までの遅延時間のミリ秒。
easing: Easing, default Easing.LINEARイージング設定。
[返却値]
animation_rotation_around_center: AnimationRotationAroundCenter生成されたアニメーションのインスタンス。
[特記事項]
アニメーションを開始するには返却されたインスタンスのstartメソッドを呼び出す必要があります。
[コードサンプル]
>>> import apysc as ap
>>> stage: ap.Stage = ap.Stage()
>>> sprite: ap.Sprite = ap.Sprite()
>>> sprite.graphics.begin_fill(color=ap.Color("#0af"))
>>> rectangle: ap.Rectangle = sprite.graphics.draw_rect(
...     x=50, y=50, width=50, height=50
... )
>>> _ = rectangle.animation_rotation_around_center(
...     rotation_around_center=90,
...     duration=1500,
...     easing=ap.Easing.EASE_OUT_QUINT,
... ).start()
[関連資料]