import princeton.introcs.Picture; import java.awt.Color; import java.io.PrintStream; public class Test2FShort2 { public static void main(String[] args) { PrintStream out = System.out; Picture tile = new Picture("tile.png"); final int TILE_WIDTH = tile.width(); final int TILE_HEIGHT = tile.height(); final int PIC_WIDTH = Integer.parseInt(args[0]); final int PIC_HEIGHT = Integer.parseInt(args[1]); Picture pic = new Picture(PIC_WIDTH, PIC_HEIGHT); /* This question boils down to the following: for each pixel in the picture set the pixel color to the matching tile pixel color What you have to be careful of is that the tile indices (x, y) must obey: x >= 0 && x < TILE_WIDTH y >= 0 && y < TILE_HEIGHT To find the indices of the matching tile pixel, you could use if statements. You could use the remainder operator instead; see Test2FShort.java */ // the x position in the tile int x = 0; for (int i = 0; i < PIC_WIDTH; i++) { // the y-position in the tile int y = 0; for (int j = 0; j < PIC_HEIGHT; j++) { // get the color in the tile at (x, y) Color col = tile.get(x, y); // set the color in the picture at (i, j) pic.set(i, j, col); // move 1 pixel down in the tile y++; if (y == TILE_HEIGHT) { y = 0; } } // move 1 pixel to right in the tile x++; if (x == TILE_WIDTH) { x = 0; } } pic.show(); } }