/** * Sets the color of a pixel. * * @param i the pixel index * @param color the new color for the pixel */ public void setColorAt(int i, Color color) { if (image == null || i < 0 || i >= pixels()) { throw new IndexOutOfBoundsException("" + i); } else { setColorAt(i % image.getWidth(), i / image.getWidth(), color); } }