generated from mwc/lab_iteration
Ckpoint 3 gave explanation for draw_tile_grid
Doc strings are useful becuase they can help you remember what a block of code does. I think I will use them in the future because they keep a record of what a block of code does, and can also be used to refresh your memory on a block of code you had previosuly figured out.
This commit is contained in:
parent
bf2b3fde84
commit
79df991a9d
Binary file not shown.
Binary file not shown.
33
tile.py
33
tile.py
|
@ -3,22 +3,25 @@ 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_fancysquiggle(size)
|
||||
|
||||
def draw_tile_outline(size):
|
||||
pencolor("#dddddd")
|
||||
square(size)
|
||||
|
||||
def draw_squiggle(size):
|
||||
forward(size/4)
|
||||
pencolor("black")
|
||||
def draw_fancysquiggle(size):
|
||||
pencolor("blue")
|
||||
left(90)
|
||||
quarter_arc_right(size/4)
|
||||
quarter_arc_left(size/4)
|
||||
quarter_arc_left(size/4)
|
||||
quarter_arc_right(size/4)
|
||||
half_arc_right(size/2)
|
||||
left(180)
|
||||
fly(size/2)
|
||||
left(90)
|
||||
fly(size/4)
|
||||
fly(size/2)
|
||||
right(90)
|
||||
pencolor("red")
|
||||
forward(size/2)
|
||||
left(90)
|
||||
fly(size/2)
|
||||
left(90)
|
||||
fly(size)
|
||||
left(90)
|
||||
|
@ -35,10 +38,10 @@ def square(size):
|
|||
forward(size)
|
||||
left(90)
|
||||
|
||||
def quarter_arc_right(radius):
|
||||
"Draws a quarter of an arc, turning to the right."
|
||||
circle(-radius, 90)
|
||||
def half_arc_right(radius):
|
||||
"Draws a half of an arc, turning to the right."
|
||||
circle(-radius, 180)
|
||||
|
||||
def quarter_arc_left(radius):
|
||||
"Draws a quarter of an arc, turning to the left."
|
||||
circle(radius, 90)
|
||||
def half_arc_left(radius):
|
||||
"Draws a half of an arc, turning to the left."
|
||||
circle(radius, 180)
|
||||
|
|
11
tile_grid.py
11
tile_grid.py
|
@ -9,8 +9,15 @@ 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.)
|
||||
takes 4 commands
|
||||
width is the number of tiles wide as inputted by the user
|
||||
height is the number of tiles high as inputted by the user
|
||||
tile_size is the size of the tile as inputted by the user
|
||||
tile_function is the squiggle on the tile
|
||||
For y in range(height) and for x in range(width) repeats the tile design for each tile
|
||||
and then moves back over or up to start drawing another tile until enough tiles
|
||||
to satisfy the height and width have been drawn
|
||||
The width (horizontal) tiles are drawn first because they are indented below line 23
|
||||
"""
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
|
|
Loading…
Reference in New Issue