1 | static int drawArrowBetweenPoints_width = 4; |
2 | static double drawArrowBetweenPoints_headScale = 2; |
3 | |
4 | static void drawArrowBetweenPoints(Graphics2D g, Pt p1, Pt p2, Color color) { |
5 | int x1 = p1.x, y1 = p1.y, x2 = p2.x, y2 = p2.y; |
6 | double dist = pointDistance(x1, y1, x2, y2); |
7 | double headSize = drawArrowBetweenPoints_width*drawArrowBetweenPoints_headScale*drawArrowHead_length+2; // 2 = gap |
8 | DoublePt v = blendDoublePts(new DoublePt(x2, y2), new DoublePt(x1, y1), headSize/dist); |
9 | DoublePt p = blendDoublePts(new DoublePt(x2, y2), new DoublePt(x1, y1), 0); |
10 | g.setColor(color); |
11 | g.setStroke(new BasicStroke(drawArrowBetweenPoints_width)); |
12 | g.draw(new Line2D.Double(x1, y1, v.x, v.y)); |
13 | drawArrowHead(g, x1, y1, p.x, p.y, drawArrowBetweenPoints_width*drawArrowBetweenPoints_headScale); |
14 | } |
Began life as a copy of #1015607
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1015613 |
Snippet name: | drawArrowBetweenPoints |
Eternal ID of this version: | #1015613/1 |
Text MD5: | 6f60f5e172b6fbf53e420ba8aa455871 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-05-19 20:22:04 |
Source code size: | 803 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 369 / 411 |
Referenced in: | [show references] |