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

Sunset movie

Please read the comments as they explain not just what each function does but why
#A function that makes an entire sunset movie from a starting picture.
def makeSunsetMovie(pic):
  for frameNumber in range(16): # This will make a one-second movie at 16 f.p.s. So change this to (e.g.) 96 for a six-second movie.
    makeSunsetPicture(pic, 0.95) # 0.95 is the amount of reddening. To make the effect more gradual, make this approach 1.0
    writeFrame(pic, frameNumber)

# A function that makes a picture more like a sunset view by adjusting its color balance.
# This function has no idea that it is being used in a movie making production.
def makeSunsetPicture(picture, factor):
  reduceGreen(picture, factor)
  reduceBlue(picture, factor)

# A function that adjusts the green in a picture by a given amount.
# It has nothing to do with adjusting the blue (and therefore the redness) and could be used in completely
# different contexts -- e.g. to compensate for fluorescent lighting, which makes people's skin green.
def reduceGreen(picture, amt):
  for p in getPixels(picture):
    setGreen(p, getGreen(p)*amt)

# A function that adjusts the blue in a picture by a given amount.
# This is independent of everything else
def reduceBlue(picture, amt):
  for p in getPixels(picture):
    setBlue(p, getBlue(p)*amt)

# This function writes a picture to a file with a formatted name, including an embedded number.
# Thus writeFrame(pic, 19) will write pic to "sunset19.jpg"
# Other than having "frame" in its name, this function is nothing to do with movies. It just writes
# a single file in a given place.
def writeFrame(pic, fn):
  numerals = str(fn) # Remember that a number and its text representation are different data
  if fn < 10:
    numerals = "0" + numerals #We have to add a leading zero so that file names are correctly sorted
  fileName = "sunset" + numerals + ".jpg"
  writePictureTo(pic, getMediaPath(fileName))


Links to this Page