Skip to content

Conversation

@rhino-ty
Copy link
Collaborator

@rhino-ty rhino-ty commented Jan 16, 2025

πŸ“‚ μž‘μ—… λ‚΄μš©

closes #12

  • Bezier 곑선 보간법을 μ‚¬μš©ν•œ λΆ€λ“œλŸ¬μš΄ λ“œλ‘œμž‰ κ΅¬ν˜„
  • 4개 점을 μœ μ§€ν•˜λŠ” 포인트 버퍼 μ‹œμŠ€ν…œ κ΅¬ν˜„
  • 점 κ°œμˆ˜μ— λ”°λ₯Έ λ“œλ‘œμž‰ 둜직 뢄리 (1점: 원, 2점: 직선, 3점: 2차곑선, 4점: 3차곑선)
  • λ“œλ‘œμž‰ ν…ŒμŠ€νŠΈ μ „μš© νŽ˜μ΄μ§€ κ΅¬ν˜„ => ν˜„μž¬ μ†ŒμŠ€μ½”λ“œμ—λŠ” μ‚­μ œλΌμžˆμŒ.

πŸ’‘ μžμ„Έν•œ μ„€λͺ…

κΈ°μ‘΄ quadraticCurveTo 방식은 각 점이 μƒˆλ‘œμš΄ κ³‘μ„ μ˜ μ‹œμž‘μ μœΌλ‘œ μž¬μ‚¬μš©λ˜λ©΄μ„œ 선이 μ€‘λ³΅μœΌλ‘œ κ·Έλ €μ§€λŠ” λ¬Έμ œκ°€ μžˆμ—ˆμŠ΅λ‹ˆλ‹€. 해결해도 각이 계속 μ§€λŠ” ν˜„μƒμ„ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.
이λ₯Ό ν•΄κ²°ν•˜κΈ° μœ„ν•΄ λ‹€μŒκ³Ό 같은 λ°©μ‹μœΌλ‘œ κ°œμ„ ν–ˆμŠ΅λ‹ˆλ‹€.

  1. 4점 버퍼 μ‹œμŠ€ν…œμœΌλ‘œ 슀트둜크 νžˆμŠ€ν† λ¦¬ 관리
  2. 점 사이 거리λ₯Ό κ³ λ €ν•œ μ œμ–΄μ  계산
  3. 점 κ°œμˆ˜λ³„ λ Œλ”λ§ 둜직 뢄리 κ΅¬ν˜„

🚩 후속 μž‘μ—…

  • 더 λ‚˜μ€ 곑선 μ•Œκ³ λ¦¬μ¦˜ κ²€ν† 
  • λ“œλ‘œμž‰ 속도에 λ”°λ₯Έ 동적 tension 쑰절 κΈ°λŠ₯ μΆ”κ°€
  • λͺ¨μ„œλ¦¬ μ•ˆκ·Έλ €μ§€λŠ” μ΅œμ ν™” λΆ€λΆ„ μˆ˜μ •

βœ… μ…€ν”„ 체크리슀트

  • PR 제λͺ©μ„ ν˜•μ‹μ— 맞게 μž‘μ„±ν–ˆλ‚˜μš”?
  • 브랜치 μ „λž΅μ— λ§žλŠ” λΈŒλžœμΉ˜μ— PR을 올리고 μžˆλ‚˜μš”? (main이 μ•„λ‹™λ‹ˆλ‹€.)
  • μ΄μŠˆλŠ” close ν–ˆλ‚˜μš”?
  • Reviewers, Labelsλ₯Ό λ“±λ‘ν–ˆλ‚˜μš”?
  • μž‘μ—… 도쀑 λ¬Έμ„œ μˆ˜μ •μ΄ ν•„μš”ν•œ 경우 잘 μˆ˜μ •ν–ˆλ‚˜μš”?
  • ν…ŒμŠ€νŠΈλŠ” 잘 ν†΅κ³Όν–ˆλ‚˜μš”?
  • λΆˆν•„μš”ν•œ μ½”λ“œλŠ” μ œκ±°ν–ˆλ‚˜μš”?

…ation

- StrokeBuffer class using Catmull-Rom spline interpolation for smooth drawing
- Create standalone DrawingTest component for testing drawing functionality without game state
- Add dedicated route '/drawing-test' for testing canvas interactions
- Implement cursor canvas reference and coordinate scaling for accurate drawing
- Implement
  - Add quadraticCurveTo for smoother line drawing in `drawStroke`
  - Update point management system to handle 3-point curve generation in `continueDrawing`
- Problem : System creates duplicate line
  - Current logic keeps three points (prev-prev, prev, current)
  - When new point arrives, prev becomes prev-prev
  - This causes each curve section to be drawn twice
- Add
  - Custom Bezier curve control point calculation with tension
  - Adaptive curve rendering based on point count
- Fix
  - Update point buffer to maintain 4 points for cubic Bezier curves
  - Remove quadraticCurveTo and add bezierCurveTo that caused duplicate line issues
- Modify control point calculation using Catmull-Rom spline formula
- Higher tension now results in tighter curves, matching intuitive behavior
@rhino-ty rhino-ty added πŸ’» FE Frontend Code πŸ“ˆ Improvement Performance Optimization labels Jan 16, 2025
@rhino-ty rhino-ty self-assigned this Jan 16, 2025
@rhino-ty rhino-ty linked an issue Jan 16, 2025 that may be closed by this pull request
3 tasks
@github-actions
Copy link

πŸ“š Storybook preview deployed to: Visit Storybook Preview

- Simplify logic by replacing cubic Bezier curves with quadratic curves
- Improve performance with bit-shifting for midpoint calculations
- Remove redundant control point computations
- Maintain smooth curve quality while reducing computational overhead

This change improves drawing performance while keeping the same visual quality by
leveraging quadratic curves instead of cubic Bezier curves for path rendering.
@github-actions
Copy link

πŸ“š Storybook preview deployed to: Visit Storybook Preview

@github-actions
Copy link

πŸ“š Storybook preview deployed to: Visit Storybook Preview

@github-actions
Copy link

πŸ“š Storybook preview deployed to: Visit Storybook Preview

@rhino-ty rhino-ty merged commit af2505e into main Jan 23, 2025
2 checks passed
@github-actions
Copy link

🧹 Storybook preview for PR #13 has been removed.

github-actions bot added a commit that referenced this pull request Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

πŸ’» FE Frontend Code πŸ“ˆ Improvement Performance Optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

μΊ”λ²„μŠ€ 보간법 적용

4 participants