A collection of tweening / easing functions.
Project description
PyTweening
A collection of tweening / easing functions implemented in Python.
Example Usage
All tweening / easing functions are passed an argument of a float from 0.0 (for the beginning) to 1.0 (for the end) of the tween:
>>> pytweening.linear(0.5)
0.5
>>> pytweening.linear(0.75)
0.75
>>> pytweening.linear(1.0)
1.0
>>> pytweening.easeInQuad(0.5)
0.25
>>> pytweening.easeInQuad(0.75)
0.5625
>>> pytweening.easeInQuad(1.0)
1.0
>>> pytweening.easeInOutSine(0.5)
0.49999999999999994
>>> pytweening.easeInOutSine(0.75)
0.8535533905932737
>>> pytweening.easeInOutSine(1.0)
1.0
The getLine() function also provides a Bresenham line algorithm implementation:
>>> pytweening.getLine(0, 0, 5, 10)
[(0, 0), (0, 1), (1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7), (4, 8), (4, 9), (5, 10)]
The getLinePoint() function finds a point on the provided line (even if it extends before or past the start or end points):
>>> getLinePoint(0, 0, 5, 10, 0.0)
(0.0, 0.0)
>>> getLinePoint(0, 0, 5, 10, 0.25)
(1.25, 2.5)
>>> getLinePoint(0, 0, 5, 10, 0.5)
(2.5, 5.0)
>>> getLinePoint(0, 0, 5, 10, 0.75)
(3.75, 7.5)
>>> getLinePoint(0, 0, 5, 10, 1.0)
(5.0, 10.0)
Support
If you find this project helpful and would like to support its development, consider donating to its creator on Patreon.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytweening-1.0.4.tar.gz
(14.4 kB
view details)
File details
Details for the file pytweening-1.0.4.tar.gz.
File metadata
- Download URL: pytweening-1.0.4.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8533282cf70b31de8a0499e1cf420930b0013c787118872b2ec899382792e2e6
|
|
| MD5 |
d63ef1bf38bc15a51b107016085595d3
|
|
| BLAKE2b-256 |
e94facb6a2d95260a4377885e40c167fd5df587630696a6a7934675f86aebb06
|