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

26
LINES

< > BotCompany Repo | #1031936 // drawLine

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

Libraryless. Click here for Pure Java version (4664L/26K).

1  
static void drawLine(BufferedImage image, int x1, int y1, int x2, int y2, Color color) {
2  
  drawLine(imageGraphics(image), x1, y1, x2, y2, color);
3  
}
4  
5  
static void drawLine(Graphics2D g, int x1, int y1, int x2, int y2, Color color) {
6  
  g.setColor(color);
7  
  g.drawLine(x1, y1, x2, y2);
8  
}
9  
10  
static void drawLine(BufferedImage image, Pt a, Pt b, Color color) {
11  
  drawLine(imageGraphics(image), a, b, color);
12  
}
13  
14  
static void drawLine(Graphics2D g, Pt a, Pt b, Color color) {
15  
  drawLine(g, a.x, a.y, b.x, b.y, color);
16  
}
17  
18  
ifclass DoubleEdge
19  
20  
import java.awt.geom.Line2D;
21  
static void drawLine(Graphics2D g, DoubleEdge e, Color color) {
22  
  if (e == null) ret;
23  
  g.setColor(color);
24  
  g.draw(new Line2D.Double(e.x1(), e.y1(), e.x2(), e.y2()));
25  
}
26  
endif

Author comment

Began life as a copy of #1006925

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1031936
Snippet name: drawLine
Eternal ID of this version: #1031936/6
Text MD5: d2b7d2b54ac52b921d89139f80c8f6a1
Transpilation MD5: 381dabf65ea05768223f3a7494156ac8
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-01 21:02:20
Source code size: 760 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 120 / 167
Version history: 5 change(s)
Referenced in: [show references]