tween¶
For tweening, domonic includes a port of Robert Penner’s easing equations and helpers 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 domonic’s setInterval, which runs on a thread and is not 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 uses a timer method that shows how long the game has been running.
from domonic.lerpy import get_timer
print(get_timer())
# seconds elapsed since the timer started, e.g. 0.014599084854125977
- class domonic.lerpy.tween.Tween(target=None, values=None, duration=0, equations=None, delay=0, loop=False)[source]
Bases:
EventTargetTween 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
- FPS = 60
- property tweening
- property paused
- property position
- property target
- property values
- property duration
- property equations
- property delay
- property loop
- start()[source]
- stop()[source]
- pause()[source]
Pauses the tween from changing the values
- unpause()[source]
unpauses the tween
- reset()[source]
- class domonic.lerpy.easing.Back[source]
Bases:
object- static easeIn(t, b, c, d, aa, bb, s=1.70158)[source]
- static easeOut(t, b, c, d, aa, bb, s=1.70158)[source]
- static easeInOut(t, b, c, d, aa, bb, s=1.70158)[source]
- class domonic.lerpy.easing.Bounce[source]
Bases:
object- static easeIn(t, b, c, d, aa=0, bb=0)[source]
- static easeOut(t, b, c, d, aa=0, bb=0)[source]
- static easeInOut(t, b, c, d, aa=0, bb=0)[source]
- class domonic.lerpy.easing.Circ[source]
Bases:
object- static easeIn(t, b, c, d, aa, bb)[source]
- static easeOut(t, b, c, d, aa, bb)[source]
- static easeInOut(t, b, c, d, aa, bb)[source]
- class domonic.lerpy.easing.Cubic[source]
Bases:
object- static easeIn(t, b, c, d, aa, bb)[source]
- static easeOut(t, b, c, d, aa, bb)[source]
- static easeInOut(t, b, c, d, aa, bb)[source]
- class domonic.lerpy.easing.Elastic[source]
Bases:
object- static easeIn(t, b, c, d, aa, bb)[source]
- static easeOut(t, b, c, d, aa, bb)[source]
- static easeInOut(t, b, c, d, aa, bb)[source]
- class domonic.lerpy.easing.Expo[source]
Bases:
object- static easeIn(t, b, c, d, aa, bb)[source]
- static easeOut(t, b, c, d, aa, bb)[source]
- static easeInOut(t, b, c, d, aa, bb)[source]
- class domonic.lerpy.easing.Linear[source]
Bases:
object- static easeNone(t, b, c, d, aa, bb)[source]
- static easeIn(t, b, c, d, aa, bb)[source]
- static easeOut(t, b, c, d, aa, bb)[source]
- static easeInOut(t, b, c, d, aa, bb)[source]
- class domonic.lerpy.easing.Quad[source]
Bases:
object- static easeIn(t, b, c, d, aa, bb)[source]
- static easeOut(t, b, c, d, aa, bb)[source]
- static easeInOut(t, b, c, d, aa, bb)[source]
- class domonic.lerpy.easing.Quart[source]
Bases:
object- static easeIn(t, b, c, d, aa, bb)[source]
- static easeOut(t, b, c, d, aa, bb)[source]
- static easeInOut(t, b, c, d, aa, bb)[source]