跳转至

maliang.animation.animations

字数 9 个   阅读时间不到 1 分钟   访问量

源代码:maliang/animation/animations.py

Base and standard animation classes.

The animation base class can be inherited or called directly. Other standard animation classes are best used by direct calls, rather than inheritance.

类:

  • Animation

    Base animation class.

  • MoveWindow

    Animation of moving the window.

  • MoveTkWidget

    Animation of moving tkinter.Widget.

  • MoveWidget

    Animation of moving virtual.Widget.

  • MoveElement

    Animation of moving virtual.Element.

  • MoveItem

    Animation of moving a item of tkinter.Canvas.

  • GradientTkWidget

    Animation of making the color of tkinter.Widget to be gradient.

  • GradientItem

    Animation of making the color of canvas item to be gradient.

  • ScaleFontSize

    Animation of scaling the font size of virtual.Text.

Animation

Animation(
    duration: int,
    command: collections.abc.Callable[[float], typing.Any],
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
    derivation: bool = False
)

Base animation class.

  • duration: duration of the animation, in milliseconds
  • command: callback function, which will be called once per frame
  • controller: a function that controls the animation process
  • end: end function, which is called once at the end of the animation
  • fps: frame rate of the animation
  • repeat: number of repetitions of the animation
  • repeat_delay: length of the delay before the animation repeats
  • derivation: whether the callback function is derivative

方法:

  • start

    Start the animation.

  • stop

    Stop the animation.

  • skip

    Skip some loops.

属性:

  • active (bool) –

    Returns the active state of the animation.

  • count (int) –

    Returns the number of loops remaining.

active property

active: bool

Returns the active state of the animation.

count property

count: int

Returns the number of loops remaining.

start

start() -> None
start(*, delay: int) -> str
start(*, delay: int = 0) -> str | None

Start the animation.

  • delay: length of the delay before the animation starts

stop

stop() -> None
stop(*, delay: int) -> str
stop(*, delay: int = 0) -> str | None

Stop the animation.

  • delay: length of the delay before the animation stops

skip

skip(count: int = 1) -> None

Skip some loops.

  • count: count of skipping

MoveWindow

MoveWindow(
    window: tkinter.Tk | tkinter.Toplevel | containers.Tk | containers.Toplevel,
    offset: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0
)

Bases: Animation

Animation of moving the window.

  • window: the window to be moved
  • offset: relative offset of the coordinates
  • duration: duration of the animation, in milliseconds
  • controller: a function that controls the animation process
  • end: end function, which is called once at the end of the animation
  • fps: frame rate of the animation
  • repeat: number of repetitions of the animation
  • repeat_delay: length of the delay before the animation repeats

MoveTkWidget

MoveTkWidget(
    widget: tkinter.Widget,
    offset: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0
)

Bases: Animation

Animation of moving tkinter.Widget.

  • widget: the tkinter.Widget to be moved
  • offset: relative offset of the coordinates
  • duration: duration of the animation, in milliseconds
  • controller: a function that controls the animation process
  • end: end function, which is called once at the end of the animation
  • fps: frame rate of the animation
  • repeat: number of repetitions of the animation
  • repeat_delay: length of the delay before the animation repeats

MoveWidget

MoveWidget(
    widget: virtual.Widget,
    offset: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0
)

Bases: Animation

Animation of moving virtual.Widget.

  • widget: the virtual.Widget to be moved
  • offset: relative offset of the coordinates
  • duration: duration of the animation, in milliseconds
  • controller: a function that controls the animation process
  • end: end function, which is called once at the end of the animation
  • fps: frame rate of the animation
  • repeat: number of repetitions of the animation
  • repeat_delay: length of the delay before the animation repeats

MoveElement

MoveElement(
    element: virtual.Element,
    offset: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0
)

Bases: Animation

Animation of moving virtual.Element.

  • element: the virtual.Element to be moved
  • offset: relative offset of the coordinates
  • duration: duration of the animation, in milliseconds
  • controller: a function that controls the animation process
  • end: end function, which is called once at the end of the animation
  • fps: frame rate of the animation
  • repeat: number of repetitions of the animation
  • repeat_delay: length of the delay before the animation repeats

MoveItem

MoveItem(
    canvas: tkinter.Canvas | containers.Canvas,
    item: int,
    offset: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0
)

Bases: Animation

Animation of moving a item of tkinter.Canvas.

  • canvas: an instance of tkinter.Canvas that contains the item
  • item: the item to be moved
  • offset: relative offset of the coordinates
  • duration: duration of the animation, in milliseconds
  • controller: a function that controls the animation process
  • end: end function, which is called once at the end of the animation
  • fps: frame rate of the animation
  • repeat: number of repetitions of the animation
  • repeat_delay: length of the delay before the animation repeats

GradientTkWidget

GradientTkWidget(
    widget: tkinter.Widget,
    parameter: str,
    colors: tuple[str, str],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
    derivation: bool = False
)

Bases: Animation

Animation of making the color of tkinter.Widget to be gradient.

  • widget: the tkinter.Widget whose color is to be gradient
  • parameter: parameter name of widget that is to be modified in color
  • colors: a tuple of the initial and ending colors
  • duration: duration of the animation, in milliseconds
  • controller: a function that controls the animation process
  • end: end function, which is called once at the end of the animation
  • fps: frame rate of the animation
  • repeat: number of repetitions of the animation
  • repeat_delay: length of the delay before the animation repeats
  • derivation: whether the callback function is derivative

GradientItem

GradientItem(
    canvas: tkinter.Canvas | containers.Canvas,
    item: int,
    parameter: str,
    colors: tuple[str, str],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
    derivation: bool = False
)

Bases: Animation

Animation of making the color of canvas item to be gradient.

  • canvas: an instance of tkinter.Canvas that contains the item
  • item: item whose color is to be gradient
  • parameter: parameter name of item that is to be modified in color
  • colors: a tuple of the initial and ending colors
  • duration: duration of the animation, in milliseconds
  • controller: a function that controls the animation process
  • end: end function, which is called once at the end of the animation
  • fps: frame rate of the animation
  • repeat: number of repetitions of the animation
  • repeat_delay: length of the delay before the animation repeats
  • derivation: whether the callback function is derivative

ScaleFontSize

ScaleFontSize(
    text: virtual.Text,
    sizes: float,
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
    derivation: bool = False
)
ScaleFontSize(
    text: virtual.Text,
    sizes: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
    derivation: bool = False
)
ScaleFontSize(
    text: virtual.Text,
    sizes: float | tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = controllers.linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
    derivation: bool = False
)

Bases: Animation

Animation of scaling the font size of virtual.Text.

  • text: an instance of virtual.Text that needs to be scaled
  • sizes: a tuple of the initial and ending sizes or target font size
  • duration: duration of the animation, in milliseconds
  • controller: a function that controls the animation process
  • end: end function, which is called once at the end of the animation
  • fps: frame rate of the animation
  • repeat: number of repetitions of the animation
  • repeat_delay: length of the delay before the animation repeats
  • derivation: whether the callback function is derivative