Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Code for transforming pictures


# A template function for transforming pictures
def transformPicture(pic):
  
  allThePixels = getPixels(pic)
  for currentPixel in allThePixels:
    # Do something to currentPixel by replacing line below with something useful
    pass

# This is the above template with the "pass" replaced by a block of three lines
# that darken the current pixel
def darken(pic):
  allThePixels = getPixels(pic)
  for currentPixel in allThePixels:
    setRed(currentPixel, getRed(currentPixel)/2)
    setGreen(currentPixel, getGreen(currentPixel)/2)
    setBlue(currentPixel, getBlue(currentPixel)/2)

# This is the above template with the "pass" replaced by a block of three lines
# flip the values of the current pixel to make a photographic negative
def negate(pic):
  allThePixels = getPixels(pic)
  for currentPixel in allThePixels:
    # Do something to currentPixel
    setRed(currentPixel, 255-getRed(currentPixel))
    setGreen(currentPixel, 255-getGreen(currentPixel))
    setBlue(currentPixel, 255-getBlue(currentPixel))


Links to this Page