Clone a turtle


y = t.clone()


examples/turtle/star.py
import turtle

# based on the example in the documentation

t = turtle.getturtle()
t.color('red', 'yellow')
t.begin_fill()
while True:
    t.forward(100)
    t.left(190)
    if abs(t.pos()) < 1:
        break
t.end_fill()

turtle.exitonclick()

examples/turtle/many_shapes.py
import turtle

t = turtle.getturtle()

while True:
    res = turtle.numinput("Angles?", "How many angles?", default=3, minval=3, maxval = 180)
    if res is None:
        break
    t.clear()
    print(res)
    t.circle(100, steps=int(res))

examples/turtle/numinput_select_shape.py
import turtle

t = turtle.getturtle()

res = turtle.numinput("Angles?", "How many angles?", default=3, minval=3, maxval = 180)
print(res)
t.circle(100, steps=int(res))

turtle.exitonclick()

examples/turtle/onclick_shapes.py
import turtle
import time

s = turtle.getscreen()
t = turtle.getturtle()

#s.onclick(lambda x, y: t.left(10) )
s.onclick(lambda x, y: print(x, y) )

#s.mainloop()

while True:
    t.forward(1)
    #time.sleep(0.1)

examples/turtle/textinput_select_shape.py
import turtle

t = turtle.getturtle()

res = turtle.textinput("Shape?", "Which shape shall I draw? rectangle or triangle ?")
print(res)
if res == 'triangle':
    t.circle(100, steps=3)
elif res == 'rectangle':
    t.circle(100, steps=4)
else:
    pass
    

turtle.exitonclick()