From c5724e4195adcddcbfc4b9758e56d2eae06a3d63 Mon Sep 17 00:00:00 2001 From: irismarie Date: Thu, 22 Oct 2020 10:35:56 +0200 Subject: [PATCH] fix: calculate length of line correctly, #206 --- src/widget/widgets/line.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/widget/widgets/line.js b/src/widget/widgets/line.js index 94a33df..93249f6 100644 --- a/src/widget/widgets/line.js +++ b/src/widget/widgets/line.js @@ -51,19 +51,15 @@ class WidgetLine extends Component { // calculate the length of the line let length = 0; - if (width <= height) { - if (rotation > 0) { - length = width / Math.abs(Math.cos(rad)); + if (rotation > 0) { + if (width <= height) { + length = width / Math.abs(Math.cos(rad)); } else { - length = width - } - } else { // height < width - if (rotation > 0) { length = height / Math.abs(Math.sin(rad)); - } else { - length = height; } + } else { + length = width; } // calculate line coordinates (in percent)