The traffic sign for intersection created with overlapping squares and an x. The overlapping squares produce a black lining near the edges while the x, in proper rotation, represents crossed roads. The simple Python Turtle code is made shorter by the use of loops and definitions..
Feel free to copy the basic Python Turtle code that is given below. Don't hesitate to ask questions about the code if you have any. Enjoy! Please comment, like, or subscribe :)
Incidentally, for manually colorable graphics and variations, please visit my author url at https://www.amazon.com/author/basicpy...
import turtle
t = turtle.Turtle() #Definitions and Initializations
screen = turtle.Screen()
t.pensize(4)
sign_size = square_size = 350 #Changeable; Length of one side of square; square_size -- decreasing values
def square(color, square_size): #Procedure to draw a square with algorithm-assigned color and size
t.fillcolor(color) #Start of color-filling procedure for one square
t.begin_fill()
for i in range(4): #Loop to draw 4 sides of a square
t.forward(square_size)
t.left(90)
t.end_fill()
def intersection(): #Procedure to draw an x or intersection sign
t.fillcolor("black") #Start of color-filling procedure to make intersection sign "black"
t.begin_fill()
for i in range(4): #Loop to draw 4 edges of intersection sign
t.forward((0.5 /6) * square_size)
t.left(90)
t.forward((2 / 6) * square_size)
t.right(90)
t.forward((2 / 6) * square_size)
t.left(90)
t.forward((0.5 / 6) * square_size)
t.end_fill()
t.penup() #Python_Graphic start of drawing procedure
t.forward(sign_size / (2 ** 0.5))
for color in ["yellow", "black", "yellow"]: #Loop to draw 3 differently-sized and overlapping squares with indicated colors
t.left(135)
t.pendown()
t.pencolor(color)
square(color, square_size) #Function call to draw a square with algoritm-assigned color and size
square_size -= (1 / 25) * sign_size #Change in size for next square
t.penup()
t.home()
t.forward(square_size / (2 ** 0.5))
t.penup()
t.home()
t.forward((2.5 / 6) * square_size)
t.left(90)
t.pendown()
t.pencolor("black")
intersection() #Function call to draw an x or intersection sign
t.hideturtle()
screen.exitonclick()