PyTweening

1.2.0 · active · verified Fri Apr 10

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.

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →