From 3bba8465a3d823596e7f8cfab24b9afa9c05cf2c Mon Sep 17 00:00:00 2001
From: eleanor-park <eleanor_park@brown.edu>
Date: Wed, 10 Apr 2024 22:04:55 -0400
Subject: eraser circled created

---
 .../collectionFreeForm/CollectionFreeFormView.tsx  | 65 +++++++++++-----------
 1 file changed, 33 insertions(+), 32 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 26afa5297..a72b499b2 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -625,8 +625,8 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
                         setupMoveUpEvents(this, e, this.onEraserMove, this.onEraserUp, emptyFunction);
                         break;
                     case InkTool.RadiusEraser:
-                        this._batch = UndoManager.StartBatch('collectionErase');
-                        setupMoveUpEvents(this, e, this.onEraserMove, this.onEraserUp, emptyFunction);
+                        // this._batch = UndoManager.StartBatch('collectionErase');
+                        // setupMoveUpEvents(this, e, this.onEraserMove, this.onEraserUp, emptyFunction);
                         break;
                     case InkTool.None:
                         if (!(this._props.layoutEngine?.() || StrCast(this.layoutDoc._layoutEngine))) {
@@ -851,43 +851,44 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
         const inkStroke = ink?.ComponentView as InkingStroke;
         const { inkData } = (inkStroke).inkScaledData();
 
-        const eraserInkData = inkStroke.splitByEraser(inkCoords, eraseWidth) as InkData;
+        const eraserInkData = inkStroke.splitByEraser(inkCoords, eraseWidth);
 
         const tVals: number[] = []; // should be the tvals of the intersections
 
         for (var i = 0; i < eraserInkData.length - 3; i += 4) {
-            const currCurveT = Math.floor(i/4);
-            const eraserBezier = InkField.Segment(eraserInkData, i);
-            for (var j = 0; j < inkData.length; j +=4) {
-            const inkSegment: Bezier = InkField.Segment(inkData, i);
-                this.bintersects(inkSegment, eraserBezier).forEach((val: string | number, i: number) => {
-                    // Converting the Bezier.js Split type to a t-value number.
-                    const t = +val.toString().split('/')[0];
-                    if (i % 2 === 0 && !tVals.includes(t)) tVals.push(t); // bcz: Hack!  don't know why but intersection points are doubled from bezier.js (but not identical).
-                });
-            }
-        }
-
-        for (var i = 0; i < inkData.length - 3; i += 4) {
-            const currCurveT = Math.floor(i/4);
+            const eraserBezier: Bezier = InkField.Segment(eraserInkData, i);
+            segment1.push(eraserBezier);
+            for (var j = 0; j < inkData.length; j += 4) {
             const inkSegment: Bezier = InkField.Segment(inkData, i);
-            if (tVals[0] >= currCurveT && tVals[0] < currCurveT+1) {
-                tVals.shift()
-                i -= 4;
-                if (eraseT - eraseWidth > currCurveT && eraseT + eraseWidth < currCurveT + 1) {
-                    segment1.push(inkSegment.split(0, eraseT - currCurveT - eraseWidth));
-                    segment2.push(inkSegment.split(eraseT - currCurveT + eraseWidth, 1));
-                } else if (eraseT - eraseWidth < currCurveT) {
-                    segment2.push(inkSegment.split(eraseT - currCurveT + eraseWidth, 1));
-                } else if (eraseT + eraseWidth > currCurveT + 1) {
-                    segment1.push(inkSegment.split(0, eraseT - currCurveT - eraseWidth));
-                }
-            } else if (eraseT > currCurveT + 1) {
-                segment1.push(inkSegment);
-            } else {
-                segment2.push(inkSegment);
+            // this.bintersects(inkSegment, eraserBezier).forEach((val: string | number, i: number) => {
+            //     // Converting the Bezier.js Split type to a t-value number.
+            //     const t = +val.toString().split('/')[0];
+            //     if (i % 2 === 0 && !tVals.includes(t)) tVals.push(t); // bcz: Hack!  don't know why but intersection points are doubled from bezier.js (but not identical).
+            // });
             }
         }
+        // segment1.push(eraserBezier);
+    
+        // for (var i = 0; i < inkData.length - 3; i += 4) {
+        //     const currCurveT = Math.floor(i/4);
+        //     const inkSegment: Bezier = InkField.Segment(inkData, i);
+        //     if (tVals[0] >= currCurveT && tVals[0] < currCurveT+1) {
+        //         tVals.shift()
+        //         i -= 4;
+        //         if (eraseT - eraseWidth > currCurveT && eraseT + eraseWidth < currCurveT + 1) {
+        //             segment1.push(inkSegment.split(0, eraseT - currCurveT - eraseWidth));
+        //             segment2.push(inkSegment.split(eraseT - currCurveT + eraseWidth, 1));
+        //         } else if (eraseT - eraseWidth < currCurveT) {
+        //             segment2.push(inkSegment.split(eraseT - currCurveT + eraseWidth, 1));
+        //         } else if (eraseT + eraseWidth > currCurveT + 1) {
+        //             segment1.push(inkSegment.split(0, eraseT - currCurveT - eraseWidth));
+        //         }
+        //     } else if (eraseT > currCurveT + 1) {
+        //         segment1.push(inkSegment);
+        //     } else {
+        //         segment2.push(inkSegment);
+        //     }
+        // }
 
         // push 1 or both segments if they are not empty
         if (segment1.length && (Math.abs(segment1[0].points[0].x - segment1[0].points.lastElement().x) > 0.5 || Math.abs(segment1[0].points[0].y - segment1[0].points.lastElement().y) > 0.5)) {
-- 
cgit v1.2.3-70-g09d2

