From 750b516b3b2c0b34680e8f7e8e495672fd4f5872 Mon Sep 17 00:00:00 2001 From: Robert Rosman Date: Fri, 7 Jun 2024 21:55:49 +0200 Subject: [PATCH] fix: handle negative values for width/height on ellipse and rectangle --- src/composables/tools/useEllipse/useEllipse.ts | 4 ++-- src/composables/tools/useRectangle/useRectangle.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/composables/tools/useEllipse/useEllipse.ts b/src/composables/tools/useEllipse/useEllipse.ts index 5842094..86e879e 100644 --- a/src/composables/tools/useEllipse/useEllipse.ts +++ b/src/composables/tools/useEllipse/useEllipse.ts @@ -65,8 +65,8 @@ export function useEllipse({ base = 'edge'}: UseEllipseOptions = {}): Tool { const ShapeSvgComponent = createShapeSvgComponent((rectangle) => h('rect', { - x: rectangle.x, - y: rectangle.y, - width: rectangle.width, - height: rectangle.height, + x: rectangle.width > 0 ? rectangle.x : rectangle.x + rectangle.width, + y: rectangle.height > 0 ? rectangle.y : rectangle.y + rectangle.height, + width: Math.abs(rectangle.width), + height: Math.abs(rectangle.height), stroke: rectangle.color, 'stroke-width': rectangle.thickness })