Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pict = makePicture(pickAFile())
- width = getWidth(pict)
- height = getHeight(pict)
- newPict = makeEmptyPicture(width,height)
- def alternateColumns(w,pict,newPict):
- #@param:
- # w: int, column width, must be a divisor of width;
- # pict: picture;
- # newPict: an empty picture that has the same size of "pict";
- for i in range(0,width,width/(width/(2*w))):
- moveColumnFromAToB(i,w)
- moveColumnFromBToA(i,w)
- show(newPict)
- def moveColumnFromAToB(i,w):
- #@param:
- # i: int; first pixel on the x axis
- # w: int, column width, must be a multiple of width;
- for y in range(0,height):
- for x in range(i,i+w):
- pix = getPixel(pict,min(width-1,x),y)
- nPix = getPixel(newPict,min(width-1,x+w),y)
- nc = getColor(nPix)
- c = getColor(pix)
- setColor(nPix,c)
- def moveColumnFromBToA(i,w):
- #@param:
- # i: int; first pixel on the x axis
- # w: int, column width, must be a multiple of width;
- for y in range(0,height):
- for x in range(i+w,i+2*w):
- pix = getPixel(pict,min(width-1,x),y)
- nPix = getPixel(newPict,min(width-w,x-w),y)
- nc = getColor(nPix)
- c = getColor(pix)
- setColor(nPix,c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement