Skip to content

Commit 5074419

Browse files
feat: enhance shape handling to include image dimensions in canvas
1 parent fb5c4cf commit 5074419

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

client/src/components/Canvas.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,12 +842,20 @@ if ((Object.values(SHAPE_TYPE).includes(activeTool) || activeTool.startsWith('br
842842
}
843843

844844
// For rectangle/line: set start/end
845-
if (sh.type === SHAPE_TYPE.RECTANGLE || sh.type === SHAPE_TYPE.LINE) {
845+
if (
846+
sh.type === SHAPE_TYPE.RECTANGLE ||
847+
sh.type === SHAPE_TYPE.LINE ||
848+
sh.type === SHAPE_TYPE.IMAGE
849+
) {
846850
// Normalize start/end so start is top-left and end is bottom-right for storage simplicity
847851
const newStart = { x: Math.min(minX, maxX), y: Math.min(minY, maxY) };
848852
const newEnd = { x: Math.max(minX, maxX), y: Math.max(minY, maxY) };
849853
sh.start = newStart;
850854
sh.end = newEnd;
855+
if (sh.type === SHAPE_TYPE.IMAGE) {
856+
sh.width = newEnd.x - newStart.x;
857+
sh.height = newEnd.y - newStart.y;
858+
}
851859
}
852860

853861
// For pen: scale all points from origBBox to new bbox

0 commit comments

Comments
 (0)