Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def mixer(p1, p2) :
- # @param p1: Picture
- # @param p2: Picture;
- canvas = makeEmptyPicture(getWidth(p1),getHeight(p1))
- for b in range(0, 101, 5):
- blendPictures(p1, p2, b, canvas)
- repaint(canvas)
- def blendPictures(pict1,pict2,blendFactor,canvas) :
- # @param pict1: Picture
- # @param pict2: Picture
- # @param blendFactor: int
- # @param canvas: Picture
- for x in range(0, getWidth(pict1)) :
- for y in range(0,getHeight(pict1)):
- pix1 = getPixel(pict1, x, y)
- pix2 = getPixel(pict2, x, y)
- pixCanvas = getPixel(canvas,x,y)
- newRed = (blendFactor/100.0)*getRed(pix1)+(1-(blendFactor/100.0))*getRed(pix2)
- newGreen = (blendFactor/100.0)*getGreen(pix1)+(1-(blendFactor/100.0))*getGreen(pix2)
- newBlue = (blendFactor/100.0)*getBlue(pix1)+(1-(blendFactor/100.0))*getBlue(pix2)
- color = makeColor(newRed,newGreen,newBlue)
- setColor(pixCanvas,color)
Add Comment
Please, Sign In to add comment