Skip to content

feat: add smooth freehand drawing with continuous drawing mode#779

Open
benoist wants to merge 41 commits intoklinecharts:mainfrom
coinrayio:feature/smooth-freehand-drawing
Open

feat: add smooth freehand drawing with continuous drawing mode#779
benoist wants to merge 41 commits intoklinecharts:mainfrom
coinrayio:feature/smooth-freehand-drawing

Conversation

@benoist
Copy link

@benoist benoist commented Jan 19, 2026

Summary

  • Add freePath overlay for freehand drawing with click-and-drag
  • Implement continuous drawing mode with sub-bar precision using float indices
  • Add floatIndexToTimestamp and timestampToFloatIndex methods for precise timestamp interpolation
  • Support drawing beyond the last candle (into the future)
  • Drawings persist correctly across timeframe changes

Changes

  • src/component/Overlay.ts: Add drawingMode property and continuous drawing methods
  • src/view/OverlayView.ts: Handle continuous drawing events and float index rendering
  • src/Store.ts: Add coordinateToFloatIndex, floatIndexToTimestamp, timestampToFloatIndex
  • src/extension/overlay/freePath.ts: New freehand drawing overlay
  • src/extension/figure/line.ts: Add lineCap and lineJoin support

Test plan

  • Draw freehand paths on the chart
  • Verify smooth rendering during and after drawing
  • Switch timeframes and verify drawings persist at correct positions
  • Draw past the last candle and verify it works

@benoist
Copy link
Author

benoist commented Jan 19, 2026

I left freePath option in as extension, as I believe these are on the same level as the other extension in this library and helps to test the code.

liihuu and others added 12 commits January 23, 2026 10:04
Co-authored-by: Abdulbasit Mamman <basttyy@gmail.com>
- Add continuous drawing mode for overlays (click-drag-release pattern)
- Implement smooth freehand drawing with sub-pixel precision using float indices
- Add precise timestamp interpolation for drawings to persist across timeframe changes
- Support drawing beyond the last candle (extrapolation into future)
- Add freePath overlay for freehand drawing
- Add lineCap/lineJoin support for smooth stroke rendering

New methods in Store:
- floatIndexToTimestamp(): converts float indices to interpolated timestamps
- timestampToFloatIndex(): converts precise timestamps back to float indices
@Basttyy Basttyy force-pushed the feature/smooth-freehand-drawing branch from 156fdf3 to b2ba3a5 Compare January 23, 2026 17:19
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.

3 participants