Make sure review the four homework assignments, all of the labs we've done, and the examples we've written in class. Alos, I may ask some questions from Exam 1.
makeBlurry
that animates filling in a picture with random colors at random locations within the picture.
Have the user pass in as a parameter how many random pixel changes they want to make. Repainting after every pixel change is slow, so have your method repaint every tenth pixel to speed things up (don't use Util.sleep
,
that will really slow it down). For example the call, in my solution, the code
below results int the blurry bug by randomly modifying pixels 150,000 times.
String path = "T:/Harcourt/Fall2008/CS140/gallery/"; Picture pic1 = new Picture(path + "bug.jpg"); pic1.makeBlurry(150000);
flipHorizontal
that flips a picture horizontally.
For example, here is the bug flipped horizontally. (Contrast this with the original.)
rotateLeft
that rotates a picture
ninety degrees counter clockwise.
For example, here is the bug rotated left. (Contrast this with the original)
morph
that changes a picture into another picture from
the top down. For example, assuming pic1
and pic2
are the same exact dimensions
pic1.morph(pic2);will change
pic1
into pic2
row by row starting at the
top.
Picture.java
file and work properly so you can use them.
Here's my sample main program for the study guide methods (except for the first program that simulates rolling a die.
public class Exam2StudyGuide { public static void main(String [] args) throws Exception { String path = "T:/Harcourt/Fall2008/CS140/gallery/"; Picture pic = new Picture(path + "bug.jpg"); Picture pic1 = new Picture(path + "colors_small.jpg"); Picture pic2 = new Picture(path + "mutant_lemon_small.jpg"); pic.flipHorizontal().repaint(); pic.makeBlurry(100000); pic.flipHorizontal().repaint(); pic.rotateLeft().repaint(); pic1.morph(pic2); } }