feat: support segment midpoints in line editor (#5641)

* feat: support segment midpoints in line editor

* fix tests

* midpoints working in bezier curve

* midpoint working with non zero roughness

* calculate beizer curve control points for points >2

* unnecessary rerender

* don't show phantom points inside editor for short segments

* don't show phantom points for small curves

* improve the algo for plotting midpoints on bezier curve by taking arc lengths and doing binary search

* fix tests finally

* fix naming

* cache editor midpoints

* clear midpoint cache when undo

* fix caching

* calculate index properly when not all segments have midpoints

* make sure correct element version is fetched from cache

* chore

* fix

* direct comparison for equal points

* create arePointsEqual util

* upate name

* don't update cache except inside getter

* don't compute midpoints outside editor unless 2pointer lines

* update cache to object and burst when Zoom updated as well

* early return if midpoints not present outside editor

* don't early return

* cleanup

* Add specs

* fix
This commit is contained in:
Aakansha Doshi 2022-09-14 19:55:54 +05:30 committed by GitHub
parent c5869979c8
commit 0d1058a596
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 666 additions and 113 deletions

View file

@ -10982,7 +10982,6 @@ Object {
"hoverPointIndex": -1,
"isDragging": false,
"lastUncommittedPoint": null,
"midPointHovered": false,
"pointerDownState": Object {
"lastClickedPoint": -1,
"prevSelectedPointsIndices": null,
@ -10991,6 +10990,7 @@ Object {
"x": 0,
"y": 0,
},
"segmentMidPointHoveredCoords": null,
"selectedPointsIndices": null,
"startBindingElement": "keep",
},
@ -11208,7 +11208,6 @@ Object {
"hoverPointIndex": -1,
"isDragging": false,
"lastUncommittedPoint": null,
"midPointHovered": false,
"pointerDownState": Object {
"lastClickedPoint": -1,
"prevSelectedPointsIndices": null,
@ -11217,6 +11216,7 @@ Object {
"x": 0,
"y": 0,
},
"segmentMidPointHoveredCoords": null,
"selectedPointsIndices": null,
"startBindingElement": "keep",
},
@ -11661,7 +11661,6 @@ Object {
"hoverPointIndex": -1,
"isDragging": false,
"lastUncommittedPoint": null,
"midPointHovered": false,
"pointerDownState": Object {
"lastClickedPoint": -1,
"prevSelectedPointsIndices": null,
@ -11670,6 +11669,7 @@ Object {
"x": 0,
"y": 0,
},
"segmentMidPointHoveredCoords": null,
"selectedPointsIndices": null,
"startBindingElement": "keep",
},
@ -12066,7 +12066,6 @@ Object {
"hoverPointIndex": -1,
"isDragging": false,
"lastUncommittedPoint": null,
"midPointHovered": false,
"pointerDownState": Object {
"lastClickedPoint": -1,
"prevSelectedPointsIndices": null,
@ -12075,6 +12074,7 @@ Object {
"x": 0,
"y": 0,
},
"segmentMidPointHoveredCoords": null,
"selectedPointsIndices": null,
"startBindingElement": "keep",
},