Files
lab_iteration/tile.py
mbhatti4 68400dfa65 Yes! I think once we start coding longer programs, it would be super helpful for me to use docstrings to explain to myself what each function does.
If you have loads of functions, they can start not making sense if you are just looking at the code.
2025-09-16 19:21:20 -04:00

65 lines
1.2 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)
def draw_tile_outline(size):
pencolor("#f5abff")
square(size)
def draw_squiggle(size):
forward(size/2)
pencolor("blue")
left(90)
forward(size)
left(90)
fly(size/2)
left(90)
fly(size/2)
left(90)
forward(size)
right(90)
fly(size/2)
right(90)
fly(size)
left(180)
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)
# 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)