From 81ba9eb66f8284d8760012973f84cdbe617ceb94 Mon Sep 17 00:00:00 2001 From: pants Date: Mon, 21 Sep 2026 14:16:34 -0700 Subject: init --- c2/fill/Client.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 c2/fill/Client.java (limited to 'c2/fill/Client.java') 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); + } + } + } +} -- cgit v1.2.3