summaryrefslogtreecommitdiff
path: root/c2/fill/Client.java
blob: 9d57619ead21632ed1b49e7d7e8ab7b9500cd6b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);
            }
        }
    }
}