Skip to main content

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)

Project details


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.3.zip (15.8 kB view details)

Uploaded Source

File details

Details for the file PyTweening-1.0.3.zip.

File metadata

  • Download URL: PyTweening-1.0.3.zip
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyTweening-1.0.3.zip
Algorithm Hash digest
SHA256 4b608a570f4dccf2201e898f643c2a12372eb1d71a3dbc7e778771b603ca248b
MD5 41176abe770e8c318dc1f4213831e6da
BLAKE2b-256 b9f8c32a58d6e4dff8aa5c27e907194d69f3b57e525c2e4af96f39c6e9c854d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page