Files
lab_iteration/tile.py
njmason2 59b8557101 tile.py tile_grid.py drawtiles.py
Yes, I'll use docstrings because I can type more comments between """ and """.
I'll still use # to the right of code to comment on the code line.
2025-09-12 10:48:16 -04:00

53 lines
1.7 KiB
Python

from turtle import *
# Nelson Mason - LAI 676LEC A - Assignment 1.4 - Checkpoint 3 - Draw with ranges
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("#dddddd")
square(size)
def draw_squiggle(size): # recoded to draw a circle within each square
penup()
forward(size/4)
left(90)
forward(size/2)
pendown() # new starting point for drawing inside the tile
#forward(size/4) # original starting point for drawing inside the tile
pencolor("yellow") # change of color
#left(90) part of original starting point positioning - moved up in this code block
quarter_arc_right(size/4) # 1st arc
#quarter_arc_left(size/4) not needed for right-turn drawing of circle
#quarter_arc_left(size/4) not needed for right-turn drawing of circle
quarter_arc_right(size/4) # 2nd arc
quarter_arc_right(size/4) # 3rd arc - added to keep drawing the circle
quarter_arc_right(size/4) # 4th arc - added to keep drawing the circle
left(90) # lines 28-32 moves the pen to the tile outline starting point,
fly(size/4)
left(90)
fly(size/2)
left(90) # lower left corner, pointing to the right
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)