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.

1  
scope renderLineCompedSingleLevels_raw.
2  
3  
static byte[][] renderLineCompedSingleLevels_raw(LineCompedSingle<Char> lc) {
4  
  int n = lcLength(lc);
5  
  
6  
  // each byte is the character's "color"
7  
  // (0 for empty, 1 for color one, 2 for color two)
8  
  L<byte[]> rows = new AutoCreateList<>(() -> new byte[n]);
9  
  fill(lc, rows, 0, 0, lc.main, 1);
10  
  ret toArray(rows, byte[].class);
11  
}
12  
  
13  
// returns new x
14  
static int #fill(LineCompedSingle<Char> lc, L<byte[]> rows, int x, int y, L<Int> symbols, int color) {
15  
  //printVars_str fill(+x, +y, +symbols, +color);
16  
  for (int idx : symbols) {
17  
    if (idx < l(lc.literals)) {
18  
      rows.get(y)[x] = (byte) color;
19  
      x++;
20  
    } else {
21  
      int newX = fill(lc, rows, x, y+1, intPairToList(lc.getPair(idx)), color);
22  
      while (x < newX) rows.get(y)[x++] = (byte) color;
23  
      color = 3-color;
24  
    }
25  
  }
26  
  ret x;
27  
}
28  
29  
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: 213 / 265
Version history: 3 change(s)
Referenced in: [show references]