Libraryless. Click here for Pure Java version (40L/1K).
1 | static L<Rectangle> gridOfRectangles(Rectangle r, int cols, int rows) { |
2 | new L<Rectangle> l; |
3 | for row to rows: { |
4 | int y1 = r.y+(int) Math.round(r.height*(double) row/rows); |
5 | int y2 = r.y+(int) Math.round(r.height*(double) (row+1)/rows); |
6 | for col to cols: { |
7 | int x1 = r.x+(int) Math.round(r.width*(double) col/cols); |
8 | int x2 = r.x+(int) Math.round(r.width*(double) (col+1)/cols); |
9 | l.add(new Rectangle(x1, y1, x2-x1, y2-y1)); |
10 | } |
11 | } |
12 | ret l; |
13 | } |
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: | 128 / 194 |
Version history: | 4 change(s) |
Referenced in: | [show references] |