maliang.animation¶
字数 11 个 阅读时间不到 1 分钟 访问量
源代码:maliang/animation/__init__.py
A subpackage that provides animation-related features.
A highly customizable animation base class and related subclasses are provided, as well as highly customizable control functions. In addition, control functions also applies to the related functions of the color
subpackage.
模块:
-
animations
–Base and standard animation classes.
-
controllers
–Controller generator and standard control functions.
类:
-
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
.
函数:
-
generate
–Generate a control function from an ordinary mathematical function.
-
linear
–Speed remains the same.
-
smooth
–Speed is slow first, then fast and then slow. (slow -> fast -> slow)
-
rebound
–Before the end, displacement will bounce off a bit.
-
ease_in
–Gradually accelerate. (slow -> fast)
-
ease_out
–Gradually decelerate. (fast -> slow)
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 millisecondscommand
: callback function, which will be called once per framecontroller
: a function that controls the animation processend
: end function, which is called once at the end of the animationfps
: frame rate of the animationrepeat
: number of repetitions of the animationrepeat_delay
: length of the delay before the animation repeatsderivation
: whether the callback function is derivative
方法:
属性:
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 movedoffset
: relative offset of the coordinatesduration
: duration of the animation, in millisecondscontroller
: a function that controls the animation processend
: end function, which is called once at the end of the animationfps
: frame rate of the animationrepeat
: number of repetitions of the animationrepeat_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
: thetkinter.Widget
to be movedoffset
: relative offset of the coordinatesduration
: duration of the animation, in millisecondscontroller
: a function that controls the animation processend
: end function, which is called once at the end of the animationfps
: frame rate of the animationrepeat
: number of repetitions of the animationrepeat_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
: thevirtual.Widget
to be movedoffset
: relative offset of the coordinatesduration
: duration of the animation, in millisecondscontroller
: a function that controls the animation processend
: end function, which is called once at the end of the animationfps
: frame rate of the animationrepeat
: number of repetitions of the animationrepeat_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
: thevirtual.Element
to be movedoffset
: relative offset of the coordinatesduration
: duration of the animation, in millisecondscontroller
: a function that controls the animation processend
: end function, which is called once at the end of the animationfps
: frame rate of the animationrepeat
: number of repetitions of the animationrepeat_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 oftkinter.Canvas
that contains the itemitem
: the item to be movedoffset
: relative offset of the coordinatesduration
: duration of the animation, in millisecondscontroller
: a function that controls the animation processend
: end function, which is called once at the end of the animationfps
: frame rate of the animationrepeat
: number of repetitions of the animationrepeat_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
: thetkinter.Widget
whose color is to be gradientparameter
: parameter name of widget that is to be modified in colorcolors
: a tuple of the initial and ending colorsduration
: duration of the animation, in millisecondscontroller
: a function that controls the animation processend
: end function, which is called once at the end of the animationfps
: frame rate of the animationrepeat
: number of repetitions of the animationrepeat_delay
: length of the delay before the animation repeatsderivation
: 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 oftkinter.Canvas
that contains the itemitem
: item whose color is to be gradientparameter
: parameter name of item that is to be modified in colorcolors
: a tuple of the initial and ending colorsduration
: duration of the animation, in millisecondscontroller
: a function that controls the animation processend
: end function, which is called once at the end of the animationfps
: frame rate of the animationrepeat
: number of repetitions of the animationrepeat_delay
: length of the delay before the animation repeatsderivation
: whether the callback function is derivative
ScaleFontSize ¶
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 ofvirtual.Text
that needs to be scaledsizes
: a tuple of the initial and ending sizes or target font sizeduration
: duration of the animation, in millisecondscontroller
: a function that controls the animation processend
: end function, which is called once at the end of the animationfps
: frame rate of the animationrepeat
: number of repetitions of the animationrepeat_delay
: length of the delay before the animation repeatsderivation
: whether the callback function is derivative
generate ¶
generate(
base: collections.abc.Callable[[float], float], start: float, end: float, *, map_y: bool = True
) -> collections.abc.Callable[[float], float]
Generate a control function from an ordinary mathematical function.
base
: base function, an ordinary mathematical functionstart
: the first value of the parameter of the base functionend
: the last value of the parameter of the base functionmap_y
: whether map the final return value to 1
linear ¶
Speed remains the same.
t
: the percentage of time
smooth ¶
Speed is slow first, then fast and then slow. (slow -> fast -> slow)
t
: the percentage of time
rebound ¶
Before the end, displacement will bounce off a bit.
t
: the percentage of time