generated from mwc/lab_iteration
Created an arc drawing for each tile.
This was definitely trickier than the previous two examples we looked at, and there was a significant amount of trial and error to get this functional. Specifically, having the turtle return to its original starting point was tricky as there was a bug where the turtle would glitch around the screen before settling on its end point, which threw me off for some time. Thankfully, I just began testing some different combinations one at a time until I achieved the desired outcome.
This commit is contained in:
parent
38e1a0349f
commit
d7555aef89
Binary file not shown.
Binary file not shown.
26
tile.py
26
tile.py
|
@ -3,26 +3,12 @@ from turtle import *
|
|||
def draw_tile(size):
|
||||
"Draws one tile, which can be repeated to form a pattern."
|
||||
draw_tile_outline(size)
|
||||
draw_squiggle(size)
|
||||
draw_greater_arc(size)
|
||||
|
||||
def draw_tile_outline(size):
|
||||
pencolor("#dddddd")
|
||||
square(size)
|
||||
|
||||
def draw_squiggle(size):
|
||||
forward(size/4)
|
||||
pencolor("black")
|
||||
left(90)
|
||||
quarter_arc_right(size/4)
|
||||
quarter_arc_left(size/4)
|
||||
quarter_arc_left(size/4)
|
||||
quarter_arc_right(size/4)
|
||||
left(90)
|
||||
fly(size/4)
|
||||
left(90)
|
||||
fly(size)
|
||||
left(90)
|
||||
|
||||
def fly(distance):
|
||||
"Moves without drawing."
|
||||
penup()
|
||||
|
@ -42,3 +28,13 @@ def quarter_arc_right(radius):
|
|||
def quarter_arc_left(radius):
|
||||
"Draws a quarter of an arc, turning to the left."
|
||||
circle(radius, 90)
|
||||
|
||||
def draw_greater_arc(size):
|
||||
"Draw a full arc or half of a circle, turning to the left."
|
||||
pencolor("black")
|
||||
quarter_arc_left(size/2)
|
||||
quarter_arc_left(size/2)
|
||||
left(90)
|
||||
fly(size)
|
||||
left(90)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from tile import fly
|
|||
def draw_tile_grid(width, height, tile_size, tile_function):
|
||||
"""Draws a (width x height) grid, with tile_function drawn on each tile.
|
||||
|
||||
(Your explanation here.)
|
||||
Uses the tile_size function to create an evenly distributed grid before returning to starting position.
|
||||
"""
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
|
|
Loading…
Reference in New Issue