优化
This commit is contained in:
15
src/utils.ts
15
src/utils.ts
@@ -30,6 +30,21 @@ export const VARIABLE_MAPPING_ROW_INDEX_LABEL = '数据序号';
|
||||
/** 粘贴副本时相对原位置的偏移 (mm) */
|
||||
export const PASTE_ELEMENT_OFFSET_MM = 2;
|
||||
|
||||
/** 在标签画布上居中放置元素(mm,保留 1 位小数) */
|
||||
export function centerElementOnLabel(
|
||||
labelWidth: number,
|
||||
labelHeight: number,
|
||||
elementWidth: number,
|
||||
elementHeight: number
|
||||
): { x: number; y: number } {
|
||||
const x = Math.round(((labelWidth - elementWidth) / 2) * 10) / 10;
|
||||
const y = Math.round(((labelHeight - elementHeight) / 2) * 10) / 10;
|
||||
return {
|
||||
x: Math.max(0, x),
|
||||
y: Math.max(0, y),
|
||||
};
|
||||
}
|
||||
|
||||
/** 深拷贝元素并生成新 id,用于复制/粘贴 */
|
||||
export function cloneTemplateElementsForPaste(
|
||||
elements: TemplateElement[],
|
||||
|
||||
Reference in New Issue
Block a user