edit store
This commit is contained in:
@@ -772,7 +772,10 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
}
|
||||
|
||||
// برای مثلث و abstract، x و y در store گوشه بالا-چپ است اما در render مرکز استفاده میشود
|
||||
if (obj.type === "rectangle" && (obj.shapeType === "triangle" || obj.shapeType === "abstract")) {
|
||||
if (
|
||||
obj.type === "rectangle" &&
|
||||
(obj.shapeType === "triangle" || obj.shapeType === "abstract")
|
||||
) {
|
||||
// محاسبه مرکز از گوشه بالا-چپ
|
||||
const cx = (obj.x || 0) + w / 2;
|
||||
const cy = (obj.y || 0) + h / 2;
|
||||
@@ -798,8 +801,10 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
];
|
||||
|
||||
corners.forEach((corner) => {
|
||||
const rotatedX = corner.x * Math.cos(rot) - corner.y * Math.sin(rot);
|
||||
const rotatedY = corner.x * Math.sin(rot) + corner.y * Math.cos(rot);
|
||||
const rotatedX =
|
||||
corner.x * Math.cos(rot) - corner.y * Math.sin(rot);
|
||||
const rotatedY =
|
||||
corner.x * Math.sin(rot) + corner.y * Math.cos(rot);
|
||||
const finalX = cx + rotatedX;
|
||||
const finalY = cy + rotatedY;
|
||||
minX = Math.min(minX, finalX);
|
||||
@@ -816,7 +821,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
const startY = obj.y || 0;
|
||||
const endX = obj.width || 0;
|
||||
const endY = obj.height || 0;
|
||||
|
||||
|
||||
// برای arrow و line، bounding box از نقطه شروع تا نقطه پایان است
|
||||
minX = Math.min(minX, startX, endX);
|
||||
minY = Math.min(minY, startY, endY);
|
||||
|
||||
Reference in New Issue
Block a user