Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def swap(A, x, y):
- # @param A: Picture; Need to be squared
- # @param x: Integer; Need to be x<getWidth(A)-1
- # @param y: Integer; Need to be y<getHeight(A)-1
- # @return None: This function work on side effect on the Picture(A)
- w=getWidth(A)
- h=getHeight(A)
- if w!=h:
- print 'ERROR: The selected image should be squared'
- return None
- if x>w:
- print "ERROR: The index column selected isn't compatible, please choose one in range of the width"
- return None
- if y>h:
- print "ERROR: The index row selected isn't compatible, please choose one in range of the height"
- return None
- for i in range(0, h):
- pixCol=getPixel(A, x, i)
- colorCol=getColor(pixCol)
- for j in range(0, w):
- pixRow=getPixel(A, j, y)
- colorRow=getColor(pixRow)
- setColor(pixCol, colorCol)
- setColor(pixRow, colorRow)
- show(A)
- def debuggerSwap(x, y):
- global canv
- canv=makeEmptyPicture(x, y)
- for i in range(0, x):
- for j in range(0, y):
- if i!=50 and j!=100:
- setColor(getPixel(canv, i, j), black)
- elif i==50:
- setColor(getPixel(canv, i, j), white)
- elif j==100:
- setColor(getPixel(canv, i, j), blue)
- return canv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement