public class Lab6 { public static void onlyRed() { int x; int y; x = 0; while (x < Grid.getWidth()) { y = 0; while (y < Grid.getHeight()) { Grid.setColor(x, y, Grid.getRed(x, y), 0, 0); y = y + 1; } x = x + 1; } } public static void negate() { int x; int y; x = 0; while (x < Grid.getWidth()) { y = 0; while (y < Grid.getHeight()) { Grid.setColor(x, y, 255-Grid.getRed(x, y), 255-Grid.getGreen(x,y), 255-Grid.getBlue(x,y) ); y = y + 1; } x = x + 1; } } public static int brightness(int red, int green, int blue) { return (red + green + blue) / 3; } public static void grayScale() { int x; int y; x = 0; while (x < Grid.getWidth()) { y = 0; while (y < Grid.getHeight()) { int brightvalue = brightness(Grid.getRed(x,y), Grid.getGreen(x,y), Grid.getBlue(x,y)); Grid.setColor(x, y, brightvalue, brightvalue, brightvalue); y = y + 1; } x = x + 1; } } public static void reduceColors(int span) { int x; int y; x = 0; while (x < Grid.getWidth()) { y = 0; while (y < Grid.getHeight()) { int newRed = Grid.getRed(x,y) / span * span; int newGreen = Grid.getGreen(x,y) / span * span; int newBlue = Grid.getBlue(x,y) / span * span; Grid.setColor(x, y, newRed, newGreen, newBlue); y = y + 1; } x = x + 1; } } public static void tint(double redCoeff, double greenCoeff, double blueCoeff) { int x; int y; x = 0; while (x < Grid.getWidth()) { y = 0; while (y < Grid.getHeight()) { int newRed = (int)(Grid.getRed(x,y) * redCoeff); int newGreen = (int)(Grid.getGreen(x,y) * greenCoeff); int newBlue = (int)(Grid.getBlue(x,y) * blueCoeff); if (newRed > 255) { newRed = 255; } if (newGreen > 255) { newGreen = 255; } if (newBlue > 255) { newBlue = 255; } Grid.setColor(x, y, newRed, newGreen, newBlue); y = y + 1; } x = x + 1; } } }