Registry / data / pytweening

pytweening

JSON →
library1.2.0pypypi✓ verified 26d ago

PyTweening is a lightweight Python library providing a collection of tweening (also known as easing) functions. These functions allow for smooth, non-linear interpolation between values, commonly used to create natural-looking animations in graphical applications or games. The library is currently at version 1.2.0 and receives periodic updates to enhance functionality and maintain compatibility.

pip install pytweening
INSTALL
IMPORT
SIG · PYTWEENING
P
pytweening
datapythonv1.2.0
Install
2.4s avg
Import
12ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.014s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.008s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pytweening
import pytweening
All tweening functions and utilities are directly available as attributes of the imported 'pytweening' module.

This quickstart demonstrates how to import `pytweening` and use some of its core tweening functions. Tweening functions typically take a float `n` from 0.0 (start) to 1.0 (end) and return a new float, which can then be used to interpolate between two desired values.

import pytweening # Get a linear tween value at 50% progress linear_value = pytweening.linear(0.5) print(f"Linear tween at 0.5: {linear_value}") # Get an ease-in-quad tween value at 50% progress ease_in_quad_value = pytweening.easeInQuad(0.5) print(f"EaseInQuad tween at 0.5: {ease_in_quad_value}") # Example of interpolating a value from start to end using a tweening function start_val = 0 end_val = 100 progress = 0.75 # 75% of the animation progress tweened_progress = pytweening.easeInOutSine(progress) interpolated_value = start_val + (end_val - start_val) * tweened_progress print(f"Interpolated value at {progress} progress (easeInOutSine): {interpolated_value}")
Debug
Known issues
gotchaTweening functions generally expect an input 'n' between 0.0 and 1.0 representing the progress of the animation. While the library itself doesn't strictly enforce this range check internally anymore, providing values outside of this range might lead to unexpected results, especially for functions designed to stay within the 0.0-1.0 output range.
fix
Ensure that the input parameter 'n' to tweening functions (e.g., `pytweening.linear(n)`) is always a float between 0.0 and 1.0 for predictable behavior. Custom functions like `easeInOutElastic` might naturally go outside this range for visual effects, but the input should still be 0.0-1.0.
affects: All versions
gotchaWhen using iterator functions like `pytweening.iterLinear` to generate sequences of points, some floating-point rounding errors may naturally occur in the output coordinates. This is a common characteristic of floating-point arithmetic.
fix
Be aware of potential minor inaccuracies when precise integer coordinates are required for iterated lines. If pixel-perfect integer coordinates are critical, consider explicit rounding or using integer-based line algorithms.
affects: All versions
gotchaPyTweening provides client-side animation logic. When integrating into multi-client environments (e.g., online games) or systems involving physics, performing local client-side tweens on shared objects can lead to desynchronization. Different clients might observe inconsistent object positions due to network latency or varying execution times.
fix
For shared game objects or physics-driven movements in networked applications, it is often better to manage the 'tween' state (start/end positions, duration, easing type) on the server and replicate the results, or use server-side interpolation to ensure consistency across all clients.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pytweening'
The pytweening library has not been installed in the current Python environment.
fix
pip install pytweening
AttributeError: module 'pytweening' has no attribute 'EaseInQuad'
The tweening function name was incorrectly capitalized; pytweening functions typically use camelCase starting with a lowercase 'e' (e.g., easeInQuad, easeOutBounce).
fix
Use the correct casing for the function name, e.g., pytweening.easeInQuad instead of pytweening.EaseInQuad.
TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
A non-numeric value (like a string, None, or an object that doesn't support arithmetic operations) was passed as the time parameter 't' to a tweening function, which expects a float or int between 0.0 and 1.0.
fix
Ensure the value passed to the tweening function is a float or integer, typically representing time from 0.0 to 1.0. Example: pytweening.easeInQuad(0.5) instead of pytweening.easeInQuad("0.5")
NameError: name 'easeInQuad' is not defined
A pytweening function was called without being prefixed by the module name, indicating it was not imported directly into the global namespace.
fix
Either prefix the function call with the module name (pytweening.easeInQuad(t)) or import the specific function directly (from pytweening import easeInQuad).
Upgrade
Version history
1.2.0latest on PyPI · released Feb 20, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
8
Resources
pytweening — pip install pytweening · libregistry