此代码运行时没有错误并返回一个空白图像,打印颜色和coord的显示数字有意义,但由于某种原因似乎没有写入任何内容。 希望有人会看到我不喜欢的东西:
import math
def fisheye():
file = pickAFile()
pic = makePicture(file)
h = getHeight(pic)
w = getWidth(pic)
maxradius = sqrt(w**2 + h**2)/2
fisheye = makeEmptyPicture(int(w+maxradius), int(h+maxradius),white)
for x in range(0,w):
for y in range(0,h):
nyS = ( (2*x)/h ) - 1
nxS = ( (2*y)/w ) - 1
r = sqrt( nxS**2 + nyS**2 )
if( r >= 0.0 and r <= 1.0 ):
nr = (r + (1.0-r)) / 2.0
if( nr <= 1.0 ):
t = math.atan2(nyS,nxS)
nx = nr*cos(t)
ny = nr*sin(t)
x2 = (((nx+1)*w)/2.0)
y2 = (((ny+1)*h)/2.0)
color = getColor(getPixel(pic, x, y))
print max(color)
setColor( getPixel(pic, int(x2),int(y2)) , color)
explore(fisheye)
答案 0 :(得分:0)
问题似乎是您致电setColor()
。在此声明中,您还可以致电getPixel()
,引用pic
而非fisheye
。
请将此声明更改为以下内容:
setColor( getPixel(fisheye, int(x2),int(y2)) , colour)