Skip to content

[refactor/MAT-902] DrawingCanvas Catmull-Rom + IncrementalPathBuilder 적용#351

Draft
b0nsu wants to merge 3 commits into
developfrom
refactor/mat-902-catmull-rom-incremental
Draft

[refactor/MAT-902] DrawingCanvas Catmull-Rom + IncrementalPathBuilder 적용#351
b0nsu wants to merge 3 commits into
developfrom
refactor/mat-902-catmull-rom-incremental

Conversation

@b0nsu
Copy link
Copy Markdown
Collaborator

@b0nsu b0nsu commented May 26, 2026

Summary

라이브 path smoothing 을 quadratic Bézier full-rebuild → centripetal Catmull-Rom + frozen-prefix 증분 빌드로 교체.

Linear

Changes

  • `smoothing.ts` 재작성
    • `buildSmoothPath`: quadratic → centripetal Catmull-Rom cubic Bézier (export 시그니처 유지)
    • `centripetalControlPointsMut`: mutable singleton control point cache (internal, export 안 함 — nested 호출 silent bug 방지)
    • `IncrementalPathBuilder` 클래스: `reset()` / `update(points)` API, frozen prefix 누적 + trailing 재계산
  • `DrawingCanvas`:
    • `incrementalBuilderRef` 추가
    • `startStroke` 에서 `reset()`, `addPoint` 에서 `update()` 로 livePath 갱신
    • finalize / load 는 기존 `buildSmoothPath` 그대로

Testing

  • `pnpm typecheck && pnpm lint && pnpm build` 통과

Risk / Impact

  • props / imperative API 변경 없음
  • 시각 변화 (의도된): 같은 점 시퀀스에서 곡선 모양이 약간 다름 (centripetal 이 코너에서 더 부드러움). 직렬화 데이터 호환 유지
  • 외부 API: `buildSmoothPath` / `IncrementalPathBuilder` 노출. `centripetalControlPointsMut` 는 internal 로 한정
  • 독립 base (develop)

…r 적용

- smoothing.ts: quadratic Bézier → centripetal Catmull-Rom cubic Bézier
- centripetalControlPointsMut: mutable 캐시로 per-call alloc 제거
- IncrementalPathBuilder: 라이브 드로잉 path 증분 빌드
  · frozen prefix(points[0..n-3])를 SkPath에 누적, trailing ~2 segments 만 매 update 재계산
  · 200-point 한 획 기준 addPoint 199 → ~3 segment 계산 (~66× 가속)
- DrawingCanvas: incrementalBuilderRef 추가, addPoint/startStroke 에서 update/reset 사용
- finalize/load 는 기존 buildSmoothPath 전체 빌드 그대로

buildSmoothPath export 시그니처 유지. 시각적 곡선 모양만 코너에서 더 자연스러움(centripetal).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@linear
Copy link
Copy Markdown

linear Bot commented May 26, 2026

MAT-902

b0nsu and others added 2 commits May 26, 2026 16:15
mutable singleton 반환 패턴이라 외부 caller 가 nested 호출 시 cp1x/cp1y 가 덮어쓰여 silent bug 가능. export 제거해 module 내부 전용으로 한정.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…T-911)

buildSmoothPath 와 IncrementalPathBuilder.update 가 같은 short-path special case (0/1/2점) 분기 + 첫 점 moveTo 를 따로 가지고 있어서 drift 위험. 공통 buildShortPath helper 로 추출.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant