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

22
LINES

< > BotCompany Repo | #1031198 // renderLineCompedSingleLevels - as monospaced text

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

Libraryless. Click here for Pure Java version (3316L/20K).

1  
sS renderLineCompedSingleLevels(LineCompedSingle<Char> lc) {
2  
  // each byte is the character's "color"
3  
  // (0 for empty, 1 for color one, 2 for color two)
4  
  byte[][] rows = renderLineCompedSingleLevels_raw(lc);
5  
  S text = uncompressLineCompedSingle(lc);
6  
  //printVars(+rows);
7  
  int n = l(first(rows));
8  
  ret lines(map(rows, row -> {
9  
    StringBuilder buf = new(n);
10  
    for i to n: {
11  
      if (row[i] == 0) 
12  
        buf.append(i == n-1 ? " " : "  ");
13  
      else {
14  
        buf.append(text.charAt(i));
15  
        if (i < n-1)
16  
          buf.append(row[i+1] != 0 && row[i+1] != row[i]
17  
            ? '|' : ' ');
18  
      }
19  
    }
20  
    ret str(buf);
21  
  }));
22  
}

Author comment

Began life as a copy of #1028482

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1031198
Snippet name: renderLineCompedSingleLevels - as monospaced text
Eternal ID of this version: #1031198/25
Text MD5: afd156b019661d6dec9623100aa8b589
Transpilation MD5: c3c445c31a96bb4a7c9af15f8337d6de
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:57:59
Source code size: 667 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 136 / 234
Version history: 24 change(s)
Referenced in: [show references]