diff options
| author | vkalev <50213748+vkalev@users.noreply.github.com> | 2021-06-21 17:44:19 -0500 |
|---|---|---|
| committer | vkalev <50213748+vkalev@users.noreply.github.com> | 2021-06-21 17:44:19 -0500 |
| commit | 441a3dab4ada425d28a55435be51339e3d28c892 (patch) | |
| tree | 252313e2e304b582ba0031db082b43d06b817c9f /src/client/views/InkStrokeProperties.ts | |
| parent | 4c1fc6bcfdf603bb8c620f9288da09ed69587bfb (diff) | |
adding comments
Diffstat (limited to 'src/client/views/InkStrokeProperties.ts')
| -rw-r--r-- | src/client/views/InkStrokeProperties.ts | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts index b13b04f68..533fdf006 100644 --- a/src/client/views/InkStrokeProperties.ts +++ b/src/client/views/InkStrokeProperties.ts @@ -17,8 +17,11 @@ export class InkStrokeProperties { private _lastDash = "2"; private _inkDocs: { x: number, y: number, width: number, height: number }[] = []; + // Indicates whether the ink is locked. @observable _lock = false; + // Indicates whether the ink's format is being currently edited (displaying of control points). @observable _controlBtn = false; + // Stores the index of the current selected control point of the ink instance. @observable _currPoint = -1; getField(key: string) { @@ -80,6 +83,14 @@ export class InkStrokeProperties { InkStrokeProperties.Instance = this; } + /** + * Adds a new control point to the ink instance when editing its format. + * @param x The x-coordinate of the current new point. + * @param y The y-coordinate of the current new point. + * @param pts The list containing all of the points to be added in PointData form. + * @param index The index of the current new point. + * @param control The list of all control points of the ink. + */ @undoBatch @action addPoints = (x: number, y: number, pts: { X: number, Y: number }[], index: number, control: { X: number, Y: number }[]) => { @@ -115,6 +126,12 @@ export class InkStrokeProperties { })); } + /** + * Helper function that enables other functions to be applied to a particular ink instance. + * @param func The inputted function. + * @param requireCurrPoint Indicates whether the current selected point is needed. + * @returns The applied function. + */ applyFunction = (func: (doc: Doc, ink: InkData, ptsXscale: number, ptsYscale: number) => { X: number, Y: number }[] | undefined, requireCurrPoint: boolean = false) => { var appliedFunc = false; this.selectedInk?.forEach(action(inkView => { @@ -145,6 +162,10 @@ export class InkStrokeProperties { return appliedFunc; } + /** + * Deletes the points of the current ink instance. + * @returns The changed x- and y-coordinates of the control points. + */ @undoBatch @action deletePoints = () => this.applyFunction((doc: Doc, ink: InkData) => { @@ -168,6 +189,11 @@ export class InkStrokeProperties { return newPoints; }, true); + /** + * Rotates the points of the current ink instance by a certain angle degree. + * @param angle The angle at which to rotate the ink (all of its x- and y-coordinates). + * @returns The changed x- and y-coordinates of the control points. + */ @undoBatch @action rotate = (angle: number) => { @@ -186,6 +212,13 @@ export class InkStrokeProperties { }); } + /** + * Handles the movement / scaling of control points of an ink instance. + * @param xDiff The movement of the control point's x-coordinate. + * @param yDiff The movement of the control point's y-coordinate. + * @param controlNum The index of the current control point selected. + * @returns The changed x- and y-coordinates of the control points. + */ @undoBatch @action control = (xDiff: number, yDiff: number, controlNum: number) => @@ -209,6 +242,11 @@ export class InkStrokeProperties { return newPoints; }); + /** + * Changes the color of the border of the ink instance. + * @param color The new hex value to change the border to. + * @returns true. + */ @undoBatch @action switchStk = (color: ColorState) => { @@ -217,6 +255,11 @@ export class InkStrokeProperties { return true; } + /** + * Changes the color of the fill of the ink instance. + * @param color The new hex value to change the fill to. + * @returns true. + */ @undoBatch @action switchFil = (color: ColorState) => { |
