This year, in our pursuit to learn or improve upon our Python, we did a project which included using the Python Turtle function to create an image. My partner, Gabriel, and I decided that it would be best if we drew the logo of a popular online communications app named Discord. Ironically, we both communicated with each other via Discord as we programmed this. The image on the right shows our final result
Gabriel was responsible for creating the main body of the logo while I was responsible for programming the more intricate areas of the logo, such as the top triggers and bottom grips of the logo. I also made the sides of the logo and basically connected everything together so that it would look natural. We used two turtles, with one being a "master" and one being a "mirror". Gabriel helped tremendously by programming the functions which would utilize both turtles, which ultimately helped us trim down on the size of the file. I thought that this would be difficult to create, with the logo's abundance of contours and angles. However, with trial and error and some calculation, we were able to execute it as we planned. The code below is what we created.
###########################################
# Start
# Created by Nicholas and Gabriel
###########################################
# Importing and Essential Variables
###########################################
#Importing Turtle.
import turtle
# Importing Time (for finish time)
import time
# Normal Turtle.
t = turtle.Turtle()
# Mirror Turtle for easier programming.
i = turtle.Turtle()
i.shape("turtle")
# Speed for turtle.
turtle.speed(1000000)
# Colors for project.
back = '#4F4FEC'
main = '#FFFFFF'
# Creating a fixed screen.
turtle.setworldcoordinates(-300,-300,300,300)
#Setting backdrop color.
turtle.bgcolor(main)
###########################################
# Functions for drawing.
###########################################
# Forward Movement (On T Side) for mirror.
def mMovement(forA):
t.forward(float(forA))
i.backward(float(forA))
# Rotating Movement (both) for mirror.
def mRotate(forB):
t.left(forB)
i.right(forB)
# Get Positioning . (Both)
def mGetPos():
items = {
'T1' : t.pos(),
'T2' : i.pos()
}
return items
# Get Heading. (Both)
def mGetHead():
items = {
'T1' : t.heading(),
'T2' : i.heading()
}
return items
# Set Heading (both)
def mSetHead(deg):
t.setheading(deg)
i.setheading(-1 * deg)
# Pen Up/Down. (Both)
def mPen(updown):
if updown == "up" :
t.penup()
i.penup()
else :
t.pendown()
i.pendown()
# Set Coordinates for mirror (Both)
def mSetCoord(Xcord, Ycord):
t.setpos(Xcord, Ycord)
i.setpos(Xcord, Ycord)
# Pen Coloring. (Both)
def mColor(color):
t.color(str(color))
i.color(str(color))
# Draw Command for top
def drawBody() :
#DRAWING BOTH ARCHES, TOP/BOTTOM OF BODY
mSetCoord(0,-100)
mColor(main)
mPen("down")
for j in range(71) :
mMovement(2)
mRotate(0.2)
endPointsBottom = mGetPos()
mPen('up')
mSetCoord(0,150)
mPen('down')
mRotate(-14.2)
for j in range(71) :
mMovement(2)
mRotate(-0.2)
endPointsTop = mGetPos()
mPen('up')
#DRAWING HANDLES ON THE BOTTOM
t.goto(endPointsBottom['T1'][0],endPointsBottom['T1'][1])
i.goto(endPointsBottom['T2'][0],endPointsBottom['T2'][1])
mSetHead(90)
mPen('down')
t.right(240)
i.left(240)
for n in range(50):
mMovement(2)
mRotate(-.2)
mSetHead(-60)
mMovement(25)
mSetHead(0)
for n in range(71):
mMovement(2)
if (n > 45):
mRotate(1)
else:
mRotate(0.5)
mRotate(-.5)
#DRAWING SIDES
mSetHead(95)
for n in range(130):
mMovement(2)
if (n > 60):
mRotate(0.02)
else:
mRotate(0.08)
#DRAWING TOP, SMALLER HANDLES
mSetHead(155)
for n in range(50):
mMovement(2)
mRotate(0.4)
mSetHead(250)
mMovement(10)
mSetHead(-19.4)
for n in range(49):
mMovement(2)
mRotate(-.2)
#DRAWING EYES
mPen('up')
t.goto(-50,0)
t.dot(75,"white")
t.goto(50,0)
t.dot(75,"white")
# Draw Command for background and bottom.
def drawBack() :
t.begin_fill()
i.begin_fill()
t.dot(895, back)
mPen("up")
###########################################
# Main Code for Drawing.
###########################################
# Drawing.
drawBack()
drawBody()
t.ht()
i.ht()