From 68400dfa650c4050d363837188476aa6efab4dec Mon Sep 17 00:00:00 2001 From: mbhatti4 Date: Tue, 16 Sep 2025 19:21:20 -0400 Subject: [PATCH] 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. --- tile.py | 46 +++++++++++++++++++++++++++++++++------------- tile_grid.py | 7 ++++++- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/tile.py b/tile.py index 697cf8e..4110e4c 100644 --- a/tile.py +++ b/tile.py @@ -6,22 +6,28 @@ def draw_tile(size): draw_squiggle(size) def draw_tile_outline(size): - pencolor("#dddddd") + pencolor("#f5abff") square(size) def draw_squiggle(size): - forward(size/4) - pencolor("black") + forward(size/2) + pencolor("blue") left(90) - quarter_arc_right(size/4) - quarter_arc_left(size/4) - quarter_arc_left(size/4) - quarter_arc_right(size/4) + forward(size) left(90) - fly(size/4) + fly(size/2) left(90) + fly(size/2) + left(90) + forward(size) + right(90) + fly(size/2) + right(90) fly(size) - left(90) + left(180) + + + def fly(distance): "Moves without drawing." @@ -35,10 +41,24 @@ def square(size): forward(size) left(90) -def quarter_arc_right(radius): +#def quarter_arc_right(radius): "Draws a quarter of an arc, turning to the right." - circle(-radius, 90) + #circle(-radius, 90) -def quarter_arc_left(radius): +#def quarter_arc_left(radius): "Draws a quarter of an arc, turning to the left." - circle(radius, 90) + # 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) diff --git a/tile_grid.py b/tile_grid.py index 72a0f43..e38d521 100644 --- a/tile_grid.py +++ b/tile_grid.py @@ -10,7 +10,12 @@ 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.) + This code draws the grid of the tiles. It takes the width, height and tile size and creates a grid that matches. + Everytime it finishes a tile, it goes back the origin of the square to then continue to the next tile. + Once it finishes the row, it goes back to the origin of the first tile to then build up the next row. + At the end of drawing all the tiles, it moves the pen back to the origin. + + """ for y in range(height): for x in range(width):