What I want to do is very simple in principle (if at all possible with pyton turtle). I want to draw a square and make the turtle stay inside the square when it gets to the line without explicitly giving coordinates when to turn. Instead of
if t.xcor() >= 300 or t.xcor() <= -300:
t.dx *= -1
write a program to assess the underlying pixel color and stop/turn at line...
import turtle
win = turtle.Screen()
win.setup(600,600)
win.tracer(0)
t = turtle.Turtle()
t.shape('circle')
t.pensize(10)
t.up()
t.fd(200)
t.down()
t.lt(90)
t.fd(200)
for i in range(3):
t.lt(90)
t.fd(400)
t.lt(90)
t.fd(200)
t.up()
t.goto(0,0)
t.color('red')
t.dx = 1
t.dy = 1
while True:
win.update()
t.goto(t.xcor()+t.dx, t.ycor()+t.dy)
#### Stop/change direction/follow line when pixel.color.whatever = 'black'