Advertisement
guieuiuz

6.1

Feb 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. public void mirrorVerticalLefttoRight()
  2.   {
  3.     Pixel[][] pixels = this.getPixels2D();
  4.     Pixel leftPixel = null;
  5.     Pixel rightPixel = null;
  6.     int width = pixels[0].length;
  7.     for (int row = 0; row < pixels.length/2; row++) // divide by 2 so it only does one side
  8.     {
  9.       for (int col = 0; col < width / 2; col++)
  10.       {
  11.         leftPixel = pixels[row][col];
  12.         rightPixel = pixels[row][width - 1 - col];
  13.         rightPixel.setColor(leftPixel.getColor());
  14.       }
  15.     }
  16.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement