Created
November 27, 2016 14:51
-
-
Save jungleBadger/9fb8327d1b5e1cc26aa6b784c7529a38 to your computer and use it in GitHub Desktop.
Drawing with Python's Turtle module. Udacity full stack web dev nano degree
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
import turtle | |
def draw_initials(): | |
pointer = turtle.Turtle() | |
draw_d(pointer) | |
pointer.color("black") | |
pointer.forward(40) | |
draw_a(pointer) | |
def draw_a(a): | |
a.color("red") | |
a.left(75) | |
a.forward(110) | |
a.right(150) | |
a.forward(110) | |
a.right(180) | |
a.forward(50) | |
a.left(75) | |
a.forward(35) | |
def draw_d(d): | |
d.color("blue") | |
d.right(90) | |
d.forward(100) | |
d.left(90) | |
d.forward(20) | |
d.left(45) | |
d.forward(30) | |
d.left(45) | |
d.forward(60) | |
d.left(45) | |
d.forward(30) | |
d.left(45) | |
d.forward(20) | |
d.left(90) | |
d.forward(102) | |
d.left(90) | |
d.forward(20) | |
def draw_shapes(): | |
window = turtle.Screen() | |
window.bgcolor("white") | |
draw_initials() | |
brad = turtle.Turtle() | |
brad.penup() | |
brad.setx(150) | |
brad.sety(150) | |
brad.pendown() | |
for i in range(0, 35): | |
draw_square(brad) | |
angie = turtle.Turtle() | |
angie.penup() | |
angie.setx(80) | |
angie.sety(80) | |
angie.pendown() | |
for i in range(0, 36): | |
draw_circle(angie) | |
angie.right(10) | |
draw_triangle() | |
window.exitonclick() | |
def draw_square(brad): | |
brad.color("green") | |
brad.speed(200) | |
iteration = 0 | |
while iteration < 5: | |
brad.forward(100) | |
brad.right(90) | |
iteration += 1 | |
brad.right(10) | |
def draw_circle(angie): | |
angie.color("yellow") | |
angie.speed(30) | |
angie.circle(50) | |
def draw_triangle(): | |
iteration = 0 | |
almond = turtle.Turtle() | |
almond.color("red") | |
while iteration < 3: | |
almond.forward(160) | |
almond.left(120) | |
iteration += 1 | |
draw_shapes() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment