def vertical_reflection_GUI (label): '''Implement the function vertical_reflection from img_manip.''' #Clear all the temp pics in front of the current pic current_pic global temp_label global current_pic temp_label = temp_label[0:current_pic+1] #Implement the function vertical_reflection. label.picture = img_manip.vertical_reflection(label.picture) #Keep a copy of the current pic for the functions Undo and Redo temp_label.append(label.picture) current_pic += 1 #update the label update_label(label)
def test_vertical_reflection(): '''Test the function vertical_reflection in img_manip.''' new_pic = create_pic(4, 4) new_pic_reflected = img_manip.vertical_reflection(new_pic) #Test if the colour of each pixel in new_pic_vertical_reflection is equal to #the colour of the corresponding pixel in new_pic. If not, the boolean #reflected is made False. reflected= True width = media.get_width(new_pic) height = media.get_height(new_pic) for x in range(width): for y in range(height): pix1 = media.get_pixel(new_pic, x, y) pix2 = media.get_pixel(new_pic_reflected, x, height - y - 1) col1 = media.get_color(pix1) col2 = media.get_color(pix2) if col1 != col2: reflected = False assert reflected, \ "vertical_reflection failed to reflect the image vertically."