lab_iteration/tile.py

55 lines
1.2 KiB
Python

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)
"""Here. If you change outline the boxes are small, not connencted and squiggles drawing outside.
Here. If you change squiggles, they draw extremley small in bottom left corner of boxes, correct size."""
def draw_tile_outline(size):
"Changed Pen color from black to blue"
pencolor("blue")
pensize(2)
square(size)
def draw_squiggle(size):
pensize(3)
forward(size/4)
pencolor("purple")
left(90)
quarter_arc_right(size/4)
quarter_arc_left(size/4)
pensize(1)
pencolor("red")
quarter_arc_left(size/4)
quarter_arc_right(size/4)
left(90)
fly(size/4)
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 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)