Files
project_drawing/drawing.py

94 lines
1.8 KiB
Python

# drawing.py
# ----------
# By Kayden
#
# (Briefly describe what this program does.)
from turtle import *
from math import sqrt
from superturtle.image import save_svg
from superturtle.movement import no_delay
def fly(distance):
"The turtle moves without drawing for a specified distance."
penup()
forward(distance)
pendown()
def square(size):
"This function defines the drawing of a square with an iteration."
for i in range(4):
forward(size)
right(90)
def pattern():
"The function draws a square in a square 3 times."
left(45)
square(50)
fly(5)
right(90)
fly(5)
left(90)
square(40)
fly(5)
right(90)
fly(5)
left(90)
square(30)
def rotateright():
"The turtle draws the pattern then moves and rotates right."
pattern()
left(135)
fly(15)
right(90)
fly(70)
right(90)
def rotateleft():
"The turtle draws the pattern then moves and rotates left."
pattern()
right(45)
fly(55)
left(90)
fly(70)
left(90)
fly(71)
left(180)
def drawright():
"The turtle draws squares to the right."
for i in range(10):
pattern()
left(135)
fly(85)
right(180)
def drawleft():
"The turtle draws squares to the left."
for i in range(10):
pattern()
right(45)
fly(57)
def draw():
"The turtle draws two rows of squares per cycle."
drawright()
rotateright()
drawleft()
rotateleft()
def draw_my_drawing():
"The turtle starts at a specific point and facing a specific direction, then performs the draw function."
penup()
goto(-320,450)
pendown()
left(180)
for i in range(7):
draw()
width, height = 816, 1056
with save_svg(width, height, "drawing.svg"):
draw_my_drawing()
input()