Hello, The following code works well but I don't understand why the mysteryEffect code block changes the picture. Doesn’t 64*(r/64) just equal r? (Same with g and b.) So this function should not change the picture at all. But it does! If anyone can explain how and why this actually changes the picture I would appreciate it greatly.
#Creates, duplicates and shows the pic def main(): pic1= makePicture( pickAFile() ) pic2= duplicatePicture( pic1) fadeDownFromBlack( pic1 ) show( pic1 ) mysteryEffect( pic2 ) show( pic2 ) #Does a 50% fade of the upper half of the picture def fadeDownFromBlack( pic1 ): w=getWidth(pic1) h=getHeight(pic1) for y in range(0,h/2): for x in range(0,w): px= getPixel( pic1, x, y ) setRed(px,y*(2.0/h)*getRed(px)) setGreen(px,y*(2.0/h)*getGreen(px)) setBlue(px,y*(2.0/h)*getBlue(px)) repaint( pic1 ) #Adds a rainbow effect to the picture def mysteryEffect( pic2 ): for px in getPixels( pic2 ): r= getRed ( px ) g= getGreen( px ) b= getBlue( px ) setRed( px, 64*(r/64)) setGreen( px, 64*(g/64)) setBlue( px, 64*(b/64)) repaint( pic2 ) Thanks, Joe
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor