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

21
LINES

< > BotCompany Repo | #1014951 // renderBackgroundPlusBoxes

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3481L/21K).

static BufferedImage renderBackgroundPlusBoxes(int w, int h, BackgroundPlusBoxes s) {
  BufferedImage bi = newBufferedImage(w, h, toColor(s.background));
  Graphics2D g = imageGraphics(bi);
  for (BoxWithColor e : s.boxes) {
    int x1 = min(e.a.x, e.b.x), y1 = min(e.a.y, e.b.y);
    int x2 = max(e.a.x, e.b.x), y2 = max(e.a.y, e.b.y);
    fillRect(g, x1, y1, x2-x1+1, y2-y1+1, toColor(e.color));
  }
  g.dispose();
  ret bi;
}

static BufferedImage renderBackgroundPlusBoxes(int w, int h, Color background, Color boxColor, L<Rect> rects) {
  ret renderBackgroundPlusBoxes(w, h, BackgroundPlusBoxes(background,
    map(rects, r -> BoxWithColor(r, boxColor))));
}

// default to black on white
static BufferedImage renderBackgroundPlusBoxes(int w, int h, L<Rect> rects) {
  ret renderBackgroundPlusBoxes(w, h, Color.white, Color.black, rects);
}

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: #1014951
Snippet name: renderBackgroundPlusBoxes
Eternal ID of this version: #1014951/5
Text MD5: 24a86a920fd3b720e12f9a0026fe9e84
Transpilation MD5: 545dea75c6810282497c8b39d0ae76b4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-07 17:59:17
Source code size: 865 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 388 / 522
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1014958 - renderBackgroundPlusBoxes_withHints
#1014969 - renderBackgroundPlusPolys
#1030555 - renderBoxes