Files
lab_iteration/tile.py
jwberent c50ef8c836 I changed the pattern of the tiles and added the docstring to the function.
Checkpoint 3:
- I will definitely use docstrings in the future.  I will use them because they are helpful in showing another person what each function does.  Also, when I am debugging my code it will be helpful if I know what each function is supposed to be doing.
2025-09-11 18:29:45 -04:00

50 lines
1.0 KiB
Python

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_squiggle(size/2)
draw_squiggle(size/3)
draw_squiggle(size/4)
draw_squiggle(size/5)
draw_squiggle(size/6)
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()
forward(distance)
pendown()
def square(size):
"Draws a square of side length `size`"
for side in range(4):
forward(size)
left(90)
def quarter_arc_right(radius):
"Draws a quarter of an arc, turning to the right."
circle(-radius, 90)
def quarter_arc_left(radius):
"Draws a quarter of an arc, turning to the left."
circle(radius, 90)