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

33
LINES

< > BotCompany Repo | #1009141 // fillRect - works on BufferedImage or Graphics2D

JavaX fragment (include)

1  
static void fillRect(BufferedImage image, int x, int y, int w, int h, Color color) {
2  
  Graphics2D g = imageGraphics(image);
3  
  fillRect(g, x, y, w, h, color);
4  
  g.dispose();
5  
}
6  
7  
static void fillRect(Graphics g, Color color, int x, int y, int w, int h) {
8  
  fillRect(g, x, y, w, h, color);
9  
}
10  
11  
static void fillRect(Graphics/*2D*/ g, int x, int y, int w, int h, Color color) {
12  
  g.setColor(color);
13  
  g.fillRect(x, y, w, h);
14  
}
15  
16  
// draw on currentImage()
17  
static void fillRect(int x, int y, int w, int h, Color color) {
18  
  fillRect(currentImage(), x, y, w, h, color);
19  
}
20  
21  
static void fillRect(Rect r, Color color) {
22  
  fillRect(r.x, r.y, r.w, r.h, color);
23  
}
24  
25  
ifclass Rect
26  
static void fillRect(BufferedImage image, Rect r, Color c) {
27  
  if (r != null) fillRect(image, r.x, r.y, r.w, r.h, c);
28  
}
29  
30  
static void fillRect(Graphics/*2D*/ g, Rect r, Color c) {
31  
  if (r != null) fillRect(g, r.x, r.y, r.w, r.h, c);
32  
}
33  
endif

Author comment

Began life as a copy of #1006920

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009141
Snippet name: fillRect - works on BufferedImage or Graphics2D
Eternal ID of this version: #1009141/11
Text MD5: 3f5d1af49de62f2a3fa339a6ae2f50cc
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-20 16:57:08
Source code size: 931 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 578 / 635
Version history: 10 change(s)
Referenced in: [show references]