lab_iteration/tile.py

48 lines
941 B
Python

from turtle import *
def draw_tile(size):
"Draws one tile, which can be repeated to form a pattern."
draw_tile_outline(size)
draw_fancysquiggle(size)
def draw_tile_outline(size):
pencolor("#dddddd")
square(size)
def draw_fancysquiggle(size):
pencolor("blue")
left(90)
half_arc_right(size/2)
left(180)
fly(size/2)
left(90)
fly(size/2)
right(90)
pencolor("red")
forward(size/2)
left(90)
fly(size/2)
left(90)
fly(size)
left(90)
def fly(distance):
"Moves without drawing."
penup()
forward(distance)
pendown()
def square(size):
"Draws a square of side length `size`"
for side in range(4):
forward(size)
left(90)
def half_arc_right(radius):
"Draws a half of an arc, turning to the right."
circle(-radius, 180)
def half_arc_left(radius):
"Draws a half of an arc, turning to the left."
circle(radius, 180)