Mini-Lab: Reflecting Pictures



The objectives of this lab are to become more familiar with JES, to understand and modify more complex programs (which may include if statements, nested loops, functions, etc.), and to do more complicated image manipulations.


In this mini-lab, we will be writing a function that reflects an entire image. In our function, we will create a new picture to hold the reflected image.

  1. Write a verticalReflection function that creates a vertical reflection of a picture. It should take a picture as a parameter, and return a new picture of the same size reflected vertically around the right edge. This means that the picture should appear in the new picture as it would if you held the original up to a mirror.  Here are some hints, assuming that the dimensions of the original picture are width and height:
    Design Questions: Focusing on rows first, for any particular pixel (x, y), what should be the y-coordinate of the corresponding pixel in the new, reflected picture? Next, let's focus on the x-coordinates: what should be the x-coordinate of the corresponding pixel in the new, reflected picture?
  2. Make sure you have added appropriate comments for your function.

  3. Test your new function with various pictures. Use the writePictureTo function to save one reflected image, and if necessary, the original image, in your CS107 folder.

Submit your results

  1. Submit the file you created in this mini-lab via .

Post your results

  1. Create a new web page to display your reflected image, along with its original version.
  2. Copy this new web page and the images that should be on it to your personal web space on (You may want to review the instructions in Lab 1 if you've forgotten how to do this.)
  3. Include a link to your new web page from your course page. Bring up your course page in a web browser and test your link.