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

19
LINES

< > BotCompany Repo | #1025255 // gridOfDoubleRects3 - takes cols and rows, returns LL<DoubleRect>

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

Libraryless. Click here for Pure Java version (2278L/14K).

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

Author comment

Began life as a copy of #1024667

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: #1025255
Snippet name: gridOfDoubleRects3 - takes cols and rows, returns LL<DoubleRect>
Eternal ID of this version: #1025255/6
Text MD5: 2475e6218a4049e99c4b86632c371584
Transpilation MD5: aa2ed6504373adb2f21448f292cf4595
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-16 21:22:16
Source code size: 574 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 274 / 361
Version history: 5 change(s)
Referenced in: [show references]