costum shape
This commit is contained in:
@@ -481,6 +481,29 @@ export const useTransformHandlers = (
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
} else if (selectedObject.type === "custom-shape") {
|
||||
// Scale each vertex in-place; no width/height anchor needed
|
||||
const oldPoints = selectedObject.points ?? [];
|
||||
const newPoints = oldPoints.map((val, i) =>
|
||||
i % 2 === 0 ? val * scaleX : val * scaleY,
|
||||
);
|
||||
|
||||
// Recompute axis-aligned bounding box from the scaled points
|
||||
const xs = newPoints.filter((_, i) => i % 2 === 0);
|
||||
const ys = newPoints.filter((_, i) => i % 2 !== 0);
|
||||
const newWidth =
|
||||
xs.length > 0 ? Math.max(...xs) - Math.min(...xs) : 0;
|
||||
const newHeight =
|
||||
ys.length > 0 ? Math.max(...ys) - Math.min(...ys) : 0;
|
||||
|
||||
updateObject(selectedObject.id, {
|
||||
x: node.x(),
|
||||
y: node.y(),
|
||||
rotation: node.rotation(),
|
||||
points: newPoints,
|
||||
width: Math.max(1, newWidth),
|
||||
height: Math.max(1, newHeight),
|
||||
});
|
||||
} else {
|
||||
// Default for other objects (image, etc.)
|
||||
updateObject(selectedObject.id, {
|
||||
|
||||
Reference in New Issue
Block a user