1 | static void paintTiledBackground_centered(Component c, Graphics g, BufferedImage image) { |
2 | int w = c.getWidth(); |
3 | int h = c.getHeight(); |
4 | int tw = image.getWidth(), th = image.getHeight(); |
5 | |
6 | // center of tile should be in center of image |
7 | int shiftX = (w-tw)/2, shiftY = (h-th)/2; |
8 | |
9 | int y1 = mod(shiftY-1, th)-th+1; |
10 | for (int x = mod(shiftX-1, tw)-tw+1; x < w; x += tw) |
11 | for (int y = y1; y < h; y += th) |
12 | g.drawImage(image, x, y, c); |
13 | } |
Began life as a copy of #1009941
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009956 |
Snippet name: | paintTiledBackground_centered |
Eternal ID of this version: | #1009956/1 |
Text MD5: | da3ae165758d1c272163b8138de2887b |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-08-27 17:42:10 |
Source code size: | 470 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 525 / 526 |
Referenced in: | [show references] |