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

38
LINES

< > BotCompany Repo | #1014942 // drawRect - works on BufferedImage or Graphics2D

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

Libraryless. Click here for Pure Java version (5069L/28K).

static void drawRect(BufferedImage image, int x, int y, int w, int h, Color color) {
  Graphics2D g = imageGraphics(image);
  drawRect(g, x, y, w, h, color);
  g.dispose();
}

static void drawRect(Graphics2D g, int x, int y, int w, int h, Color color) {
  g.setColor(color);
  g.drawRect(x, y, w, h);
}

static void drawRect(Graphics2D g, Color color, Rect r) {
  drawRect(g, r, color);
}

static void drawRect(Graphics2D g, Rect r, Color color) {
  g.setColor(color);
  g.drawRect(r.x, r.y, r.w, r.h);
}

static void drawRect(Graphics2D g, Rect r) {
  g.drawRect(r.x, r.y, r.w, r.h);
}

// draw on currentImage()
static void drawRect(int x, int y, int w, int h, Color color) {
  drawRect(currentImage(), x, y, w, h, color);
}

static void drawRect(Rect r, Color color) {
  drawRect(r.x, r.y, r.w, r.h, color);
}

ifclass Rect
static void drawRect(BufferedImage image, Rect r, Color c) {
  if (r != null) drawRect(image, r.x, r.y, r.w, r.h, c);
}
endif

Author comment

Began life as a copy of #1009141

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: #1014942
Snippet name: drawRect - works on BufferedImage or Graphics2D
Eternal ID of this version: #1014942/6
Text MD5: 61922feaf1261f3fb41af46c93d91ccb
Transpilation MD5: 665dbc556eca0e3fb2cd5cbb0bb021bd
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-15 17:52:38
Source code size: 989 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 465 / 546
Version history: 5 change(s)
Referenced in: [show references]