def flipAlongDiagonal(): # Set up the source and target pictures file = pickAFile() pict = makePicture(file) wid = getWidth (pict) hgt = getHeight (pict) canvas = makeEmptyPicture(hgt, wid) # Now, do the actual copying--swap X & Y! targetX = 1 for sourceX in range(1,getWidth(pict)): targetY = 1 for sourceY in range(1,getHeight(pict)): color = getColor(getPixel(pict,sourceX,sourceY)) setColor(getPixel(canvas, targetY, targetX), color) targetY = targetY + 1 targetX = targetX + 1 show(pict) show(canvas) return canvas def rotate90(): # Set up the source and target pictures file = pickAFile() pict = makePicture(file) wid = getWidth (pict) hgt = getHeight (pict) canvas = makeEmptyPicture(hgt, wid) # Now, do the actual copying--swap X & Y! targetX = 1 for sourceX in range(1,getWidth(pict)): targetY = 1 for sourceY in range(1,getHeight(pict)): color = getColor(getPixel(pict,sourceX,sourceY)) setColor(getPixel(canvas, targetY, wid - targetX), color) targetY = targetY + 1 targetX = targetX + 1 show(pict) show(canvas) return canvas