/** * 그리기 명령의 설정값 — AutoCAD의 MLSTYLE·HATCH 대화상자에 해당하는 상태. * 명령이 물어보는 값 중 "매번 묻지 않는 것"만 여기에 둔다. */ import type { HatchStyle } from '../entities/HatchEntity'; let mlineElements = 2; let mlineSpacing = 1; let hatchStyle: HatchStyle = 'pattern'; /** null이면 경계 크기에 맞춰 자동 계산한다 */ let hatchSpacing: number | null = null; let hatchAngle = Math.PI / 4; export const getMlineElements = () => mlineElements; export const getMlineSpacing = () => mlineSpacing; export const setMlineStyle = (elements: number, spacing: number) => { mlineElements = Math.max(2, Math.round(elements)); mlineSpacing = Math.abs(spacing) || 1; }; export const getHatchStyle = () => hatchStyle; export const getHatchSpacing = () => hatchSpacing; export const getHatchAngle = () => hatchAngle; export const setHatchStyle = (style: HatchStyle) => { hatchStyle = style; }; export const setHatchSpacing = (spacing: number | null) => { hatchSpacing = spacing; }; export const setHatchAngle = (angleRad: number) => { hatchAngle = angleRad; }; /** 경계 크기에 맞춘 기본 해치 간격 — 도면 축척이 달라도 눈에 보이게 한다 */ export const autoHatchSpacing = (width: number, height: number): number => Math.max(Math.hypot(width, height) / 30, 1e-6);