An attempt to draw the Recycle symbol using Python Turtle. Whew! The code is unexpectedly long, perhaps due to arrow details and alignment. You can make the code shorter and even enhance the resulting graphic with arrow folds. Try it! Let me know of your attempts. :)
Feel free to copy the basic Python Turtle code that is given below. Don't hesitate to write comments or ask questions about the code if you have any. Enjoy! Please comment, like, or subscribe :)
import turtle
t = turtle.Turtle() #Definitions and Initializationa
screen = turtle.Screen()
triangle_side_length = 700 #Changeable; Side length of triangle which encased symbol
triangle_height = triangle_side_length / (3 ** (1/2)) #Height derived from 30-60-90 triangle side proportion
center = (0, -(1 / 16) * triangle_height) #Center of final graphic
counter = 1 #Needed to create the triangular band: big green minus small white
def triangle(length): #Creation of big green triangle minus small white one; "length" is
t.forward(length / 2) #assigned longer triangle side first then shorter one in code
t.right(120) #below
for i in range(2):
t.forward(length)
t.right(120)
t.forward(length / 2)
def triangle_corner(): #Deletion of smaller triangular corner
t.fillcolor("white")
t.begin_fill()
for i in range(3):
t.forward(triangle_side_length / (3 ** (1 / 2)))
t.right(120)
t.end_fill()
def gap(): #Cutting out of inter-arrow gap
t.fillcolor("white")
t.begin_fill()
t.forward((5 / 9) * triangle_side_length / (2 * 3 ** (1 / 2)))
t.pencolor("white")
t.left(90)
t.forward((1 / 9) * triangle_side_length)
t.left(90)
t.forward((5 / 9) * triangle_side_length / (2 * 3 ** (1 / 2)))
t.left(90)
t.forward((1 / 9) * triangle_side_length)
t.end_fill()
def arrow_head(): #Drawing steps for arrow head
t.fillcolor("green")
t.begin_fill()
t.forward((1 / 6) * triangle_side_length)
t.left(150)
t.forward((1 / 6) * triangle_side_length * (3 ** (1 / 2)))
t.left(150)
t.forward((1 / 6) * triangle_side_length)
t.end_fill()
for length in [triangle_side_length, (4 / 9) * triangle_side_length]:
t.penup() #Python_Graphic start of drawing procedure; Note the two values
t.goto(center) #assigned for "length"
t.setheading(30)
t.forward(length / (2 * 3 ** (1 / 2)))
t.right(90)
t.pendown()
if counter == (1): #Use of counter = 1 for bigger green triangle
t.pencolor("green")
t.fillcolor("green")
t.begin_fill()
triangle(length)
t.end_fill()
counter = 2
else: #Use of another counter value for smaller white triangle
t.pencolor("white")
t.fillcolor("white")
t.begin_fill()
triangle(length)
t.end_fill()
t.penup() #Start of cutting three corner triangles away
t.pensize(2)
for i in range(3):
t.goto(center)
t.setheading(-30 + i * 120)
t.forward((1/2) * triangle_side_length * 3 ** (1 / 2))
t.right(150)
t.pendown
triangle_corner()
t.penup()
t.penup() #Start of cutting 3 inter-arrow gaps away
for i in range(3):
t.goto(center)
t.setheading(-90 - i * 120)
t.forward((2 / 9) * triangle_side_length / (3 ** (1 / 2)))
t.right(90)
t.forward((1/20) * triangle_side_length)
t.left(90)
t.pendown()
gap()
t.penup()
t.pencolor("green") #Start of drawing arrow heads
for i in range(3):
t.penup()
t.goto(center)
t.setheading(-90 - i * 120)
t.forward((13 / 36) * triangle_side_length / (3 ** (1/2)))
t.left(30)
t.pendown()
arrow_head()
t.hideturtle()
screen.exitonclick()