generated from mwc/lab_iteration
Created a line in the title by creating a function and moving the turtle foward and back. I took out the squiggle function.
Checkpoint 3: Yes I do think I will use docstrings as it will help me provide space to write explain the meaning of the code along with what it is doing. They can be very useful.
This commit is contained in:
25
tile.py
25
tile.py
@@ -3,25 +3,20 @@ from turtle import *
|
|||||||
def draw_tile(size):
|
def draw_tile(size):
|
||||||
"Draws one tile, which can be repeated to form a pattern."
|
"Draws one tile, which can be repeated to form a pattern."
|
||||||
draw_tile_outline(size)
|
draw_tile_outline(size)
|
||||||
draw_squiggle(size)
|
draw_stripe(size)
|
||||||
|
|
||||||
def draw_tile_outline(size):
|
def draw_tile_outline(size):
|
||||||
pencolor("#dddddd")
|
pencolor("#dddddd")
|
||||||
square(size)
|
square(size)
|
||||||
|
|
||||||
def draw_squiggle(size):
|
def draw_stripe(size):
|
||||||
forward(size/4)
|
|
||||||
pencolor("black")
|
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)
|
fly(size/4)
|
||||||
left(90)
|
left(90)
|
||||||
fly(size)
|
forward(size)
|
||||||
left(90)
|
backward(size)
|
||||||
|
right(90)
|
||||||
|
fly(-size/4)
|
||||||
|
|
||||||
def fly(distance):
|
def fly(distance):
|
||||||
"Moves without drawing."
|
"Moves without drawing."
|
||||||
@@ -34,11 +29,3 @@ def square(size):
|
|||||||
for side in range(4):
|
for side in range(4):
|
||||||
forward(size)
|
forward(size)
|
||||||
left(90)
|
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)
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from tile import fly
|
|||||||
def draw_tile_grid(width, height, tile_size, tile_function):
|
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 x height) grid, with tile_function drawn on each tile.
|
||||||
|
|
||||||
(Your explanation here.)
|
(You give it a grid width, height, size(length) and function that does the drawing. It draws tiles goes to the left moves up a row and repeats all the rows from the height and width. The turtle then ends at the starting point.)
|
||||||
"""
|
"""
|
||||||
for y in range(height):
|
for y in range(height):
|
||||||
for x in range(width):
|
for x in range(width):
|
||||||
|
|||||||
Reference in New Issue
Block a user