LAB 3

 

 

Function:

#Minilab Reflection
#Demetris Roumis
#4/14/07

#reflecting any whole image vertically to get a mirror image.
def mirrorPicture(picture):
...w=getWidth(picture)
...h=getHeight(picture)
...mirror=makeEmptyPicture(w,h)
...for x in range(1,w+1):
......for y in range(1,h+1):
......px = getPixel(picture,x,y)
......newpx = getPixel(mirror,w+1-x,y)
......c = getColor(px)
......setColor(newpx,c)
...show(picture)
...show(mirror)
...return mirror

 

What this function does is retreive the dimensions of the selected picture, create new picture, copy the color of each pixels in the source picture to the target picture with a relation of (width of source picture)+1-(pixel's x coordinate value). Then shows both pictures and returns the mirrored one.