优化预览
This commit is contained in:
21
src/utils.ts
21
src/utils.ts
@@ -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 strokeDasharray,scale 为 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[];
|
||||
|
||||
Reference in New Issue
Block a user