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

29
LINES

< > BotCompany Repo | #1031200 // renderLineCompedSingleLevels_raw

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

Transpiled version (3086L) is out of date.

scope renderLineCompedSingleLevels_raw.

static byte[][] renderLineCompedSingleLevels_raw(LineCompedSingle<Char> lc) {
  int n = lcLength(lc);
  
  // each byte is the character's "color"
  // (0 for empty, 1 for color one, 2 for color two)
  L<byte[]> rows = new AutoCreateList<>(() -> new byte[n]);
  fill(lc, rows, 0, 0, lc.main, 1);
  ret toArray(rows, byte[].class);
}
  
// returns new x
static int #fill(LineCompedSingle<Char> lc, L<byte[]> rows, int x, int y, L<Int> symbols, int color) {
  //printVars_str fill(+x, +y, +symbols, +color);
  for (int idx : symbols) {
    if (idx < l(lc.literals)) {
      rows.get(y)[x] = (byte) color;
      x++;
    } else {
      int newX = fill(lc, rows, x, y+1, intPairToList(lc.getPair(idx)), color);
      while (x < newX) rows.get(y)[x++] = (byte) color;
      color = 3-color;
    }
  }
  ret x;
}

end scope

Author comment

Began life as a copy of #1031198

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031200
Snippet name: renderLineCompedSingleLevels_raw
Eternal ID of this version: #1031200/4
Text MD5: 5e8f32dca4c6ce094347db4a633e259a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-20 14:56:37
Source code size: 886 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 149 / 177
Version history: 3 change(s)
Referenced in: [show references]