![]() Finally, store the new Color at the current x and y. ![]() Implement the following algorithm: for each x and y value in the range (0.width, 0.height), get the Color object at that x and y, calculate the average of its red, green, and blue values, and then create a new Color object using the average for all three of its RGB values. * Updates all pixels to the closest gray equivalent. You will need to use the getBlue, getGreen, and getRed methods.Īdd the following method stub below your constructor: Then skim through the Color Javadoc to become familiar with that class. ![]() In particular, you will need to use the following methods: getWidth, getHeight, getColorAt, and setColorAt. Skim through the GreenfootImage Javadoc to become familiar with that class. Each object represents the red, green, and blue value of a single pixel. Images in Greenfoot are essentially 2D arrays of Color objects. After you complete the exercises below, you will submit the Image.java file via Canvas. Write your name, today's date, and a short description of this lab in the Javadoc comment of the Image class. Open the editor for Image.java (by double clicking on the Image rectangle on the right) and modify the constructor to use the dimensions 640x426 (the actual size of football.jpg). Then in Greenfoot, right-click the "World" rectangle on the right and select "New subclass." Name the subclass Image and select football.jpg (it should be listed below). Right-click the football stadium photo above, and save it to the "images" folder in your Greenfoot project. Once open, right-click the "MyWorld" rectangle and delete it. Name your scenario Lab23 or whatever you like. Run Greenfoot and then select "Scenario > New Java Scenario." from the menu. In the previous Greenfoot lab, we dealt with Actor objects. In today's lab, you will use Greenfoot to implement several features of programs like Photoshop. Media Computation is an approach to learning programming that focuses on manipulating digital media like images and sounds. Image courtesy of JMU Creative Services Background When checking for a state to change in a 'while' loop (like for the sound to stop), it will executed until the sound stops (a long time in computer terms).James Madison University, Spring 2018 Semester The only difference, is that the 'while' statement is one of the looping commands and can take many more ticks to execute than a non-looping command (I am not talking methods here I am talking basic java keyword commands). The code appears to have the actor move 5 pixels every tenth of a second but, that is not what will happen (visually).Īll in all, the 'while' statement is just like any other statement - when the program pointer get to that statement, it is executed. }Manually perform the act method on an actor and you will have to wait one second before the actor all of sudden appear 500 cells to the right of where it started (or at the right edge of the screen, if a bounded world prevented further progress). The first part of the question is why would the loop execute before the image for the card is changed? The second part of the question, and I am sure it is a simple oversight on my part, is why would the image for the card eventually change when the music has stopped playing? The commands are not being executed in the order explicitly stated in the program, but all commands are being run through and successfully completing, just not as expected.įor (int n=0 n System.currentTimeMillis()) continue She decided to use a while statement to ensure that only one music card could be clicked on at a time and that the user would not be able to select a different card before the selection from the composition was finished playing. If (Greenfoot.mouseClicked(this) & isClicked = false & cardOneValue != 0 & isSoundPlaying = false) GreenfootSound sound = new GreenfootSound(matchingValue) ![]() If (Greenfoot.mouseClicked(this) &isClicked = false & cardOneValue = 0)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |