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.

static BufferedImage renderShape_antiAlias(Color bg default Color.white, Shape shape, int w, int h) {
  BufferedImage img = newBufferedImage(w, h, bg);
  Graphics2D g = antiAliasOn(img.createGraphics());
  g.setColor(Color.black);
  g.fill(shape);
  ret img;
}

// uses shape.getBounds()
static BufferedImage renderShape_antiAlias(Color bg default Color.white, Shape shape) {
  if (shape == null) null;
  Rect r = toRect(shape.getBounds());
  
  BufferedImage img = newBufferedImage(max(1, r.w), max(1, r.h), bg);
  Graphics2D g = antiAliasOn(img.createGraphics());
  g.translate(-r.x, -r.y);
  g.setColor(Color.black);
  g.fill(shape);
  ret img;
}

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: 64 / 101
Version history: 3 change(s)
Referenced in: [show references]