优化预览

This commit is contained in:
iqudoo
2026-06-13 05:51:48 +08:00
parent 2a43df00c6
commit a08fbd1eb6
3 changed files with 30 additions and 12 deletions

View File

@@ -152,6 +152,27 @@ export const DEFAULT_CUT_LINE_CONFIG: CutLineConfig = {
color: '#cccccc',
};
/** 裁切线有效线宽 (mm),预览与 PDF 共用 */
export function getCutLineStrokeWidthMm(cutLine: Pick<CutLineConfig, 'width'>): number {
return Math.max(0.02, cutLine.width);
}
/** 虚线单段长度 (mm),预览与 PDF 共用 */
export function getCutLineDashSegmentMm(cutLine: Pick<CutLineConfig, 'style' | 'width'>): number {
if (cutLine.style !== 'dashed') return 0;
return Math.max(0.5, cutLine.width * 4);
}
/** 预览 SVG strokeDasharrayscale 为 mm→px 比例 */
export function formatCutLineSvgDashArray(
cutLine: Pick<CutLineConfig, 'style' | 'width'>,
scale: number
): string | undefined {
if (cutLine.style !== 'dashed') return undefined;
const seg = getCutLineDashSegmentMm(cutLine) * scale;
return `${seg} ${seg}`;
}
export interface GridCutLinePositions {
xs: number[];
ys: number[];