Last active
August 20, 2017 10:42
-
-
Save tshirtman/603cbda8202103cb7845adb54bb90ee2 to your computer and use it in GitHub Desktop.
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
from math import cos, sin | |
from kivy.uix.widget import Widget | |
from kivy.graphics import Line | |
from kivy.clock import Clock | |
from kivy.app import App | |
from kivy.properties import ListProperty, NumericProperty | |
class ShortLineApp(App): | |
time = NumericProperty() | |
def build(self): | |
Clock.schedule_interval(self.update, 0) | |
widget = Widget() | |
with widget.canvas: | |
widget.line = Line(points=[], width=4) | |
return widget | |
def update(self, dt): | |
self.time += dt | |
point = ( | |
self.root.center_x + self.root.width / 2 * cos(self.time), | |
self.root.center_y + self.root.height / 2 * sin(self.time) | |
) | |
line = self.root.line | |
line.points += point | |
if len(line.points) > 200: | |
line.points.pop(0) | |
line.points.pop(0) | |
if __name__ == '__main__': | |
ShortLineApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment