Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ribaltamentoOrizzontale(pict):
- #@param pict: Picture
- w,h = getWidth(pict), getHeight(pict)
- #creo un'immagine vuota per poi renderla identica a pict
- newPict = makeEmptyPicture(w,h)
- for y in range(h):
- for x in range(w):
- color = getColor(getPixel(pict,x,y))
- setColor(getPixel(newPict,x,y),color)
- mirrorPoint = w/2
- for j in range(h):
- for i in range(mirrorPoint):
- leftP = getPixel(newPict,i,j) # pixel attuale
- rightP = getPixel(newPict,(w-i-1),j) # pixel specchiato
- #swap tra pixel: attraverso lo scambio dei colori
- colorL,colorR = getColor(leftP),getColor(rightP)
- setColor(rightP, colorL)
- setColor(leftP, colorR)
- show(newPict)
- def ribaltamentoVerticale(pict):
- #@param pict: Picture
- w,h = getWidth(pict), getHeight(pict)
- #creo un'immagine vuota per poi renderla identica a pict
- newPict = makeEmptyPicture(w,h)
- for y in range(h):
- for x in range(w):
- color = getColor(getPixel(pict,x,y))
- setColor(getPixel(newPict,x,y),color)
- mirrorPoint = h/2
- for i in range(w):
- for j in range(mirrorPoint):
- leftP = getPixel(newPict,i,j) # pixel attuale
- rightP = getPixel(newPict,i,(h-j-1)) # pixel specchiato
- #swap tra pixel: attraverso lo scambio dei colori
- colorL,colorR = getColor(leftP),getColor(rightP)
- setColor(rightP, colorL)
- setColor(leftP, colorR)
- show(newPict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement