我正在尝试将我之前制作的Julia集生成器转换为Python代码。但是,当代码运行时,turtle图形窗口会立即停止响应,并且不会绘制任何内容。我做了什么可怕的错误,还是我遗漏了什么?也许我对python的要求太高了,不能在1帧内完成。请解释是什么导致了这种情况,以及我如何解决它。谢谢!在import turtle
import time
y_set = []
map_output = 0
iterations = 0
#turtle.hideturtle()
#turtle.speed(1)
生成y值列表
^{pr2}$
创建颜色值def color (i, n):
output = map(i, 2, 10000, 0, 2500)
if output < 0:
output = 0
if output > 0:
output = 255
在x上迭代def repeat (n, r, i):
global iterations
global x
global y
aa = 0
ba = 0
ab = 0
a = 0
b = 0
for j in range (n):
iterations += 1
aa = a * a
bb = b * b
ab = 2 * a * b
a = ((aa - bb) + float(r))
b = (ab + float(i))
if (ab + bb) > 4:
break
turtle.setx(100 * x)
turtle.sety(100 * y)
color(iterations, n)
turtle.pendown()
turtle.penup()
在y上迭代def Julia (s, r, i, d):
global iterations
global y_set
global x
global y
global a
global b
y_set(s)
while len(y_set) > 0:
y = y_set[0]/360
del y_set[0]
x = -1.5
for n in range (round((700/(float(r)+1))+1)):
a = x
b = y
iterations = 0
repeat(10**d, r, i)
x += ((1/240)*s)
用户输入real = input('Real: ')
imag = input('Imaginary: ')
Julia (1, real, imag, 100)
turtle.done()