This library provides many equivalent functions of Flash’s Caurina Tweener in cpython 2, cpython 3 and jython 2, and uses the same set of excellent easing equations by Robert Penner . In a nut-shell, it allows you to move objects with nice smooth acceleration and deceleration using a variety of methods. Plus you don’t have to worry about updating them. Any property that supports standard mathematical operations can be tweened. This is particularly useful with animations.
PiTweener itself is located in the src
directory. Usage is fairly simple. At the initialization phase:
import PiTweener
tweener = PiTweener.Tweener() # add a tween: tweener.add_tween( my_rocket, throttle = 50, set_thrust = 400, tween_time = 5.0, tween_type = tweener.OUT_QUAD, on_complete_function = my_rocket.burn )
# get a tween and modify it: mt = tweener.get_tweens_affecting_object(my_rocket)[0] tweenable = mt.get_tweenable("throttle") tweener.add_tween(tweenable, change=1000, tween_time=0.7) tweener.add_tween(mt, duration=-0.2, tween_time=0.2)
Unit tests can be executed simply by running PiTweenerTest:
cd src; python PiTweenerTest.py
The project’s documentation can be generated with Sphinx, the tool used to generate the official python documentation. On Ubuntu 10.04 (and probably Debian too) Sphinx can be installed through aptitude:
sudo apt-get install python-sphinx
The documentation can then be built through the included Makefile. For the html documentation, run:
make html
For the pdf documentation, make sure you have LaTeX installed and then run:
make latex
and then compile the pdf with latex by running:
cd doc/latex; make all-pdf
Note: If you are planning to use the html documentation with github pages, you must install sphinx-to-github first, and then run it on the generated html directory:
sphinxtogithub doc/html
Note: These instructions assume that you are running some operating system where you can use a bash shell. On Windows you can use the included bat files, and modify any relevant instructions accordingly.
PiTweener is a fork of pyTweener . It was forked by pipeep (get it?), to address a number of bugs in the pyTweener engine. In addition, PiTweener attempts to match python’s PEP 8
guidelines .