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

# Take a picture and make it gradually appear warmer/darker, simulating sunset
# This takes a long while to run
def makeSunsetMovie(pic):

  for frameNumber in range(100): # 100 frames from 00 to 99

    # A progress report to reassure us that the program really is working
    printNow("Working on frame number " + str(frameNumber) + " of 100.")

    # Make the frame warmer by a very small amount
    # Since we are not copying the picture afresh for each frame, these color shifts
    # will accumulate from frame to frame
    amt = 0.99 # Experiment with this. Smaller number will make sunset happen faster
    for p in getPixels(pic):
      setGreen(p, getGreen(p)*amt)
      setBlue(p, getBlue(p)*amt)  

    # Write color-shifted picture as a frame for the movie
    numerals = str(frameNumber)
    if frameNumber < 10:
      numerals = "0" + numerals
    fileName = "sunset" + numerals + ".jpg"
    writePictureTo(pic, getMediaPath(fileName))



Link to this Page