Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. from kivy.app import App
  2. from kivy.clock import Clock
  3. from kivy.properties import NumericProperty
  4. from kivy.lang import Builder
  5.  
  6.  
  7. KV = '''
  8. #:import cos math.cos
  9. #:import sin math.sin
  10. #:import chain itertools.chain
  11.  
  12. Widget:
  13. points:
  14. list(
  15. chain(*
  16. ((
  17. cos(x / 100.) * cos(app.time + x) * self.width / 2 + self.width / 2,
  18. sin(x / 100.) * cos(app.time + x) * self.height / 2 + self.height / 2
  19. ) for x in range(0, 24 * 314, 4 * 314 / 6))
  20. ))
  21. canvas:
  22. Color:
  23. rgba: .5, .5, .5, 1
  24. Line:
  25. points: self.points or []
  26. width: 3
  27. '''
  28.  
  29.  
  30. class ClockApp(App):
  31. time = NumericProperty(0)
  32.  
  33. def build(self):
  34. Clock.schedule_interval(self.update_clock, 0)
  35. self.root = Builder.load_string(KV)
  36. return self.root
  37.  
  38. def update_clock(self, dt):
  39. self.time += dt
  40.  
  41.  
  42. if __name__ == '__main__':
  43. ClockApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement