Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

15
LINES

< > BotCompany Repo | #1007290 // renderTiledBackground

JavaX fragment (include)

1  
static BufferedImage renderTiledBackground(S tileImageID, int w, int h) {
2  
  ret renderTiledBackground(tileImageID, w, h, 0, 0);
3  
}
4  
5  
static BufferedImage renderTiledBackground(S tileImageID, int w, int h, int shiftX, int shiftY) {
6  
  BufferedImage tileImage = loadImage2(tileImageID);
7  
  BufferedImage img = newBufferedImage(w, h, Color.black);
8  
  Graphics2D g = img.createGraphics();
9  
  int tw = tileImage.getWidth(), th = tileImage.getHeight();
10  
  for (int x = mod(shiftX-1, tw)-tw+1; x < w; x += tw)
11  
    for (int y = mod(shiftY-1, th)-th+1; y < h; y += th)
12  
      g.drawImage(tileImage, x, y, null);  
13  
  g.dispose();
14  
  ret img;
15  
} 

Author comment

Began life as a copy of #1006894

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: #1007290
Snippet name: renderTiledBackground
Eternal ID of this version: #1007290/5
Text MD5: 26e8a230afab9aa2d73767f7e1324d00
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-22 16:41:22
Source code size: 639 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 495 / 486
Version history: 4 change(s)
Referenced in: [show references]