("dashOnGesture",
{
bubbles: true,
detail: {
points: this._points,
gesture: GestureUtils.Gestures.Stroke,
bounds: B
}
}
)
)
this._points = [];
}
}
document.removeEventListener("pointermove", this.onPointerMove);
document.removeEventListener("pointerup", this.onPointerUp);
}
@computed get svgBounds() {
const xs = this._points.map(p => p.X);
const ys = this._points.map(p => p.Y);
const right = Math.max(...xs);
const left = Math.min(...xs);
const bottom = Math.max(...ys);
const top = Math.min(...ys);
return { right: right, left: left, bottom: bottom, top: top, width: right - left, height: bottom - top };
}
// TODO: find a way to reference this function from InkingStroke instead of copy pastign here. copied bc of weird error when on mobile view
CreatePolyline(points: { X: number, Y: number }[], left: number, top: number, color?: string, width?: number) {
const pts = points.reduce((acc: string, pt: { X: number, Y: number }) => acc + `${pt.X - left},${pt.Y - top} `, "");
return (
);
}
@computed get currentStroke() {
if (this._points.length <= 1) {
return (null);
}
const B = this.svgBounds;
return (
);
}
@action
enableMobileInkBox = (content: MobileInkBoxContent) => {
this.showMobileInkOverlay = content.enableBox;
}
render() {
return (
{this.currentStroke}
{this.props.children}
{this._palette}
{this.showMobileInkOverlay ? : <>>}
);
}
}
Scripting.addGlobal("GestureOverlay", GestureOverlay);
Scripting.addGlobal(function setPen(width: any, color: any) { runInAction(() => { GestureOverlay.Instance.Color = color; GestureOverlay.Instance.Width = width; }); });
Scripting.addGlobal(function resetPen() { runInAction(() => { GestureOverlay.Instance.Color = "rgb(244, 67, 54)"; GestureOverlay.Instance.Width = 5; }); });