跳转至

maliang.animation.controllers

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

源代码:maliang/animation/controllers.py

Controller generator and standard control functions.

Definition of control function:

def f(t: float) -> float: ...
  • t: 0% ~ 100%, indicates the percentage of time
  • return: real number, indicates a multiple of the cardinality of the animation

函数:

  • 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)

generate

generate(
    base: collections.abc.Callable[[float], float], start: float, end: float
) -> collections.abc.Callable[[float], float]
generate(
    base: collections.abc.Callable[[float], float],
    start: float,
    end: float,
    *,
    map_y: typing.Literal[False] = False
) -> collections.abc.Callable[[float], float]
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 function
  • start: the first value of the parameter of the base function
  • end: the last value of the parameter of the base function
  • map_y: whether map the final return value to 1

linear

linear(t: int) -> int
linear(t: float) -> float
linear(t: float) -> float

Speed remains the same.

  • t: the percentage of time

smooth

smooth(t: float) -> float

Speed is slow first, then fast and then slow. (slow -> fast -> slow)

  • t: the percentage of time

rebound

rebound(t: float) -> float

Before the end, displacement will bounce off a bit.

  • t: the percentage of time

ease_in

ease_in(t: float) -> float

Gradually accelerate. (slow -> fast)

  • t: the percentage of time

ease_out

ease_out(t: float) -> float

Gradually decelerate. (fast -> slow)

  • t: the percentage of time