跳转至

maliang.animation.animations

字数 834 个   代码 132 行   阅读时间 4 分钟   访问量

源代码: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

class public | object

def __init__(
    self,
    duration: int,
    command: collections.abc.Callable[[float], typing.Any],
    *,
    controller: collections.abc.Callable[[float], float] = linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
    derivation: bool = False,
) -> None: ...
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

🟡_repeat

method protected

1
2
3
def _repeat(
    self,
) -> None: ...
Processing of the number of repetitions.

🟡skip

method public

1
2
3
4
def skip(
    self,
    count: int = 1,
) -> None: ...
Skip some loops.

  • count: count of skipping

🟡start

method public

1
2
3
4
5
def start(
    self,
    *,
    delay: int = 0,
) -> str | None: ...
Start the animation.

  • delay: length of the delay before the animation starts

🟡stop

method public

1
2
3
4
5
def stop(
    self,
    *,
    delay: int = 0,
) -> str | None: ...
Stop the animation.

  • delay: length of the delay before the animation stops

🟢GradientItem

class public | Animation

def __init__(
    self,
    canvas: tkinter.Canvas | containers.Canvas,
    item: int,
    parameter: str,
    colors: tuple[str, str],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
    derivation: bool = False,
) -> None: ...
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

🟢GradientTkWidget

class public | Animation

def __init__(
    self,
    widget: tkinter.Widget,
    parameter: str,
    colors: tuple[str, str],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
    derivation: bool = False,
) -> None: ...
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

🟢MoveElement

class public | Animation

def __init__(
    self,
    element: virtual.Element,
    offset: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
) -> None: ...
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

class public | Animation

def __init__(
    self,
    canvas: tkinter.Canvas | containers.Canvas,
    item: int,
    offset: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
) -> None: ...
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

🟢MoveTkWidget

class public | Animation

def __init__(
    self,
    widget: tkinter.Widget,
    offset: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
) -> None: ...
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

class public | Animation

def __init__(
    self,
    widget: virtual.Widget,
    offset: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
) -> None: ...
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

🟢MoveWindow

class public | Animation

def __init__(
    self,
    window: tkinter.Tk | tkinter.Toplevel | containers.Tk | containers.Toplevel,
    offset: tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
) -> None: ...
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

🟢ScaleFontSize

class public | Animation

def __init__(
    self,
    text: virtual.Text,
    sizes: float | tuple[float, float],
    duration: int,
    *,
    controller: collections.abc.Callable[[float], float] = linear,
    end: collections.abc.Callable[[], typing.Any] | None = None,
    fps: int = 30,
    repeat: int = 0,
    repeat_delay: int = 0,
    derivation: bool = False,
) -> None: ...
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