/** * 손으로 짠 그리기 도구 공용(337 설계 2-14) — 점 물음 사건 · 옵션 한 줄 · 끝 상태 · 마지막 그린 끝점(LINE.END). * 선 · 폴리선 · 원 · 사각형 · 다각형 · 타원이 같이 씀. */ import { Point } from '@flatten-js/core'; import { type OptionSpec, type XY, recall, remember } from '../../commands/prompt'; import { END_STATE } from '../tool.types'; /** 옵션 하나 — 그림 「label(kw)」 · 사건 `OPTION.` · 맞추기 kw · en */ export const option = (key: string, kw: string, label: string, en = key): OptionSpec => ({ key, kw, en, label, }); /** 첫 점 물음(기준점 없음) — 누름 · 절대 좌표만 */ export const firstPointEvents = (actions: string | string[], target: string) => ({ MOUSE_CLICK: { actions, target }, ABSOLUTE_POINT_INPUT: { actions, target }, }); /** 기준점 있는 점 물음 — 누름 · 절대 · 상대 · 거리 숫자 */ export const pointEvents = (actions: string | string[], target: string) => ({ ...firstPointEvents(actions, target), RELATIVE_POINT_INPUT: { actions, target }, NUMBER_INPUT: { actions, target }, }); /** 명령 끝 상태 — 들면 쉬는 상태(선택 도구)로 */ export const END = { [END_STATE]: { type: 'final' as const } }; // 마지막 선 · 폴리선 · 호 끝점 — LINE · PLINE 첫 점 빈 Enter 가 여기서 이어 그림(오토캐드) const LINE_END = 'LINE.END'; export const rememberDrawEnd = (point: XY): void => remember(LINE_END, { x: point.x, y: point.y }); export const lastDrawEnd = (): Point | null => { const point = recall(LINE_END); return point ? new Point(point.x, point.y) : null; };