tween

For tweening there’s now a port of the penner equations and function to use them.

   import time

   from domonic.lerpy.easing import *
   from domonic.lerpy.tween import *

   someObj = {'x':0,'y':0,'z':0}
   twn = Tween( someObj, { 'x':10, 'y':5, 'z':3 }, 6, Linear.easeIn )
   twn.start()

   time.sleep(1)
   print(someObj)
   time.sleep(1)
   print(someObj)
   time.sleep(1)
   print(someObj)
   # twn.pause()
   time.sleep(1)
   print(someObj)
   time.sleep(1)
   # twn.unpause()
   print(someObj)
   time.sleep(1)
   print(someObj)
   time.sleep(1)
   print(someObj)


equations can be an array with different tweens per property
# twn.equations = [ Expo.easeOut, Expo.easeIn, { ease:Back.easeOut, a:0.5, b:1.5 } ]

Note* Tweens use a domonic ‘setInterval’ which runs on a thread so won’t be affected by sleep.

Easing equations you can pass in:

Back.easeIn Bounce.easeIn Circ.easeIn Cubic.easeIn Elastic.easeIn Expo.easeIn Linear.easeIn Quad.easeIn Quart.easeIn Quint.easeIn Sine.easeIn

Back.easeOut Bounce.easeOut Circ.easeOut Cubic.easeOut Elastic.easeOut Expo.easeOut Linear.easeOut Quad.easeOut Quart.easeOut Quint.easeOut Sine.easeOut

Back.easeInOut Bounce.easeInOut Circ.easeInOut Cubic.easeInOut Elastic.easeInOut Expo.easeInOut Linear.easeInOut Quad.easeInOut Quart.easeInOut Quint.easeInOut Sine.easeInOut

get_timer

The tween engine makes use of timer method which shows how long the game has been running.

from domonic.lerpy import get_timer
print(get_timer())
class domonic.lerpy.tween.Tween(target=None, values=None, duration=0, equations=None, delay=0, loop=False)[source]

Tween is a complex lerp but you don’t have do the math cos robert penner did already. Just pass an easing equation from the easing package

i.e

twn = Tween(someObj, { ‘x’:10, ‘y’:5, ‘z’:3}, 6, Linear.easeIn )

will tween the objects properties over the given time using Linear.easeIn

pause()[source]

Pauses the tween from changing the values

unpause()[source]

unpauses the tween