API

class transytion.Delay(duration: float)

Does not do anything but waits some time.

class transytion.Tween(duration: float, obj: ~typing.Any, targets: dict[str, float], start: dict[str, float] | None = None, ease_func: ~collections.abc.Callable[[float], float] = <function linear>, before_execution: ~collections.abc.Callable[[], None] = <function Tween.<lambda>>, callback: ~collections.abc.Callable[[], None] = <function Tween.<lambda>>, on_pause: ~collections.abc.Callable[[], None] = <function Tween.<lambda>>, on_remove: ~collections.abc.Callable[[], None] = <function Tween.<lambda>>, args: tuple[~typing.Any, ...] = (), repeat_count: int | float = 1)

A list of TweenNodes with some organizational skills.

property args

Get the args for the final callback.

property callback

Get the final callback.

property finished

Determine if a tween has finished going forward or backward.

pause()

Pause a tween. Tells the manager of this tween to put it in the paused tweens list.

reset()

Restarts a tween from the beginning.

resume()

Resume a tween. If the tween was paused, it is now put in the active tween list and resumed by it’s manager.

update(dt) None

Updates the current TweenNode and transitions to the next TweenNode if the current one has finished updating.

class transytion.TweenManager

Keeps track of updating tweens in an update loop.

class transytion.TweenNode(duration: float, obj: ~typing.Any, targets: dict[str, float], start_vals: dict[str, float] | None = None, ease_func: ~collections.abc.Callable[[float], float] = <function linear>, callback: ~collections.abc.Callable[[], None] = <function TweenNode.<lambda>>, args: tuple[~typing.Any, ...] = (), _progress: float = 0.0)

Fundamental building block for Tweens.

ease_func() float

Linear tween that returns the thing itself.

safe_reset_to_start()

If start position is specified (not None), make sure values start from the start. Otherwise, start from where they currently are.

start()

Must also have the original and resulting position to actually tween between those values.

transytion.call_then_tween(tween, manager=<transytion.TweenManager object>)

Intended to be used as a decorator. Given a function f, f(args) now executes and then starts the tween.

NOTE: f(args) followed by f(args) will not block the second call. Two tweens will be added and both will do a double execution of f.

transytion.chain(tweens: list[Tween]) Tween

Take a list of tweens and create a single tween that is equivalent to each tween followed by the next.

transytion.repeat(tween: Tween, count=inf) Tween

Repeats count times. (Defaults to indefinitely, that is float(“inf”)

transytion.tween_then_call(tween: Tween, manager: TweenManager = <transytion.TweenManager object>)

Intended to be used as a decorator. Given a function f, f(args) now executes the tween then calls the function. Similar to tweenify, but intended to be used by being added to a particular tween manager, and, by default, the default manager. This is largely a convenience decorator for tweenify.

NOTE: f(args) followed by f(args) will not block the second call. Two tweens will be added and both will do a double execution of f. NOTE: Because of Python limitations, cannot return value.

transytion.tweenify(tween)

Makes a function when called return a tween that executes the decorated function for the tween’s callback.

transytion.ease_funcs.back(x: float) float

Returns ‘back’ tween. See: https://easings.net/#easeInBack

transytion.ease_funcs.bounce(x: float) float

Performs bound (out) tween. See https://easings.net/#easeOutBounce

transytion.ease_funcs.circ(x: float) float

Returns a circular tween. See https://easings.net/#easeInCirc

transytion.ease_funcs.cubic(x: float) float

Cubic tween, returns the cube of itself.

transytion.ease_funcs.elastic(x: float) float

Returns elastic tween. See https://easings.net/#easeInElastic

transytion.ease_funcs.expo(x: float) float

Exponential tween, returns 2^(10x - 10).

transytion.ease_funcs.inout(f: Callable[[float], float]) Callable[[float], float]

Doubles the speed of an easing function f. Plays the easing function then plays the reverse of f for the second half of the tween.

transytion.ease_funcs.linear(x: float) float

Linear tween that returns the thing itself.

transytion.ease_funcs.out(f: Callable[[float], float]) Callable[[float], float]

Reverses the easing function.

transytion.ease_funcs.quad(x: float) float

Quadratic tween, returns the square of itself.

transytion.ease_funcs.quart(x: float) float

Quartic tween, returns itself raised to the fourth power.

transytion.ease_funcs.quint(x: float) float

Quintic tween, returns itself raised to the fifth power.

transytion.ease_funcs.sine(x: float) float

Sinusoidal tween.