Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. def swap(A, x, y):
  2. # @param A: Picture; Need to be squared
  3. # @param x: Integer; Need to be x<getWidth(A)-1
  4. # @param y: Integer; Need to be y<getHeight(A)-1
  5. # @return None: This function work on side effect on the Picture(A)
  6.  
  7.  w=getWidth(A)
  8.  h=getHeight(A)
  9.  if w!=h:
  10.   print 'ERROR: The selected image should be squared'
  11.   return None
  12.  if x>w:
  13.   print "ERROR: The index column selected isn't compatible, please choose one in range of the width"
  14.   return None
  15.  if y>h:
  16.   print "ERROR: The index row selected isn't compatible, please choose one in range of the height"
  17.   return None
  18.  for i in range(0, h):
  19.   pixCol=getPixel(A, x, i)
  20.   colorCol=getColor(pixCol)
  21.   for j in range(0, w):
  22.    pixRow=getPixel(A, j, y)
  23.    colorRow=getColor(pixRow)
  24.    setColor(pixCol, colorCol)
  25.    setColor(pixRow, colorRow)
  26.  
  27.  show(A)
  28.    
  29. def debuggerSwap(x, y):
  30.  
  31.  global canv
  32.  canv=makeEmptyPicture(x, y)
  33.  for i in range(0, x):
  34.   for j in range(0, y):
  35.    if i!=50 and j!=100:
  36.     setColor(getPixel(canv, i, j), black)
  37.    elif i==50:
  38.     setColor(getPixel(canv, i, j), white)
  39.    elif j==100:
  40.     setColor(getPixel(canv, i, j), blue)
  41.  return canv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement