import java.awt.font.*; import java.awt.geom.*; static JWindow screenTextOverlay(fS text, O... _) { ret swing(func -> JWindow { JPanel panel = singleColorPanel(optPar color(_, Color.WHITE)); new JWindow w; w.add(panel); w.setAlwaysOnTop(true); w.setVisible(true); Font font = cast optPar font(_); if (font == null) font = w.getFont().deriveFont(boolPar bold(_) ? Font.BOLD : Font.PLAIN, optPar fontSize(_, 80)); TextLayout tl = new TextLayout(text, font, ((Graphics2D) w.getGraphics()).getFontRenderContext()); Rectangle2D r = tl.getBounds(); new AffineTransform tx; tx.translate(0, r.getHeight()); Shape outline = tl.getOutline(tx); centerWindow(w, iceil(r.getWidth()), iceil(r.getHeight())); w.setShape(outline); ret w; }); }
Began life as a copy of #1013349
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: | #1023014 |
Snippet name: | screenTextOverlay - single row only, doesn't hide automatically |
Eternal ID of this version: | #1023014/5 |
Text MD5: | 5a28b279bd8964eb2702849721d26afe |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-20 20:12:50 |
Source code size: | 829 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 264 / 309 |
Version history: | 4 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1023016 - screenTextOverlay_withOutline - single row only, doesn't hide automatically |