Skip to content

Commit

Permalink
fix: handle negative values for width/height on ellipse and rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrosman committed Jun 7, 2024
1 parent 049900c commit 750b516
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/composables/tools/useEllipse/useEllipse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export function useEllipse({ base = 'edge'}: UseEllipseOptions = {}): Tool<Ellip
h('ellipse', {
cx: ellipse.x,
cy: ellipse.y,
rx: ellipse.width / 2,
ry: ellipse.height / 2,
rx: Math.abs(ellipse.width / 2),
ry: Math.abs(ellipse.height / 2),
stroke: ellipse.color,
'stroke-width': ellipse.thickness
})
Expand Down
8 changes: 4 additions & 4 deletions src/composables/tools/useRectangle/useRectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export function useRectangle(): Tool<Rectangle> {

const ShapeSvgComponent = createShapeSvgComponent<Rectangle>((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
})
Expand Down

0 comments on commit 750b516

Please sign in to comment.