示例#1
0
def rotate_right_GUI (label, degrees):
    '''Implement the appropriate rotate right function (90/180/270 degreees  
    depending on uesr's choice) 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]
    #Rotage the image to the right 90, 180 or 270 degrees.
    if degrees == '90':
        label.picture = img_manip.rotate_left270_right90(label.picture)
    elif degrees == '180':
        label.picture = img_manip.rotate_left180_right180(label.picture)
    elif degrees == '270':
        label.picture = img_manip.rotate_left90_right270(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)
示例#2
0
def test_rotate_left180_right180():
    '''Test the function rotate_left180_right180 in img_manip.'''
    
    new_pic = create_pic(4, 4)
    new_pic_rotated = img_manip.rotate_left180_right180(new_pic)
    
    #Test if the colour of each pixel in new_pic is equal to the colour of the
    #corresponding pixel in new_pic_rotated. If not, the boolean rotated is
    #made False.
    rotated = True
    for x in range(4):
        for y in range(4):
	    new_pic_pix = media.get_pixel(new_pic, x, y)
	    new_pic_rotated_pix = media.get_pixel(new_pic_rotated, 3 - x, 3 - y)
	    col1 = media.get_color(new_pic_pix)
	    col2 = media.get_color(new_pic_rotated_pix)
            if col1 != col2:
		rotated = False

    assert rotated, \
           "rotate_left180_right180 failed to rotate the picture correctly."