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 PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

purpleRinse.py

def classDemo(fileName):
  picture = makePicture(fileName)
  show(picture)
  manipulate(picture)
  repaint(picture)

def manipulate(image):
  for pix in getPixels(image):
    purpleRinse2(pix)

# Hand-coded version without the distance function, which was incorrect in first version of JES
# made available for download.
def purpleRinse1(pixel):
  hairRed = 161
  hairGreen = 137
  hairBlue = 125
  r = getRed(pixel)
  g = getGreen(pixel)
  b = getBlue(pixel)
  if (abs(r-hairRed) < 10 and abs(b-hairBlue) < 10 and abs(g-hairGreen) < 10):
    setRed(pixel, r*1.5)
    setBlue(pixel, b* 2)

# Better solution, using built-in distance function. This works with the latest version
# of JES available on the downloads page.
def purpleRinse2(pixel):
  hairColor = makeColor(161, 137, 125)
  pixelColor = getColor(pixel)
  if distance(hairColor, pixelColor) < 10:
    setRed(pixel, getRed(pixel) *1.5)
    setBlue(pixel, getBlue(pixel)* 2)


Link to this Page