Created
January 9, 2014 20:12
-
-
Save inclement/8341110 to your computer and use it in GitHub Desktop.
Simple circle drawing kivy example.
This file contains hidden or 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 kivy.app import App | |
| from kivy.base import runTouchApp | |
| from kivy.uix.widget import Widget | |
| from kivy.properties import ListProperty | |
| from kivy.lang import Builder | |
| Builder.load_string(''' | |
| <DrawingWidget>: | |
| canvas: | |
| Color: | |
| <DrawingWidget>: | |
| canvas: | |
| Color: | |
| rgba: 1, 0, 0, 1 | |
| Line: | |
| circle: self.circle_params | |
| ''') | |
| class DrawingWidget(Widget): | |
| circle_params = ListProperty([0, 0, 50]) | |
| def on_touch_down(self, touch): | |
| self.on_touch_move(touch) | |
| def on_touch_move(self, touch): | |
| self.circle_params = [touch.pos[0], touch.pos[1], | |
| touch.pos[0]] | |
| runTouchApp(DrawingWidget()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment