static void box(Img img, Box p) { int w = img.getWidth(), h = img.getHeight(); double x1 = normalize(p.cx-p.w), x2 = normalize(p.cx+p.w); double y1 = normalize(p.cy-p.h), y2 = normalize(p.cy+p.h); int xx1 = round(x1*(w-1)), xx2 = round(x2*(w-1)); int yy1 = round(y1*(h-1)), yy2 = round(y2*(h-1)); for (int yy = yy1; yy <= yy2; yy++) for (int xx = xx1; xx <= xx2; xx++) img.setPixel(xx, yy, p.color); }