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

16
LINES

< > BotCompany Repo | #1015511 // makeGridOfRects2 - does not include partial rects. takes rw and rh, returns LL<Rect>

JavaX fragment (include)

1  
static LL<Rect> makeGridOfRects2(int w, int h, int rw, int rh) {
2  
  ret makeGridOfRects2(Rect(0, 0, w, h), rw, rh);
3  
}
4  
5  
static LL<Rect> makeGridOfRects2(Rect r, int rw, int rh) {
6  
  new LL<Rect> l;
7  
  int w = r.w-mod(r.w, rw);
8  
  int h = r.h-mod(r.h, rh);
9  
  for (int y = r.y; y < h; y += rh) {
10  
    new L<Rect> line;
11  
    for (int x = r.x; x < w; x += rw)
12  
      line.add(Rect(x, y, rw, rh));
13  
    l.add(line);
14  
  }
15  
  ret l;
16  
}

Author comment

Began life as a copy of #1015502

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015511
Snippet name: makeGridOfRects2 - does not include partial rects. takes rw and rh, returns LL<Rect>
Eternal ID of this version: #1015511/2
Text MD5: 283a9fe36c33622092c41a7ffeead332
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:35:24
Source code size: 431 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 473 / 506
Version history: 1 change(s)
Referenced in: [show references]