Advertisement
davide1409

ribaltamento verticale(ribV) ed orizzontale(ribH)

Oct 21st, 2019
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. def ribV(pict):
  2. #@param pict: Picture
  3.   allPix = getPixels(pict) # prendo tutti i pixel
  4.   w,h = getWidth(pict), getHeight(pict)
  5.   mirrorPoint = w/2
  6.   for j in range(h):
  7.     for i in range(mirrorPoint):
  8.       leftP = getPixel(pict,i,j) # pixel attuale
  9.       rightP = getPixel(pict,(w-i-1),j) # pixel specchiato
  10.       #swap tra pixel: attraverso lo scambio dei colori
  11.       colorL,colorR = getColor(leftP),getColor(rightP)
  12.       setColor(rightP, colorL)
  13.       setColor(leftP, colorR)
  14.      
  15.   show(pict)
  16.  
  17. def ribH(pict):
  18. #@param pict: Picture
  19.   allPix = getPixels(pict) # prendo tutti i pixel
  20.   w,h = getWidth(pict), getHeight(pict)
  21.   mirrorPoint = h/2
  22.   for i in range(w):
  23.     for j in range(mirrorPoint):
  24.       leftP = getPixel(pict,i,j) # pixel attuale
  25.       rightP = getPixel(pict,i,(h-j-1)) # pixel specchiato
  26.       #swap tra pixel: attraverso lo scambio dei colori
  27.       colorL,colorR = getColor(leftP),getColor(rightP)
  28.       setColor(rightP, colorL)
  29.       setColor(leftP, colorR)
  30.      
  31.   show(pict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement