static L gridOfRects3_flattened(int w, int h, int cols, int rows) { ret gridOfRects3_flattened(Rect(0, 0, w, h), cols, rows); } static L gridOfRects3_flattened(Rect r, int cols, int rows) { new L l; for row to rows: { 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); l.add(Rect(x1, y1, x2-x1, y2-y1)); } } ret l; }