Libraryless. Click here for Pure Java version (40L/1K).
static L<Rectangle> gridOfRectangles(Rectangle r, int cols, int rows) { new L<Rectangle> l; for row to rows: { int y1 = r.y+(int) Math.round(r.height*(double) row/rows); int y2 = r.y+(int) Math.round(r.height*(double) (row+1)/rows); for col to cols: { int x1 = r.x+(int) Math.round(r.width*(double) col/cols); int x2 = r.x+(int) Math.round(r.width*(double) (col+1)/cols); l.add(new Rectangle(x1, y1, x2-x1, y2-y1)); } } ret l; }
Began life as a copy of #1034017
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034018 |
Snippet name: | gridOfRectangles - takes cols and rows, returns L<Rectangle> |
Eternal ID of this version: | #1034018/5 |
Text MD5: | 2aa68ac02f994ff4208b221c0bef8068 |
Transpilation MD5: | b16b6737ac2b968dd96c3cea07f809c3 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-17 14:51:29 |
Source code size: | 482 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 127 / 191 |
Version history: | 4 change(s) |
Referenced in: | [show references] |