From 430fa5c354c4454dd1954897ed3d4364d8acd3b3 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Mon, 22 Apr 2024 10:23:22 -0600 Subject: [PATCH] Length connection arrows for adjacent cells --- js/editor/helpers.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/js/editor/helpers.js b/js/editor/helpers.js index c23d50d..e2f6390 100644 --- a/js/editor/helpers.js +++ b/js/editor/helpers.js @@ -46,9 +46,17 @@ export class SVGConnection { this.line.setAttribute('y1', this.sy + 0.5 + trim_y); // Technically this isn't quite right, since the ending is a square and the arrowhead will // poke into it a bit from angles near 45°, but that requires a bit more trig than seems - // worth it - this.line.setAttribute('x2', this.dx + 0.5 - trim_x); - this.line.setAttribute('y2', this.dy + 0.5 - trim_y); + // worth it, and it looks kinda neat anyway. + // Also, one nicety: if the cells are adjacent, don't trim the endpoint, or we won't have + // an arrow at all. + if (line_length < 2) { + this.line.setAttribute('x2', this.dx + 0.5); + this.line.setAttribute('y2', this.dy + 0.5); + } + else { + this.line.setAttribute('x2', this.dx + 0.5 - trim_x); + this.line.setAttribute('y2', this.dy + 0.5 - trim_y); + } } }