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

35
LINES

< > BotCompany Repo | #1035100 // G22VisualizeMeshes

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

Libraryless. Click here for Pure Java version (10962L/62K).

srecord noeq G22VisualizeMeshes(WidthAndHeight originalImage, L<G22Mesh> meshes) {
  delegate Anchor, Curve to G22Mesh.
  
  // can also include alpha
  settable Color anchorColor = withAlpha(0.5, Color.red);
  settable int anchorSize = 5;
  
  // can also include alpha
  settable Color curveColor = Color.blue;
  
  BufferedImage get() {
    var markedImage = whiteImage(imageSize(originalImage));
    drawOn(createGraphics(markedImage));
    ret markedImage;
  }
  
  void drawOn(Graphics2D g) {
    for (mesh : meshes)
      for (curve : mesh.curves())
        drawCurve(g, curve);

    for (mesh : meshes)
      for (p : mesh.anchorPts())
        drawAnchor(g, p);
  }
  
  void drawCurve(Graphics2D g, Curve curve) {
    drawPixels(g, curve.path().pointIterator(), curveColor);
  }

  void drawAnchor(Graphics2D g, Pt p) {
    fillRect(g, p.x-anchorSize/2, p.y-anchorSize/2,
      anchorSize, anchorSize, anchorColor);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035100
Snippet name: G22VisualizeMeshes
Eternal ID of this version: #1035100/8
Text MD5: bac15e11d825247070e96f7c61a20fb8
Transpilation MD5: 71d83560e7b076ea06cd30e479c3d00f
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-06 18:50:17
Source code size: 964 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 156 / 254
Version history: 7 change(s)
Referenced in: [show references]