static LL gridOfRects3(int w, int h, int cols, int rows) { ret gridOfRects3(Rect(0, 0, w, h), cols, rows); } static LL gridOfRects3(Rect r, int cols, int rows) { new LL l; for row to rows: { new L line; int y1 = r.y+iround(r.h*(double) row/rows); int y2 = r.y+iround(r.h*(double) (row+1)/rows); for col to cols: { int x1 = r.x+iround(r.w*(double) col/cols); int x2 = r.x+iround(r.w*(double) (col+1)/cols); line.add(Rect(x1, y1, x2-x1, y2-y1)); } l.add(line); } ret l; }