aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/InkStrokeProperties.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-11-30 23:37:49 -0500
committerbobzel <zzzman@gmail.com>2021-11-30 23:37:49 -0500
commit91247d583e5e4c7205a1ed764dd0e3a12af3be25 (patch)
tree57ab31e582d1af356242c1805b7d4d27e91970ac /src/client/views/InkStrokeProperties.ts
parentf313cfa5ae644eadb57d936bc81bd355e0c88e17 (diff)
fixed warnings/errors. added inkingStroke comments. need to double-click now to add a point to an ink stroke.
Diffstat (limited to 'src/client/views/InkStrokeProperties.ts')
-rw-r--r--src/client/views/InkStrokeProperties.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts
index 4808bbc77..7ab631b03 100644
--- a/src/client/views/InkStrokeProperties.ts
+++ b/src/client/views/InkStrokeProperties.ts
@@ -15,14 +15,15 @@ import { InkingStroke } from "./InkingStroke";
import { DocumentView } from "./nodes/DocumentView";
export class InkStrokeProperties {
- static Instance: InkStrokeProperties | undefined;
+ static _Instance: InkStrokeProperties | undefined;
+ public static get Instance() { return this._Instance || new InkStrokeProperties(); }
@observable _lock = false;
@observable _controlButton = false;
@observable _currentPoint = -1;
constructor() {
- InkStrokeProperties.Instance = this;
+ InkStrokeProperties._Instance = this;
reaction(() => this._controlButton, button => button && (CurrentUserUtils.SelectedTool = InkTool.None));
reaction(() => CurrentUserUtils.SelectedTool, tool => (tool !== InkTool.None) && (this._controlButton = false));
}
@@ -150,15 +151,15 @@ export class InkStrokeProperties {
} else {
const start = this._currentPoint === 0 ? 0 : this._currentPoint - 4;
const splicedPoints = ink.slice(start, start + (this._currentPoint === 0 || this._currentPoint === ink.length - 1 ? 4 : 8));
- var samples: Point[] = [];
+ const samples: Point[] = [];
var startDir = { x: 0, y: 0 };
var endDir = { x: 0, y: 0 };
for (var i = 0; i < splicedPoints.length / 4; i++) {
- var bez = new Bezier(splicedPoints.slice(i * 4, i * 4 + 4).map(p => ({ x: p.X, y: p.Y })));
+ const bez = new Bezier(splicedPoints.slice(i * 4, i * 4 + 4).map(p => ({ x: p.X, y: p.Y })));
if (i === 0) startDir = bez.derivative(0);
if (i === splicedPoints.length / 4 - 1) endDir = bez.derivative(1);
for (var t = 0; t < (i === splicedPoints.length / 4 - 1 ? 1 + 1e-7 : 1); t += 0.05) {
- var pt = bez.compute(t);
+ const pt = bez.compute(t);
samples.push(new Point(pt.x, pt.y));
}
}
@@ -209,12 +210,12 @@ export class InkStrokeProperties {
const ptFromScreen = view.ComponentView?.ptFromScreen;
const ptToScreen = view.ComponentView?.ptToScreen;
return !ptToScreen || !ptFromScreen ? ink :
- ink.map(i => ptToScreen(i)).map(i => {
+ ink.map(ptToScreen).map(i => {
const pvec = { X: i.X - scrpt.x, Y: i.Y - scrpt.y };
const svec = pvec.X * scrVec.x * scaling + pvec.Y * scrVec.y * scaling;
const ovec = -pvec.X * scrVec.y + pvec.Y * (scrVec.x);
const newscrpt = { X: scrpt.x + svec * scrVec.x - ovec * scrVec.y, Y: scrpt.y + svec * scrVec.y + ovec * scrVec.x };
- const newpt = ptFromScreen!(newscrpt);
+ const newpt = ptFromScreen(newscrpt);
return newpt;
});
});