Libraryless. Click here for Pure Java version (1868L/12K).
static LL<Rect> gridOfRects3(int w, int h, int cols, int rows) { ret gridOfRects3(Rect(0, 0, w, h), cols, rows); } static LL<Rect> gridOfRects3(Rect r, int cols, int rows) { new LL<Rect> l; for row to rows: { new L<Rect> 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; }
Began life as a copy of #1015511
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1024667 |
| Snippet name: | gridOfRects3 - takes cols and rows, returns LL<Rect> |
| Eternal ID of this version: | #1024667/1 |
| Text MD5: | db50ee41867e7c63c5b69b33ca1304dc |
| Transpilation MD5: | 034500194f6734d79532d48d2ac65bb4 |
| Author: | stefan |
| Category: | javax / imaging |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-08-22 23:39:25 |
| Source code size: | 564 bytes / 19 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 457 / 592 |
| Referenced in: | [show references] |