generated from mwc/lab_iteration
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.
This commit is contained in:
26
tile.py
26
tile.py
@@ -1,5 +1,6 @@
|
||||
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)
|
||||
@@ -9,19 +10,26 @@ def draw_tile_outline(size):
|
||||
pencolor("#dddddd")
|
||||
square(size)
|
||||
|
||||
def draw_squiggle(size):
|
||||
def draw_squiggle(size): # recoded to draw a circle within each square
|
||||
penup()
|
||||
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)
|
||||
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)
|
||||
left(90)
|
||||
fly(size/2)
|
||||
left(90) # lower left corner, pointing to the right
|
||||
|
||||
def fly(distance):
|
||||
"Moves without drawing."
|
||||
|
||||
11
tile_grid.py
11
tile_grid.py
@@ -8,9 +8,13 @@ from turtle import *
|
||||
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.
|
||||
"""Draws a (width * height) grid, with tile_function drawn on each tile.
|
||||
|
||||
(Your explanation here.)
|
||||
(nested loops - inner loop draws one complete row (width), inner loop closes,
|
||||
outer loop positions the pen's return to row starting point,
|
||||
then moves pen up along height to start a new row.)
|
||||
-- (fly(tile_size) positions the pen in the next column (width) to the right
|
||||
to draw the next tile in each row)
|
||||
"""
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
@@ -37,6 +41,3 @@ def move_up_one_row(tile_size):
|
||||
right(90)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user