From fb2807a98c3da49c61467f8863a091713491adac Mon Sep 17 00:00:00 2001 From: irismarie Date: Wed, 4 Nov 2020 18:17:28 +0100 Subject: [PATCH] lock aspect ratio, fixes #206 --- src/widget/widget-factory.js | 1 + src/widget/widgets/line.js | 13 +------------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/widget/widget-factory.js b/src/widget/widget-factory.js index b13255e..00dd41e 100644 --- a/src/widget/widget-factory.js +++ b/src/widget/widget-factory.js @@ -192,6 +192,7 @@ class WidgetFactory { widget.customProperties.border_color_opacity = 1; widget.customProperties.border_width = 2; widget.customProperties.rotation = 0; + widget.customProperties.lockAspect = true; break; default: diff --git a/src/widget/widgets/line.js b/src/widget/widgets/line.js index 93249f6..bfdbe9c 100644 --- a/src/widget/widgets/line.js +++ b/src/widget/widgets/line.js @@ -49,18 +49,7 @@ class WidgetLine extends Component { height = this.state.height; } - // calculate the length of the line - let length = 0; - if (rotation > 0) { - if (width <= height) { - length = width / Math.abs(Math.cos(rad)); - } - else { - length = height / Math.abs(Math.sin(rad)); - } - } else { - length = width; - } + let length = width; // calculate line coordinates (in percent) const x1 = width * 0.5 - 0.5 * Math.cos(rad) * length;