diff options
author | bobzel <zzzman@gmail.com> | 2021-11-30 23:45:53 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2021-11-30 23:45:53 -0500 |
commit | bb154f6c0c15cc0d63e6b31480f6c394814e328e (patch) | |
tree | 036a8ff6577a24aa071085319b9c34227947bce9 /src | |
parent | 91247d583e5e4c7205a1ed764dd0e3a12af3be25 (diff) |
from last
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/InkingStroke.tsx | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx index 0b3619b22..fc1727055 100644 --- a/src/client/views/InkingStroke.tsx +++ b/src/client/views/InkingStroke.tsx @@ -94,6 +94,10 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume return { X: tc[0], Y: tc[1] }; } + /** + * analyzes the ink stroke and saves the analysis of the stroke to the 'inkAnalysis' field, + * and the recognized words to the 'handwriting' + */ analyzeStrokes() { const data: InkData = Cast(this.dataDoc[this.fieldKey], InkField)?.inkData ?? []; CognitiveServices.Inking.Appliers.ConcatenateHandwriting(this.dataDoc, ["inkAnalysis", "handwriting"], [data]); @@ -156,6 +160,10 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume }), isEditing, isEditing, action(() => wasSelected && (InkStrokeProperties.Instance._currentPoint = -1))); } + /** + * @param scrPt a point in the screen coordinate space + * @returns the point in the ink data's coordinate space. + */ ptFromScreen = (scrPt: { X: number, Y: number }) => { const { inkScaleX, inkScaleY, inkStrokeWidth, inkTop, inkLeft } = this.inkScaledData(); const docPt = this.props.ScreenToLocalTransform().transformPoint(scrPt.X, scrPt.Y); @@ -165,6 +173,11 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume }; return inkPt; } + + /** + * @param inkPt a point in the ink data's coordinate space + * @returns the screen point corresponding to the ink point + */ ptToScreen = (inkPt: { X: number, Y: number }) => { const { inkScaleX, inkScaleY, inkStrokeWidth, inkTop, inkLeft } = this.inkScaledData(); const docPt = { @@ -226,7 +239,16 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume this._nearestScrPt = nearestPt; } + /** + * @returns the nearest screen point to the cursor (to render a highlight for the point to be added) + */ nearestScreenPt = () => this._nearestScrPt; + + /** + * @param boundsLeft the screen space left coordinate of the ink stroke + * @param boundsTop the screen space top coordinate of the ink stroke + * @returns the JSX controls for displaying an editing UI for the stroke (control point & tangent handles) + */ componentUI = (boundsLeft: number, boundsTop: number) => { const inkDoc = this.props.Document; const screenSpaceCenterlineStrokeWidth = 3; // the width of the blue line widget that shows the centerline of the ink stroke @@ -297,7 +319,6 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume StrCast(this.layoutDoc.strokeBezier), !closed ? "none" : fillColor === "transparent" ? "none" : fillColor, startMarker, endMarker, undefined, inkScaleX, inkScaleY, "", this.props.pointerEvents ?? (this.props.layerProvider?.(this.props.Document) === false ? "none" : "visiblepainted"), 0.0, false, downHdlr); - // Set of points rendered upon the ink that can be added if a user clicks on one. return <div className="inkStroke-wrapper"> <svg className="inkStroke" |