From 29de3f24c647e1a9cc78dbef2b757114d1c2d649 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sun, 14 Apr 2024 16:28:49 -0400
Subject: from last

---
 .../collectionFreeForm/CollectionFreeFormView.tsx      | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 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 4654de427..23fa227c2 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -751,15 +751,10 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
                 // create a new curve by appending all curves of the current segment together in order to render a single new stroke.
                 if (Doc.ActiveTool !== InkTool.StrokeEraser) {
                     this._eraserLock++;
-                    var segments;
-                    if (Doc.ActiveTool === InkTool.SegmentEraser) {
-                        segments = this.segmentErase(intersect.inkView, intersect.t); // intersect.t is where the eraser intersected the ink stroke - want to remove the segment that starts at the intersection just before this t value and goes to the one just after it
-                    } else if (Doc.ActiveTool === InkTool.RadiusEraser) {
-                        const inkCoords = intersect.inkView.ComponentView?.ptFromScreen?.(currPoint); // coordinates in ink space
-                        if (inkCoords !== undefined) {
-                            segments = this.radiusErase(intersect.inkView, intersect.t, inkCoords);
-                        }
-                    }
+                    const segments =
+                        Doc.ActiveTool === InkTool.SegmentEraser
+                            ? this.segmentErase(intersect.inkView, intersect.t) // intersect.t is where the eraser intersected the ink stroke - want to remove the segment that starts at the intersection just before this t value and goes to the one just after it
+                            : this.radiusErase(intersect.inkView, intersect.t, currPoint);
                     // } else if (Doc.ActiveTool === InkTool.RadiusEraser) {
                     //     segments = undefined;
                     // }
@@ -841,8 +836,11 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
     };
 
     @action
-    radiusErase = (ink: DocumentView, eraseT: number, inkCoords: { X: number; Y: number }): Segment[] => {
+    radiusErase = (ink: DocumentView, eraseT: number, screenEraserPt: { X: number; Y: number }): Segment[] => {
         const segments: Segment[] = [];
+        const inkCoords = ink.ComponentView?.ptFromScreen?.(screenEraserPt); // coordinates in ink space
+        if (!inkCoords) return [];
+
         var segment1: Segment = [];
         var segment2: Segment = [];
         const eraseRadius = ActiveInkWidth() / 2;
-- 
cgit v1.2.3-70-g09d2

