28 lines
864 B
Java
28 lines
864 B
Java
import java.awt.Color;
|
|
|
|
public class Client {
|
|
public static void main(String[] args) {
|
|
Picture pic = new Picture(100, 100);
|
|
Color[][] pixels = pic.getPixels();
|
|
// 1. Create a new picture with size 400 x 400
|
|
// 2. Get the pixels out of the image
|
|
|
|
// 3. Call fill, providing a specific region
|
|
fill(pixels,0,40,0,40);
|
|
|
|
// 4. Set the pixels of the image
|
|
// 5. Save the image to display it
|
|
pic.setPixels(pixels);
|
|
pic.save("white.jpg");
|
|
}
|
|
|
|
// TODO: Implement fill below (this solution can be iterative)
|
|
public static void fill(Color[][] pixels, int x1, int x2, int y1, int y2) {
|
|
for (int i = y1 + 1; i < y2 - 1; i++) {
|
|
for (int n = x1 + 1; n < x2 - 1; n++) {
|
|
pixels[i][n] = new Color(255,255,255);
|
|
}
|
|
}
|
|
}
|
|
}
|