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).

1  
static void drawRect(BufferedImage image, int x, int y, int w, int h, Color color) {
2  
  Graphics2D g = imageGraphics(image);
3  
  drawRect(g, x, y, w, h, color);
4  
  g.dispose();
5  
}
6  
7  
static void drawRect(Graphics2D g, int x, int y, int w, int h, Color color) {
8  
  g.setColor(color);
9  
  g.drawRect(x, y, w, h);
10  
}
11  
12  
static void drawRect(Graphics2D g, Color color, Rect r) {
13  
  drawRect(g, r, color);
14  
}
15  
16  
static void drawRect(Graphics2D g, Rect r, Color color) {
17  
  g.setColor(color);
18  
  g.drawRect(r.x, r.y, r.w, r.h);
19  
}
20  
21  
static void drawRect(Graphics2D g, Rect r) {
22  
  g.drawRect(r.x, r.y, r.w, r.h);
23  
}
24  
25  
// draw on currentImage()
26  
static void drawRect(int x, int y, int w, int h, Color color) {
27  
  drawRect(currentImage(), x, y, w, h, color);
28  
}
29  
30  
static void drawRect(Rect r, Color color) {
31  
  drawRect(r.x, r.y, r.w, r.h, color);
32  
}
33  
34  
ifclass Rect
35  
static void drawRect(BufferedImage image, Rect r, Color c) {
36  
  if (r != null) drawRect(image, r.x, r.y, r.w, r.h, c);
37  
}
38  
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: 467 / 548
Version history: 5 change(s)
Referenced in: [show references]