Created
March 24, 2016 17:35
-
-
Save kived/fc3589eeabaee9ac5c05 to your computer and use it in GitHub Desktop.
Kivy: precision animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kivy | |
kivy.require('1.8.1') | |
from kivy.app import App | |
from kivy.lang import Builder | |
from kivy.clock import Clock | |
from kivy.utils import interpolate | |
from time import time | |
root = Builder.load_string(''' | |
Button: | |
''') | |
class TestApp(App): | |
def build(self): | |
return root | |
def on_start(self): | |
self.starttime = time() | |
Clock.schedule_interval(self.update, 0) | |
def update(self, *args): | |
t = time() - self.starttime | |
ft = 1 - abs(t % 2 - 1) | |
color = interpolate((1, 0, 0, 1), (0, 0, 1, 1), 1. / ft) | |
self.root.background_color = color | |
if __name__ == '__main__': | |
TestApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment