''' Purpose: support image mirroring transformation ''' # This one doesn't change the color of an image! # It changes the spots! def size( original ) : ''' Purpose: return the size of the new image when performing a mirroring ''' nw, nh = original.size return (nw, nh) def color( opixel ) : ''' Purpose: return the new pixel when performing a mirroring transformation ''' npixel = opixel return npixel # The dimensions and the colors stay the same. The SPOTS are changed. def where( nspot, original ) : ''' Purpose: return the correspondent of nspot in the original when doing a mirroring ''' w, h = original.size nx, ny = nspot # Extract the x,y from the spot ox = ( w-1 ) - nx # Different x distance across oy = ny # Same y distance down ospot = ( ox, oy ) # Return an altered spot return ospot pass if ( __name__ == '__main__' ) : import url from manip import manip # get web image of interest link = "http://www.cs.virginia.edu/~cs1112/images/mandrill/full.png" original = url.get_image( link ) new_image = manip( original, size, color, where ) new_image.show()