init
This commit is contained in:
27
c2/fill/Client.java
Normal file
27
c2/fill/Client.java
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user