import princeton.introcs.Picture; import java.awt.Color; import java.io.PrintStream; public class Test2FShort { 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, just use the remainder operator. You could use if statements instead; see Test2FShort2.java */ for (int i = 0; i < PIC_WIDTH; i++) { // get the x-position in the tile int x = i % TILE_WIDTH; for (int j = 0; j < PIC_HEIGHT; j++) { // get the y-position in the tile int y = j % TILE_HEIGHT; // 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); } } pic.show(); } }