import java.awt.geom.*; static void paintFitBackground(Component c, Graphics _g, BufferedImage image) { Graphics2D g = cast _g; RenderingHints hints = g.getRenderingHints(); antiAliasOn(g); int w = c.getWidth(), h = c.getHeight(); g.setColor(c.getBackground()); g.fillRect(0, 0, w, h); if (image != null) { int iw = image.getWidth(), ih = image.getHeight(); double imgScale = max(doubleRatio(h, ih), doubleRatio(w, iw)); AffineTransform before = g.getTransform(); double y1 = h-ih*imgScale; g.scale(imgScale, imgScale); g.translate(iround((w-iw*imgScale)/2), iround((h-ih*imgScale)/2)); g.drawImage(image, 0, 0, c); g.setTransform(before); } g.setRenderingHints(hints); }
Began life as a copy of #1015864
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016579 |
Snippet name: | paintFitBackground - fit so whole screen is filled |
Eternal ID of this version: | #1016579/4 |
Text MD5: | e48f645a23ad682580bc41e968133e46 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-28 15:22:17 |
Source code size: | 742 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 337 / 385 |
Version history: | 3 change(s) |
Referenced in: | [show references] |