fix line and peykan in viwer
This commit is contained in:
@@ -249,6 +249,7 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(({ page, scale = 1 },
|
|||||||
// در Konva Line، points به صورت [0, 0, endX - startX, endY - startY] است
|
// در Konva Line، points به صورت [0, 0, endX - startX, endY - startY] است
|
||||||
const startX = (obj.x || 0) * scale;
|
const startX = (obj.x || 0) * scale;
|
||||||
const startY = (obj.y || 0) * scale;
|
const startY = (obj.y || 0) * scale;
|
||||||
|
// width و height مستقیماً مختصات نقطه پایان هستند
|
||||||
const endX = (obj.width ?? obj.x ?? 0) * scale;
|
const endX = (obj.width ?? obj.x ?? 0) * scale;
|
||||||
const endY = (obj.height ?? obj.y ?? 0) * scale;
|
const endY = (obj.height ?? obj.y ?? 0) * scale;
|
||||||
const dx = endX - startX;
|
const dx = endX - startX;
|
||||||
@@ -279,6 +280,7 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(({ page, scale = 1 },
|
|||||||
// در Konva Arrow، points به صورت [0, 0, endX - startX, endY - startY] است
|
// در Konva Arrow، points به صورت [0, 0, endX - startX, endY - startY] است
|
||||||
const startX = (obj.x || 0) * scale;
|
const startX = (obj.x || 0) * scale;
|
||||||
const startY = (obj.y || 0) * scale;
|
const startY = (obj.y || 0) * scale;
|
||||||
|
// width و height مستقیماً مختصات نقطه پایان هستند
|
||||||
const endX = (obj.width ?? obj.x ?? 0) * scale;
|
const endX = (obj.width ?? obj.x ?? 0) * scale;
|
||||||
const endY = (obj.height ?? obj.y ?? 0) * scale;
|
const endY = (obj.height ?? obj.y ?? 0) * scale;
|
||||||
const dx = endX - startX;
|
const dx = endX - startX;
|
||||||
|
|||||||
@@ -51,15 +51,15 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
|
|||||||
visible: true,
|
visible: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
// برای line و arrow، width و height در viewer-data.json به عنوان اندازه هستند
|
// برای line و arrow، width و height در viewer-data.json به عنوان مختصات انتهایی هستند
|
||||||
// اما در EditorObject به عنوان مختصات انتهایی استفاده میشوند
|
// در EditorObject هم به عنوان مختصات انتهایی ذخیره میشوند
|
||||||
if (obj.type === 'line' || obj.type === 'arrow') {
|
if (obj.type === 'line' || obj.type === 'arrow') {
|
||||||
|
// width و height مستقیماً مختصات نقطه پایان هستند
|
||||||
if (obj.width !== undefined) {
|
if (obj.width !== undefined) {
|
||||||
baseObject.width = obj.x + obj.width;
|
baseObject.width = obj.width;
|
||||||
}
|
}
|
||||||
if (obj.height !== undefined) {
|
if (obj.height !== undefined) {
|
||||||
// برای line، height ممکن است ضخامت باشد، اما برای arrow طول عمودی است
|
baseObject.height = obj.height;
|
||||||
baseObject.height = obj.y + obj.height;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (obj.width !== undefined) baseObject.width = obj.width;
|
if (obj.width !== undefined) baseObject.width = obj.width;
|
||||||
|
|||||||
Reference in New Issue
Block a user