def _tick(self): t = clamp((Date().getTime() - self._startedAt) / self._duration, 0, 1) self._callback(t) if t < 1: setTimeout(bind(self._tick, self), 1)
def _changeColor(self): self._oldColor = self._newColor self._newColor = Color(randint(0, 255), randint(0, 255), randint(0, 255)) def callback(t): document.body.style.background = self._oldColor._interpolatedToward(self._newColor, t)._webString() def onComplete(t): document.title = self._newColor._webString() Tween( { "_duration": TRANSITION_DURATION, "_callback": bind(callback, self), "_easing": easeInOut, "_onComplete": bind(onComplete, self), } ) setTimeout(bind(arguments.callee, self), CHANGE_EVERY)
def _changeColor(self): self._oldColor = self._newColor self._newColor = Color(randint(0, 255), randint(0, 255), randint(0, 255)) def callback(t): document.body.style.background = ( self._oldColor._interpolatedToward(self._newColor, t)._webString()) def onComplete(t): document.title = self._newColor._webString() Tween({ '_duration': TRANSITION_DURATION, '_callback': bind(callback, self), '_easing': easeInOut, '_onComplete': bind(onComplete, self), }) setTimeout(bind(arguments.callee, self), CHANGE_EVERY)