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

20
LINES

< > BotCompany Repo | #1033762 // renderShape_antiAlias (black on white)

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

Transpiled version (4840L) is out of date.

1  
static BufferedImage renderShape_antiAlias(Color bg default Color.white, Shape shape, int w, int h) {
2  
  BufferedImage img = newBufferedImage(w, h, bg);
3  
  Graphics2D g = antiAliasOn(img.createGraphics());
4  
  g.setColor(Color.black);
5  
  g.fill(shape);
6  
  ret img;
7  
}
8  
9  
// uses shape.getBounds()
10  
static BufferedImage renderShape_antiAlias(Color bg default Color.white, Shape shape) {
11  
  if (shape == null) null;
12  
  Rect r = toRect(shape.getBounds());
13  
  
14  
  BufferedImage img = newBufferedImage(max(1, r.w), max(1, r.h), bg);
15  
  Graphics2D g = antiAliasOn(img.createGraphics());
16  
  g.translate(-r.x, -r.y);
17  
  g.setColor(Color.black);
18  
  g.fill(shape);
19  
  ret img;
20  
}

Author comment

Began life as a copy of #1006979

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033762
Snippet name: renderShape_antiAlias (black on white)
Eternal ID of this version: #1033762/4
Text MD5: f78f47789d00a0e2368bcced9ed401e8
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-22 18:40:39
Source code size: 670 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 129 / 188
Version history: 3 change(s)
Referenced in: [show references]