Skip to content

Instantly share code, notes, and snippets.

@SebastianJarsve
Created April 3, 2013 01:15
Show Gist options
  • Save SebastianJarsve/5297690 to your computer and use it in GitHub Desktop.
Save SebastianJarsve/5297690 to your computer and use it in GitHub Desktop.
from scene import *
class MyScene (Scene):
def setup(self):
self.lines = []
def touch_began(self, touch):
x = touch.location.x
y = touch.location.y
self.xybegin = Point(x,y)
print "Touch began at (%s, %s)" % (x, y)
def touch_ended(self, touch):
x = touch.location.x
y = touch.location.y
self.lines.append((self.xybegin.x, self.xybegin.y, x, y))
print "Touch ended at (%s, %s)" % (x, y)
def draw(self):
background(0, 0, 0)
fill(1, 0, 0)
stroke(1, 0, 0)
stroke_weight(3)
for touch in self.touches.values():
x = touch.location.x
y = touch.location.y
line(self.xybegin.x, self.xybegin.y, x, y)
for l in self.lines:
line(*l)
run(MyScene())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment