Just started learning python. I am trying to draw this pattern by the turtle module, not only this one but I am also having trouble when applying loops to draw any kind of patterns (especially when it comes to patterns with different shapes lying inside each other, I just simply do not know where to start and how to organize the functions to draw those kinds of complex patterns like that). Therefore, I usually go step by step knowing that there should be a loop to make the turtle do the same thing all over again. Anyway here is the pattern I'm trying to draw: pattern And here is what I have so far:
import turtle
wn = turtle.Screen()
t = turtle.Turtle()
def pattern(t,clr):
t.screen.bgcolor("white")
t.pensize(10)
for i in range(2):
t.pd()
t.fd(100) ##
t.rt(90)
t.fd(100) ##
t.rt(90)
t.fd(90) ##
t.rt(90)
t.fd(75) ##
t.rt(90)
t.fd(70) ##
t.rt(90)
t.fd(38) ##
t.rt(90)
t.fd(38) ##
t.pu()
t.lt(90)
t.fd(77)
t.pd()
t.lt(90)
t.fd(38)
t.rt(90)
t.fd(38)
t.rt(90)
t.fd(70)
t.rt(90)
t.fd(75)
t.rt(90)
t.fd(90)
t.rt(90)
t.fd(100)
t.rt(90)
t.fd(100)
pattern(t,"black")
Any tips and advices would be much appreciated! Thank you!
Aucun commentaire:
Enregistrer un commentaire