![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
# Open a picture file, showing it before and after some transformation.
def classDemo(fileName):
picture = makePicture(fileName)
show(picture)
transformPicture(picture)
repaint(picture)
# Transform a picture by changing all pixels in some way
def transformPicture(pic):
for pixel in getPixels(pic):
darken(pixel)
def darken(px):
setRed(px, getRed(px) * 0.5)
setGreen(px, getGreen(px) * 0.5)
setBlue(px, getBlue(px) * 0.5)