public static void drawImage(int[][][] pixels, int startX, int startY) { // Key idea: draw a bunch (lots of rectangles) with the appropriate color DrawObject R = new DrawObject(); R.pixels = pixels; R.startX = startX; R.startY = startY; R.sequenceNum = currentSequenceNum; images.add(R); // Rescale if needed. int leftX = startX; int rightX = startX + pixels.length; int lowY = startY; int highY = startY + pixels[0].length; if (minX > leftX) { minX = leftX; } if (maxX < rightX) { maxX = rightX; } if (minY > lowY) { minY = lowY; } if (maxY < highY) { maxY = highY; } drawArea.repaint(); }