Skip to content

Instantly share code, notes, and snippets.

@mdamien
Last active August 29, 2015 14:07
Show Gist options
  • Save mdamien/7db237f78eb38a4ae9b3 to your computer and use it in GitHub Desktop.
Save mdamien/7db237f78eb38a4ae9b3 to your computer and use it in GitHub Desktop.
atelier python
# https://docs.python.org/3.4/library/turtle.html
from turtle import *
import random
def draw_cookie(x, y):
penup()
goto(x,y)
pendown()
radius = random.randint(100,200)
col = random.choice(['#CC6600','#FFCD82','#8F4700'])
color(col)
dot(radius)
for i in range(random.randint(15,20)):
size = int(radius/3)
x2 = x + random.randint(-size,size)
y2 = y + random.randint(-size,size)
col2 = random.choice(['#663300','#754719','#996633'])
color(col2)
radius2 = random.randint(10,20)
penup()
goto(x2, y2)
pendown()
dot(radius2)
draw_cookie(10, 10)
onscreenclick(draw_cookie)
done()
import turtle
from random import randint
turtle.hideturtle()
turtle.speed('fastest')
def moveto(x,y):
turtle.penup()
turtle.goto(x,y)
turtle.pendown()
turtle.onscreenclick(moveto)
while True:
r = randint(0, 360)
turtle.setheading(r)
turtle.forward(10)
@mdamien
Copy link
Author

mdamien commented Oct 7, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment