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

41
LINES

< > BotCompany Repo | #1008944 // Render Floating Letters [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (4717L/32K/119K).

!7

sclass Letter {
  char c;
  Rect r;
  
  *() {}
  *(char *c, Rect *r) {}
}

p {
  S code = text2floatingLetters([[sclass Letter {
  char c;
  Rect r;
  
  *() {}
  *(char *c, Rect *r) {}
}]]);
  new L<Letter> letters;
  for (S line : tlft(code)) {
    L<S> tok = tok_mergeInts(javaTok(line));
    if (jmatch2("Char <quoted> at (<int> <int>\\*<int> <int>)", tok)) {
      tok = codeTokens(tok);
      char c = toChar(unquote(tok.get(1)));
      Rect r = new Rect(getInt(tok, 4), getInt(tok, 5), getInt(tok, 7), getInt(tok, 8));
      print("Char " + quote(c) + " at " + r);
      r = translateRect(r, -10, -50); // just for fun
      letters.add(Letter(c, r));
    } else
      print("Non-match? " + line);
  }
  showImage(renderLetters(letters));
}

static BufferedImage renderLetters(L<Letter> letters) {
  Rect big = mergeRects(collect(letters, 'r));
  BufferedImage canvas = newBufferedImage(big.w*2, big.h*2, Color.white);
  for (Letter l : letters)
    petRender(canvas, (l.r.x-big.x)*2, (l.r.y-big.y)*2, l.c);
  ret canvas;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

-
Snippet ID: #1008944
Snippet name: Render Floating Letters [dev.]
Eternal ID of this version: #1008944/15
Text MD5: 2436c56d062f00b243015d01607e9b6e
Transpilation MD5: 888aa52645941c4cbdb869a0f2e35560
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-06-20 02:29:36
Source code size: 1077 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 487 / 684
Version history: 14 change(s)
Referenced in: