I need to make a function that will copy an image, but mirrored. I created the code to mirror the image, but it isn't working and I don't know why because I traced the code and it should be mirroring the image. Here's the code:
def invert(picture):
width = getWidth(picture)
height = getHeight(picture)
for y in range(0, height):
for x in range(0, width):
sourcePixel = getPixel(picture, x, y)
targetPixel = getPixel(picture, width - x - 1, height - y - 1)
color = getColor(sourcePixel)
setColor(sourcePixel, getColor(targetPixel))
setColor(targetPixel, color)
show(picture)
return picture
def main():
file = pickAFile()
picture = makePicture(file)
newPicture = invert(picture)
show(newPicture)
Can someone explain to me what is wrong? Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…