Last active
October 29, 2016 17:24
-
-
Save garrypolley/5fe699683d85226a95728c5e4da0173c to your computer and use it in GitHub Desktop.
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_multi_color_shape(t_turtle, size): | |
"""Make turtle t_turtle draw a multi-colour shape based on size passed in.""" | |
colors = ['#2424FF', '#aaa', '#FF2424', '#ccc', '#24FF24', '#000'] | |
for color in colors: | |
t_turtle.color(color) | |
t_turtle.forward(size) | |
t_turtle.left(135) | |
def create_turtle(speed, pensize): | |
"""Returns a configured turtule""" | |
turt = turtle.Turtle() | |
turt.speed(speed) | |
turt.pensize(pensize) | |
return turt | |
def move_turtle(t_turtle, forward, right): | |
"""Move t_turtle forward and then right""" | |
t_turtle.forward(forward) | |
t_turtle.right(right) | |
# Setup the screen for drawing | |
wn = turtle.Screen() | |
wn.bgcolor("#fff") | |
# Create our turtle | |
tess = create_turtle(0, 3.5) | |
# Lift turtle and move it | |
tess.up() | |
tess.goto(0, 250) | |
tess.down() | |
# Start coloring for the turtle | |
tess.begin_fill() | |
# Begin actually drawing | |
square_size = 30 | |
square_rotation = 8 | |
for i in range(45): | |
draw_multi_color_shape(tess, square_size) | |
square_size += square_rotation | |
move_turtle(tess, square_size, square_rotation) | |
tess.end_fill() | |
wn.exitonclick() |
Author
garrypolley
commented
Oct 29, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment