let the parent class handle this width and height * height the height of the desired picture * Constructor that takes the height and width let the parent class handle this fileName * fileName the name of the file to create the picture from * Constructor that takes a file name and creates the picture * child constructors always call a parent constructor * not needed but use it to show students the implicit call to super() * Barbara Ericson class Picture extends SimplePicture * SimplePicture and allows the student to add functionality to 2) write a method called switchColors() that replaces red values (using p.setRed) with green or blue values (using p.getGreen(), etc.) to change the colors around. Picture Lab: 1) write a method called keepOnlyBlue() that keeps only the blue values by setting the red and green values to zero. You can test the methods in the active code below or in this Swing project or this alternative project by teacher Jason Stark from LA (click output.jpg to see the result) or your own IDE to see what it does. You will need to use the getRed(), getGreen(), getBlue() to get the RGB values of the pixel and then swap them around by using the setRed, setGreen, setBlue methods and giving them different color values from the get methods as arguments. Then, write a method called switchColors() that swaps the red pixels with green pixels or blue pixels to change the colors around. Now, write a similar method called keepOnlyBlue() that visits every pixel and sets the red and green values to zero but does not change the blue ones. It uses nested loops to visit each pixel in a photo which has a color with red, green, and blue values, and it sets all the blue values to 0. Scroll down to the bottom of the following code and take a look at the zeroBlue() method. In this challenge, you will do a part of the Picture Lab to modify the pixels of a digital photo. Can you make black? Can you make white? Can you make purple? If your class has time, do the reading and exercises for Picture Lab sections A1 to A3 to first learn about digital pictures and RGB values. You can make any color by mixing these values! Try the RGB Color Mixer to experiment. Model, which stores values for red, green, and blue, each ranging from 0 to 255. The color of a pixel is represented using the RGB (Red, Green, Blue) color Photographs and images are made up of a 2D array of pixels which are tiny picture elements that color in the image. Click on the CodeLens button to trace through the code. 8.9.7 Picture Lab A9: Simple Edge Detection. 8.9.6 Picture Lab A8: Creating a Collage.8.9.5 Picture Lab A7: Mirroring Part of a Picture.8.9.4 Picture Lab A6: Mirroring Pictures.8.9.3 Picture Lab A5: Modifying a Picture.8.9.2 Picture Lab A4: 2D Arrays in Java.8.9 College Board Picture Lab and Steganography Lab for 2D Arrays.8.5 Toggle Mixed Up or Write Code Practice.8.2.5 Enhanced For-Each Loop for 2D Arrays (Day 2).8.2.1 Nested Loops for 2D Arrays (Day 1).8.2 Traversing 2D Arrays (nested loops).8.1.5 Set Value(s) in a 2D Array (Day 2).Peer Instruction: 2D Arrays Multiple Choice Questions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |