Last active
December 20, 2015 07:49
-
-
Save mmurdoch/6095932 to your computer and use it in GitHub Desktop.
Circle Touch
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
# Copyright Matthew Murdoch | |
# Remix under the terms of the MIT license (see http://opensource.org/licenses/MIT) | |
from random import random | |
from scene import * | |
class Circle(object): | |
def __init__(self, location, color): | |
self.location = location | |
self.color = color | |
class CircleTouch(Scene): | |
def __init__(self): | |
self.circles = [] | |
def draw(self): | |
background(0, 0, 0) | |
for circle in self.circles: | |
fill(circle.color.r, circle.color.g, circle.color.b) | |
ellipse(circle.location.x - 50, circle.location.y - 50, 50, 50) | |
def touch_began(self, touch): | |
location = touch.location | |
random_color = Color(random(), random(), random()) | |
circle = Circle(location, random_color) | |
self.circles.append(circle) | |
run(CircleTouch()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment