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

15
LINES

< > BotCompany Repo | #1007290 // renderTiledBackground

JavaX fragment (include)

static BufferedImage renderTiledBackground(S tileImageID, int w, int h) {
  ret renderTiledBackground(tileImageID, w, h, 0, 0);
}

static BufferedImage renderTiledBackground(S tileImageID, int w, int h, int shiftX, int shiftY) {
  BufferedImage tileImage = loadImage2(tileImageID);
  BufferedImage img = newBufferedImage(w, h, Color.black);
  Graphics2D g = img.createGraphics();
  int tw = tileImage.getWidth(), th = tileImage.getHeight();
  for (int x = mod(shiftX-1, tw)-tw+1; x < w; x += tw)
    for (int y = mod(shiftY-1, th)-th+1; y < h; y += th)
      g.drawImage(tileImage, x, y, null);  
  g.dispose();
  ret img;
} 

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: 443 / 427
Version history: 4 change(s)
Referenced in: [show references]