我不知道如何使用while
循环扫描所有像素。
我可以用for
循环来做到这一点,但是如何只使用 while 循环来做到这一点?
for x in range(0,width):
for y in range(0,height):
px = getPixels(pic,x,y)
___________________________
def question410():
pic = makePicture(getMediaPath("barbara.jpg"))
width = getWidth(pic)
height = getHeight(pic)
canvas = makeEmptyPicture(width,height)
explore(pic)
scale = 2
x = 0
y = 0
while x < width:
while y < height:
px = getPixel(pic,x,y)
colour = getColor(px)
tgtPx = getPixel(canvas,x,y)
setColor(tgtPx,colour)
x=x+1
y=y+1
print x, y
explore(canvas)