- 복제 함수 cloneKeepingLook 한 곳(move-tool.helpers) — 옮기기 · 크기 · 회전은 id · 묶음까지 그대로 · 복사 · 배열은 새 id - LineEntity · ArcEntity clone 이 색 · 층 · 선 꼴 유지(폴리선 자식 포함) - 복사가 누를 때마다 원본을 한 벌씩 더 쌓던 흠 고침 - ArcEntity mirror 가 축 각도 따름(α → 2θ − α) · 그리기 끝각 = 시작각 ± 쓸어간 각(끝각 0 → 2π 온 원 흠) - DXF 내보내기 시계방향 호는 시작 · 끝 바꿔 같은 작은 호 - 시험: ArcEntity.test.ts 10 · resources/tester/cad/clone-keeps-look.test.ts 7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UoSr2sqvYtBf1dtQdus88s
29 lines
891 B
TypeScript
29 lines
891 B
TypeScript
import type { Entity } from '../entities/Entity';
|
|
import { copyStyle } from './modify/modify.helpers';
|
|
|
|
/**
|
|
* Move entities by the difference between the start and end points
|
|
* @param entities
|
|
* @param deltaX
|
|
* @param deltaY
|
|
*/
|
|
export function moveEntities(entities: Entity[], deltaX: number, deltaY: number) {
|
|
for (const entity of entities) {
|
|
entity.move(deltaX, deltaY);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 복제해도 색 · 층 · 선 꼴 · 투명도를 그대로 둔다(`clone()` 은 활성 층 · 흰색으로 새로 만듦).
|
|
* `inPlace` = 옮기기 · 크기 · 회전처럼 같은 도형을 갈아 끼울 때 — id · 묶음까지 그대로.
|
|
*/
|
|
export function cloneKeepingLook(entity: Entity, inPlace = false): Entity {
|
|
const copy = copyStyle(entity, entity.clone());
|
|
copy.opacity = entity.opacity;
|
|
if (inPlace) {
|
|
copy.id = entity.id;
|
|
copy.groupId = entity.groupId;
|
|
}
|
|
return copy;
|
|
}
|