Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1024667 // gridOfRects3 - takes cols and rows, returns LL<Rect>

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (1868L/12K).

1  
static LL<Rect> gridOfRects3(int w, int h, int cols, int rows) {
2  
  ret gridOfRects3(Rect(0, 0, w, h), cols, rows);
3  
}
4  
5  
static LL<Rect> gridOfRects3(Rect r, int cols, int rows) {
6  
  new LL<Rect> l;
7  
  for row to rows: {
8  
    new L<Rect> line;
9  
    int y1 = r.y+iround(r.h*(double) row/rows);
10  
    int y2 = r.y+iround(r.h*(double) (row+1)/rows);
11  
    for col to cols: {
12  
      int x1 = r.x+iround(r.w*(double) col/cols);
13  
      int x2 = r.x+iround(r.w*(double) (col+1)/cols);
14  
      line.add(Rect(x1, y1, x2-x1, y2-y1));
15  
    }
16  
    l.add(line);
17  
  }
18  
  ret l;
19  
}

Author comment

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: 243 / 332
Referenced in: [show references]