Libraryless. Click here for Pure Java version (4717L/32K/119K).
1 | !7 |
2 | |
3 | sclass Letter { |
4 | char c; |
5 | Rect r; |
6 | |
7 | *() {} |
8 | *(char *c, Rect *r) {} |
9 | } |
10 | |
11 | p { |
12 | S code = text2floatingLetters([[sclass Letter { |
13 | char c; |
14 | Rect r; |
15 | |
16 | *() {} |
17 | *(char *c, Rect *r) {} |
18 | }]]); |
19 | new L<Letter> letters; |
20 | for (S line : tlft(code)) { |
21 | L<S> tok = tok_mergeInts(javaTok(line)); |
22 | if (jmatch2("Char <quoted> at (<int> <int>\\*<int> <int>)", tok)) { |
23 | tok = codeTokens(tok); |
24 | char c = toChar(unquote(tok.get(1))); |
25 | Rect r = new Rect(getInt(tok, 4), getInt(tok, 5), getInt(tok, 7), getInt(tok, 8)); |
26 | print("Char " + quote(c) + " at " + r); |
27 | r = translateRect(r, -10, -50); // just for fun |
28 | letters.add(Letter(c, r)); |
29 | } else |
30 | print("Non-match? " + line); |
31 | } |
32 | showImage(renderLetters(letters)); |
33 | } |
34 | |
35 | static BufferedImage renderLetters(L<Letter> letters) { |
36 | Rect big = mergeRects(collect(letters, 'r)); |
37 | BufferedImage canvas = newBufferedImage(big.w*2, big.h*2, Color.white); |
38 | for (Letter l : letters) |
39 | petRender(canvas, (l.r.x-big.x)*2, (l.r.y-big.y)*2, l.c); |
40 | ret canvas; |
41 | } |
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: | 486 / 683 |
Version history: | 14 change(s) |
Referenced in: | [show references] |