我生成的龟图,并作为我的计划的一部分,我确定从我的图表某些坐标。我希望能够隐藏完整的乌龟窗口,因为我只关心坐标,可能吗?隐藏龟窗口?
编辑:
问题2:
这是不是一个真正的答案,但一些其他问题。
我得到了我的程序工作在一定程度上,如果你在怠速运转和“L”型,它会给你的坐标列表。
import Tkinter
import turtle
from turtle import rt, lt, fd # Right, Left, Forward
size = 10
root = Tkinter.Tk()
root.withdraw()
c = Tkinter.Canvas(master = root)
t = turtle.RawTurtle(c)
t.speed("Fastest")
# List entire coordinates
l = []
def findAndStoreCoords():
x = t.xcor()
y = t.ycor()
x = round(x, 0) # Round x to the nearest integer
y = round(y, 0) # Round y to the nearest integer
# Integrate coordinates into sub-list
l.append([x, y])
def hilbert(level, angle):
if level == 0:
return
t.rt(angle)
hilbert(level - 1, -angle)
t.fd(size)
findAndStoreCoords()
t.lt(angle)
hilbert(level - 1, angle)
t.fd(size)
findAndStoreCoords()
hilbert(level - 1, angle)
t.lt(angle)
t.fd(size)
findAndStoreCoords()
hilbert(level - 1, -angle)
t.rt(angle)
问题是,龟是如此的慢!有没有像龟一样的包,但可以更快地执行命令?
+1。谢谢,这工作完美。 – ElectroNerd