diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/GestureOverlay.tsx | 1 | ||||
-rw-r--r-- | src/pen-gestures/ndollar.ts | 96 |
2 files changed, 29 insertions, 68 deletions
diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx index 402a7c20a..59d37df91 100644 --- a/src/client/views/GestureOverlay.tsx +++ b/src/client/views/GestureOverlay.tsx @@ -95,7 +95,6 @@ export class GestureOverlay extends ObservableReactComponent<React.PropsWithChil } @action onPointerDown = (e: React.PointerEvent) => { - DocumentView.DeselectAll(); (document.activeElement as HTMLElement)?.blur(); if (!(e.target as HTMLElement)?.className?.toString().startsWith('lm_')) { if ([InkTool.Highlighter, InkTool.Pen, InkTool.Write].includes(Doc.ActiveTool)) { diff --git a/src/pen-gestures/ndollar.ts b/src/pen-gestures/ndollar.ts index 04262b61f..f6e1c87fa 100644 --- a/src/pen-gestures/ndollar.ts +++ b/src/pen-gestures/ndollar.ts @@ -1,4 +1,5 @@ /* eslint-disable no-use-before-define */ +import { numberRange } from '../Utils'; import { Gestures } from './GestureTypes'; /** @@ -193,77 +194,38 @@ export class NDollarRecognizer { constructor( useBoundedRotationInvariance: boolean // constructor ) { + const rectMaker = (width: number, height1: number, height2: number) => [ + new Point(0, 0), // + new Point(0, height1), + new Point(width, height2), + new Point(width, 0), + new Point(0, 0), + ]; + + const arect = rectMaker(100, 100, 50); + const aorect = rectMaker(300, 100, 50); + const brect = rectMaker(100, 100, 200); + const borect = rectMaker(300, 100, 200); + const rect = rectMaker(100, 100, 100); + const orect = rectMaker(300, 100, 100); + const equilateral = [new Point(50, 100), new Point(100, 0), new Point(0, 0), new Point(50, 100)]; + const aequilateral = [new Point(20, 100), new Point(200, 0), new Point(0, 0), new Point(20, 100)]; + const bequilateral = [new Point(180, 100), new Point(200, 0), new Point(0, 0), new Point(180, 100)]; + const circle = numberRange(11).map(i => new Point(100 + 100 * Math.cos((i / 10) * Math.PI * 2), 100 + 100 * Math.sin((i / 10) * Math.PI * 2))); + const rightAngle = [new Point(0, 0), new Point(0, 100), new Point(200, 100)]; // - // one predefined multistroke for each multistroke type + // one predefined multistroke (plus its counterclockwise reversal for closed shapes) for each multistroke type // this.Multistrokes.push( - new Multistroke( - Gestures.Rectangle, - useBoundedRotationInvariance, - new Array([ - new Point(30, 146), // new Point(29, 160), new Point(30, 180), new Point(31, 200), - new Point(30, 222), // new Point(50, 219), new Point(70, 225), new Point(90, 230), - new Point(106, 225), // new Point(100, 200), new Point(106, 180), new Point(110, 160), - new Point(106, 146), // new Point(80, 150), new Point(50, 146), - new Point(30, 143), - ]) - ) - ); - this.Multistrokes.push(new Multistroke(Gestures.Rectangle, useBoundedRotationInvariance, new Array([new Point(30, 143), new Point(106, 146), new Point(106, 225), new Point(30, 222), new Point(30, 146)]))); - this.Multistrokes.push(new Multistroke(Gestures.Line, useBoundedRotationInvariance, [[new Point(12, 347), new Point(119, 347)]])); - this.Multistrokes.push( - new Multistroke( - Gestures.Triangle, // equilateral - useBoundedRotationInvariance, - new Array([new Point(40, 100), new Point(100, 200), new Point(140, 102), new Point(42, 100)]) - ) - ); - this.Multistrokes.push( - new Multistroke( - Gestures.Triangle, // equilateral - useBoundedRotationInvariance, - new Array([new Point(42, 100), new Point(140, 102), new Point(100, 200), new Point(40, 100)]) - ) - ); - this.Multistrokes.push( - new Multistroke( - Gestures.Circle, - useBoundedRotationInvariance, - new Array([ - new Point(200, 250), - new Point(240, 230), - new Point(248, 210), - new Point(248, 190), - new Point(240, 170), - new Point(200, 150), - new Point(160, 170), - new Point(151, 190), - new Point(151, 210), - new Point(160, 230), - new Point(201, 250), - ]) - ) - ); - this.Multistrokes.push( - new Multistroke( - Gestures.Circle, - useBoundedRotationInvariance, - new Array([ - new Point(201, 250), - new Point(160, 230), - new Point(151, 210), - new Point(151, 190), - new Point(160, 170), - new Point(200, 150), - new Point(240, 170), - new Point(248, 190), - new Point(248, 210), - new Point(240, 230), - new Point(200, 250), - ]) - ) + ...[arect, aorect, brect, borect, rect, orect].map(s => new Multistroke(Gestures.Rectangle, useBoundedRotationInvariance, [s])), + ...[arect, aorect, brect, borect, rect, orect].map(s => new Multistroke(Gestures.Rectangle, useBoundedRotationInvariance, [s.reverse()])), + ...[aequilateral, bequilateral, equilateral].map(s => new Multistroke(Gestures.Triangle, useBoundedRotationInvariance, [s])), + ...[aequilateral, bequilateral, equilateral].map(s => new Multistroke(Gestures.Triangle, useBoundedRotationInvariance, [s.reverse()])), + new Multistroke(Gestures.Circle, useBoundedRotationInvariance, [circle]), + new Multistroke(Gestures.Circle, useBoundedRotationInvariance, [circle.reverse()]), + new Multistroke(Gestures.RightAngle, useBoundedRotationInvariance, [rightAngle]), + new Multistroke(Gestures.Line, useBoundedRotationInvariance, [[new Point(12, 347), new Point(119, 347)]]) ); - this.Multistrokes.push(new Multistroke(Gestures.RightAngle, useBoundedRotationInvariance, new Array([new Point(0, 0), new Point(0, 100), new Point(200, 100)]))); NumMultistrokes = this.Multistrokes.length; // NumMultistrokes flags the end of the non user-defined gstures strokes // // PREDEFINED STROKES |