1 | static JWindow screenTextOverlay_withOutline(fS text, O... _) { |
2 | ret swing(func -> JWindow { |
3 | new JWindow w; |
4 | w.setAlwaysOnTop(true); |
5 | w.setVisible(true); |
6 | |
7 | Font font = cast optPar font(_); |
8 | if (font == null) |
9 | font = w.getFont().deriveFont(boolPar bold(_, true) ? Font.BOLD : Font.PLAIN, optPar fontSize(_, 80)); |
10 | TextLayout tl = newTextLayout(text, font, w); |
11 | Rectangle2D r = tl.getBounds(); |
12 | new AffineTransform tx; |
13 | tx.translate(0, r.getHeight()); |
14 | Shape outline = tl.getOutline(tx); |
15 | |
16 | float outlineWidth = optPar outlineWidth(_, 4.0f); |
17 | JComponent c = dynamicallyPaintedComponent(voidfunc(Graphics2D g, int w, int h) { |
18 | fillRect(g, 0, 0, w, h, optPar color(_, Color.WHITE)); |
19 | g.setColor(Color.black); |
20 | g.setStroke(new BasicStroke(outlineWidth); |
21 | antiAliasOn(g); |
22 | g.draw(outline); |
23 | }); |
24 | w.add(c); |
25 | |
26 | centerWindow(w, iceil(r.getWidth()+optPar magicXMargin(_, 10)), |
27 | iceil(r.getHeight()+optPar magicYMargin(_, 10))); |
28 | w.setShape(outline); |
29 | ret w; |
30 | }); |
31 | } |
Began life as a copy of #1023014
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023016 |
Snippet name: | screenTextOverlay_withOutline - single row only, doesn't hide automatically |
Eternal ID of this version: | #1023016/13 |
Text MD5: | 27c1af0043744b3d46bf322602c9d890 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-30 20:40:34 |
Source code size: | 1080 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 240 / 312 |
Version history: | 12 change(s) |
Referenced in: | [show references] |