## Now trace this series of who built on who’s work.•

Now trace this series of who built on who’s work.

• Who invented the laser printer?

• One of the winners of the ACM Turing Award (the closest that computer science has to a Nobel Prize) invented a computer system for typesetting books on a laser printer. Who was that?

• The winner of a recent ACM Turing Award built a computer system on top of the last typesetting system, to make it easier to use (but that’s not what he won the TuringAward for).Who was that, and what did he win his award for?

## Write a function to create a lightened grayscale image, by

Write a function to create a lightened grayscale image, by use makeLighter. First, lighten the image by using the makeLighter function on each color. Now, grayscale the new image. Compare the result to the picture created by the previous problem. How does makeLighter compare to adding 75 to each of the red, green, and blue components of every pixel?

Data from Previous Problem

Write a function to create a lightened grayscale image. First, lighten the image by adding 75 to the red, green, and blue components of every pixel. Since higher numbers are closer to white, this should make the pixel lighter. Now, grayscale the new image.

## The buildCipher function could create more complicated alphabets. As long

The buildCipher function could create more complicated alphabets. As long as both the receiver and the sender generate the alphabet in the same way, the message needs to only include the keyword for encoding and decoding to work. Try building these variations:

• Put the keyword at the end of the alphabet, rather than the front.

• Reverse the alphabet before concatenating it to the keyword.

• Separate the vowels and the consonants in the rest of the alphabet so that the cipher alphabet is keyword, then the rest of the vowels, then the rest of the consonants.

## Try doing chromakey in a range. The picture “statue-tower.jpg” has

Try doing chromakey in a range. The picture “statue-tower.jpg” has a blue, but not blue enough background to work with chromakeyBlue. However, if you change the rule to getRed(px) + getGreen(px) < getBlue(px)+100, it works great for the sky—but messes up near the ground.

• Change chromakeyBlue to use the modified rule, and apply it to “statuetower. jpg.”

• Now, write chromakeyBlueAbove to take in an input picture, a new background, and a number. The number is a y value, and you should only do chromakey to pixels above that input y. Apply it to “statue-tower.jpg” so that the blue of the sky gets changed to the moon or the jungle, but the area near the ground is not touched.

## Write a function named makeCollage to create a collage of

Write a function named makeCollage to create a collage of the same image at least four times fit onto the 7in.x95in.jpg blank JPEG. (You are welcome to add additional images.) One of those four copies can be the original picture. The other three should be modified forms. You can scale, crop, or rotate the image, create a negative of the image, shift or alter colors on the image, and make it darker or lighter.

After composing your image, mirror it. You can do this vertically or horizontally (or otherwise), in any direction—just make sure that your four base images are still visible after mirroring.

Your single function should make all of this happen—all of the effects and compositing must occur from the single function makeCollage. Of course, it is perfectly okay to use other functions, but make it so that a tester of your program need only call setMediaPath(), put all your input pictures in a mediasources directory, and then execute makeCollage() in order to see a collage generated, shown, and returned.

## A source of possible error in this adventure game is

A source of possible error in this adventure game is that the names for the rooms appear in several places. If the Dining Room is spelled “DiningRoom” in one place and “DinngRoom” (missing the second “i”) in another place, the game won’t work correctly. The more rooms you add, and the more places where you have the room names typed, the odds increase that the error will be made.

There are a couple of ways of making this error less likely to occur:

• Do not name the rooms with strings of characters. Instead, use numbers. It’s easier to type and check “4” than “DiningRoom.”

• Use a variable for DiningRoom and use that one variable for checking the location. Then it doesn’t matter if you’re using numbers or strings (and strings are much easier to read and understand).

Use one of these techniques to rewrite the adventure game with fewer potential errors.

## The function printNow is not the only way to present

The function printNow is not the only way to present information to the user during the running of a program. We might also use the function showInformation which takes a string as input, then displays it in a dialog box. Currently, our showRoom subfunctions presume that we will display the room information via printNow. If functions like showPorch returned a string with the description, then the function showRoom could either use printNow to display the room description or showInformation.

Rewrite the room showing functions to return a string, then modify showRoom to easily change between printing the room information and showing it in a dialog box.

## Typically, one does not optimize a program (make it run

Typically, one does not optimize a program (make it run faster or with less use of memory) until after it is running, well-debugged, and well-tested. (Of course, you still have to test again after each optimizing modification.) Here is an optimization that we could make to the adventure game. Currently, showRoom compares the room variable to each possible room—even if it matched earlier. Python gives us a way of only testing once, by using an elif instead of later if statements. The statement elif means “else if.” You only test the elif statement if the earlier if was false. You may have as many elif statements as you like after an if. You might use it like this:

Rewrite the showRoom method more optimally by using elif.

## Given a folder with images in it, create an index

Given a folder with images in it, create an index HTML page with links to each image. Write a function that takes a string which is the path to a directory. You will create a page in the folder named index.html that should be an HTML page containing a link to every JPEG file in the directory.

You will also generate a thumbnail (half the size) copy of each image. Use makeEmptyPicture to create a blank picture of the right size, then scale down the original picture into the blank picture. Name the new image “half-” + the original filename (e.g., if the original filename was fred.jpg, save the half-size image as half-fred.jpg). The anchor in the link to each full-size picture should be the half-size image.

## If you erase lower two bits in the red value,

If you erase lower two bits in the red value, you can clear space for hiding values 0–4.

for p in getPixels(picture):
# Clear out the red 2xLSB
r = getRed(p)
setRed(p,r-(r%4))

If you erase the lower two bits from red, green, and blue, you can save six bits. Six bits can encode 64 values. That’s enough to encode all 27 letters, both upper and lowercase.

(a) Write a function to input a picture and a string. Save each character in the string in a pixel of the picture, by saving it across the least significant two bits in each of red, green, and blue. Can you tell the difference between the original picture and the picture with the encoded text message?

(b) Now write a function to decode the original text.