From 7b3e1614fa645014c7de69a0f2057e389074c0ed Mon Sep 17 00:00:00 2001 From: vkalev Date: Sat, 20 Nov 2021 15:38:54 -0500 Subject: updating intersections to map t-values to inks --- .../collectionFreeForm/CollectionFreeFormView.tsx | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 4447b7624..6f79c5eab 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -647,15 +647,18 @@ export class CollectionFreeFormView extends CollectionSubView 0) { - intersections.forEach(ink => { - if (!this._deleteList.includes(ink)) { - this._deleteList.push(ink); - // Lowering ink opacity to give the user a visual indicator of deletion. - ink.Document.opacity = 0.5; - } - }); + const intersections: { [id: number]: DocumentView[] } = this.getEraserIntersections(); + if (intersections) { + for (const t in intersections) { + const inks = intersections[t]; + inks.forEach(ink => { + if (!this._deleteList.includes(ink)) { + this._deleteList.push(ink); + // Lowering ink opacity to give the user a visual indicator of deletion. + ink.Document.opacity = 0.5; + } + }); + } } } if (InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE)) { @@ -675,10 +678,10 @@ export class CollectionFreeFormView extends CollectionSubView { - const inks: DocumentView[] = []; + getEraserIntersections = (): { [id: number]: DocumentView[] } => { + const intersections: { [id: number]: DocumentView[] } = {}; this.childDocs .filter(doc => doc.type === DocumentType.INK) .forEach(doc => { @@ -690,16 +693,21 @@ export class CollectionFreeFormView extends CollectionSubView ({ x: p.X, y: p.Y }))).intersects( + const curve = new Bezier(array.map(p => ({ x: p.X, y: p.Y }))); + const t = curve.intersects( { p1: { x: prevPointInkSpace.X, y: prevPointInkSpace.Y }, p2: { x: currPointInkSpace.X, y: currPointInkSpace.Y } }); - if (inkView && intersects.length > 0) inks.push(inkView); + if (inkView && t) { + t.forEach(val => { + intersections[+t[0]] ? intersections[+t[0]].push(inkView) : intersections[+t[0]] = [inkView]; + }); + } } } }); - return inks; + return intersections; } handle1PointerMove = (e: TouchEvent, me: InteractionUtils.MultiTouchEvent) => { -- cgit v1.2.3-70-g09d2