public void fill(int x, int y, int bw, int bh, int color){
	//Fills in a colored rectangle of width = bw, heigth = bh	
		int x0 = x;
        int x1 = x + bw;
        int y0 = y;
        int y1 = y + bh;
        if (x0 < 0) x0 = 0;
        if (y0 < 0) y0 = 0;
        if (x1 > this.width) x1 = this.width;
        if (y1 > this.height) y1 = this.height;
        int ww = x1 - x0;

        for (int yy = y0; yy < y1; yy++) {
            int tp = yy * this.width + x0;
            for (int xx = 0; xx < ww; xx++) {
                pixels[tp + xx] = color;
            }
        }
    }