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

21
LINES

< > BotCompany Repo | #1020217 // tilesToImage - TODO: varying tile sizes

JavaX fragment (include)

static BufferedImage tilesToImage(L<BufferedImage> tiles, int columns) {
  if (empty(tiles)) null;
  int rows = idiv_ceil(l(tiles), columns);
  int tw = first(tiles).getWidth(), th = first(tiles).getHeight();
  int w = tw*columns, h = th*rows;
  BufferedImage img = newBufferedImage(w, h);
  
  int i = 0, yy = 0;
  for y to rows: {
    int xx = 0;
    for x to columns: {
      if (i >= l(tiles)) break;
      BufferedImage tile = tiles.get(i++);
      copyBufferedImage(tile, img, xx, yy);
      xx += tile.getWidth();
      th = tile.getHeight();
    }
    yy += th;
  }
  ret img;
}

Author comment

Began life as a copy of #1016032

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020217
Snippet name: tilesToImage - TODO: varying tile sizes
Eternal ID of this version: #1020217/6
Text MD5: 7dcba2048bafbaaf3a8332470f402e61
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-30 21:06:32
Source code size: 606 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 280 / 325
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1020683 - tilesToImage_twoLevelList