diff options
| author | pants <niklasjo2004@gmail.com> | 2026-09-21 14:16:34 -0700 |
|---|---|---|
| committer | pants <niklasjo2004@gmail.com> | 2026-09-21 14:16:34 -0700 |
| commit | 81ba9eb66f8284d8760012973f84cdbe617ceb94 (patch) | |
| tree | 466432644e9e3fd66ee183ec53a1f10abb1b7faa /c2/fill/Client.java | |
Diffstat (limited to 'c2/fill/Client.java')
| -rw-r--r-- | c2/fill/Client.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/c2/fill/Client.java b/c2/fill/Client.java new file mode 100644 index 0000000..9d57619 --- /dev/null +++ b/c2/fill/Client.java @@ -0,0 +1,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); + } + } + } +} |
