Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Completare il codice seguente per miscelare progressivamente due immagini;
- # si assuma per semplicitΒ che la seconda immagine abbia dimensioni uguali o
- # maggiori di quelle della prima immagine;
- # i ... indicano la mancanza di una o piu' parti di codice
- def showBlend(pict1, pict2) :
- # @param pict1: Picture
- # @param pict2: Picture;
- canvas = makeEmptyPicture(getWidth(pict1),getHeight(pict1))
- for b in range(0, 100, 10):
- blendPictures(pict1, pict2, b, canvas)
- repaint(canvas)
- def blendPictures(pict1, pict2, b, canvas) :
- # @param ...
- 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 = (b/100.0)*getRed(pix2)+(1-(b/100.0))*getRed(pix1)
- newGreen=(b/100.0)*getGreen(pix2)+(1-(b/100.0))*getGreen(pix1)
- newBlue=(b/100.0)*getBlue(pix2)+(1-(b/100.0))*getBlue(pix1)
- color = makeColor(newRed,newGreen,newBlue)
- setColor(pixCanvas,color)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement