From da5814271fcdc2e779a01172124dc3a93c027077 Mon Sep 17 00:00:00 2001 From: Lubin Pappalardo Date: Thu, 5 Oct 2023 12:02:11 -0400 Subject: [PATCH] better looking wires part2 --- assets/scripts/wires.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/scripts/wires.js b/assets/scripts/wires.js index 6034637..448d968 100644 --- a/assets/scripts/wires.js +++ b/assets/scripts/wires.js @@ -184,11 +184,16 @@ function draw () { pen.beginPath(); pen.moveTo(start.x, start.y); - pen.lineTo(end.x - (Math.abs(start.x - end.x) / 2), start.y); - pen.lineTo(end.x - (Math.abs(start.x - end.x) / 2), end.y); + if (end.x > start.x) { + pen.lineTo(end.x - (Math.abs(start.x - end.x) / 2), start.y); + pen.lineTo(end.x - (Math.abs(start.x - end.x) / 2), end.y); + } else { + pen.lineTo(start.x, end.y - (Math.abs(start.y - end.y) / 2)); + pen.lineTo(end.x, end.y - (Math.abs(start.y - end.y) / 2)); + } pen.lineTo(end.x, end.y); pen.stroke(); - + } } }