Implement the following rotation method:
For the rotateRight method, you will need to use a different one of the Picture class’s constructors in order to create a brand-new image of a different size. Here is an example call:
Picture myPicture = new Picture(newWidth, newHeight);
Of course, this presumes that you have defined newHeight and newWidth beforehand! From there, you will want to loop through all of the pixels, copying their color from the old image (this.) to the appropriate place in the new image (whatever you’ve named it). Be sure to return the new image in the end! Personally, I looped through the destination picture’s pixels and – for each one – computed the location from which to grab the source pixel that corresponded to it. The reverse works equally well.
Note that objects of type Pixel have methods that will get and set all of the components of a color at once! They use Java’s Color class, e.g.,
Color c = some_pixel.getColor();
some_other_pixel.setColor( c );
or even the equivalent
some_other_pixel.setColor( some pixel.getColor() );
When you complete this part, all of the tests from PictureTest_Rotate.java should pass.