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:
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)
|
||||
|
||||
Reference in New Issue
Block a user