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] است
|
||||
const startX = (obj.x || 0) * scale;
|
||||
const startY = (obj.y || 0) * scale;
|
||||
// width و height مستقیماً مختصات نقطه پایان هستند
|
||||
const endX = (obj.width ?? obj.x ?? 0) * scale;
|
||||
const endY = (obj.height ?? obj.y ?? 0) * scale;
|
||||
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] است
|
||||
const startX = (obj.x || 0) * scale;
|
||||
const startY = (obj.y || 0) * scale;
|
||||
// width و height مستقیماً مختصات نقطه پایان هستند
|
||||
const endX = (obj.width ?? obj.x ?? 0) * scale;
|
||||
const endY = (obj.height ?? obj.y ?? 0) * scale;
|
||||
const dx = endX - startX;
|
||||
|
||||
@@ -51,15 +51,15 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
|
||||
visible: true,
|
||||
};
|
||||
|
||||
// برای line و arrow، width و height در viewer-data.json به عنوان اندازه هستند
|
||||
// اما در EditorObject به عنوان مختصات انتهایی استفاده میشوند
|
||||
// برای line و arrow، width و height در viewer-data.json به عنوان مختصات انتهایی هستند
|
||||
// در EditorObject هم به عنوان مختصات انتهایی ذخیره میشوند
|
||||
if (obj.type === 'line' || obj.type === 'arrow') {
|
||||
// width و height مستقیماً مختصات نقطه پایان هستند
|
||||
if (obj.width !== undefined) {
|
||||
baseObject.width = obj.x + obj.width;
|
||||
baseObject.width = obj.width;
|
||||
}
|
||||
if (obj.height !== undefined) {
|
||||
// برای line، height ممکن است ضخامت باشد، اما برای arrow طول عمودی است
|
||||
baseObject.height = obj.y + obj.height;
|
||||
baseObject.height = obj.height;
|
||||
}
|
||||
} else {
|
||||
if (obj.width !== undefined) baseObject.width = obj.width;
|
||||
|
||||
Reference in New Issue
Block a user