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).

static LL<DoubleRect> gridOfDoubleRects3(double w, double h, int cols, int rows) {
  ret gridOfDoubleRects3(DoubleRect(0, 0, w, h), cols, rows);
}

static LL<DoubleRect> gridOfDoubleRects3(DoubleRect r, int cols, int rows) {
  new LL<DoubleRect> l;
  for row to rows: {
    new L<DoubleRect> line;
    double y1 = r.y+r.h*row/rows;
    double y2 = r.y+r.h*(row+1)/rows;
    for col to cols: {
      double x1 = r.x+r.w*col/cols;
      double x2 = r.x+r.w*(col+1)/cols;
      line.add(DoubleRect(x1, y1, x2-x1, y2-y1));
    }
    l.add(line);
  }
  ret l;
}

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: 189 / 258
Version history: 5 change(s)
Referenced in: [show references]