Libraryless. Click here for Pure Java version (4765L/27K).
1 | static L<Rect> gridOfRects3_flattened(int w, int h, int cols, int rows) { |
2 | ret gridOfRects3_flattened(Rect(0, 0, w, h), cols, rows); |
3 | } |
4 | |
5 | static L<Rect> gridOfRects3_flattened(Rect r, int cols, int rows) { |
6 | new L<Rect> l; |
7 | for row to rows: { |
8 | int y1 = r.y+iround(r.h*(double) row/rows); |
9 | int y2 = r.y+iround(r.h*(double) (row+1)/rows); |
10 | for col to cols: { |
11 | int x1 = r.x+iround(r.w*(double) col/cols); |
12 | int x2 = r.x+iround(r.w*(double) (col+1)/cols); |
13 | l.add(Rect(x1, y1, x2-x1, y2-y1)); |
14 | } |
15 | } |
16 | ret l; |
17 | } |
Began life as a copy of #1024667
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034017 |
Snippet name: | gridOfRects3_flattened - takes cols and rows, returns L<Rect> |
Eternal ID of this version: | #1034017/3 |
Text MD5: | c213470c8e109291d642b09ed8a38339 |
Transpilation MD5: | 84d5098465e31b691cb36407d58fd8bf |
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:25:56 |
Source code size: | 547 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 142 / 209 |
Version history: | 2 change(s) |
Referenced in: | [show references] |