aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/InkStrokeProperties.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-09-30 13:11:26 -0400
committerbobzel <zzzman@gmail.com>2021-09-30 13:11:26 -0400
commit4e4a1ec7bb6c479e8fd1b0a7bfe73e2447bafc74 (patch)
tree31f3f09e71d837c713c4878aa8507994e4dcaf5c /src/client/views/InkStrokeProperties.ts
parent065e9acb9243b31f0d15498cf9c46539accd593d (diff)
fixed creating/drawing straight horizontal/vertical lines. fixed showing proper context menu for ink.
Diffstat (limited to 'src/client/views/InkStrokeProperties.ts')
-rw-r--r--src/client/views/InkStrokeProperties.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts
index 72912ff20..00201fa56 100644
--- a/src/client/views/InkStrokeProperties.ts
+++ b/src/client/views/InkStrokeProperties.ts
@@ -45,8 +45,8 @@ export class InkStrokeProperties {
if (ink) {
const oldXrange = (xs => ({ coord: NumCast(doc.x), min: Math.min(...xs), max: Math.max(...xs) }))(ink.map(p => p.X));
const oldYrange = (ys => ({ coord: NumCast(doc.y), min: Math.min(...ys), max: Math.max(...ys) }))(ink.map(p => p.Y));
- const ptsXscale = NumCast(doc._width) / (oldXrange.max - oldXrange.min);
- const ptsYscale = NumCast(doc._height) / (oldYrange.max - oldYrange.min);
+ const ptsXscale = NumCast(doc._width) / ((oldXrange.max - oldXrange.min) || 1);
+ const ptsYscale = NumCast(doc._height) / ((oldYrange.max - oldYrange.min) || 1);
const newPoints = func(doc, ink, ptsXscale, ptsYscale);
if (newPoints) {
const newXrange = (xs => ({ min: Math.min(...xs), max: Math.max(...xs) }))(newPoints.map(p => p.X));
@@ -185,7 +185,7 @@ export class InkStrokeProperties {
*/
@undoBatch
@action
- moveControl = (deltaX: number, deltaY: number, controlIndex: number) =>
+ moveControlPtHandle = (deltaX: number, deltaY: number, controlIndex: number) =>
this.applyFunction((doc: Doc, ink: InkData, xScale: number, yScale: number) => {
const order = controlIndex % 4;
const closed = InkingStroke.IsClosed(ink);
@@ -258,7 +258,7 @@ export class InkStrokeProperties {
(nearestPt.Y - refPt.Y) * (nearestPt.Y - refPt.Y) * ptsYscale * ptsYscale);
if (near / (this.selectedInk?.lastElement().props.ScreenToLocalTransform().Scale || 1) < 10) {
- return this.moveControl((nearestPt.X - ink[controlIndex].X) * ptsXscale, (nearestPt.Y - ink[controlIndex].Y) * ptsYscale, controlIndex);
+ return this.moveControlPtHandle((nearestPt.X - ink[controlIndex].X) * ptsXscale, (nearestPt.Y - ink[controlIndex].Y) * ptsYscale, controlIndex);
}
}
return false;
@@ -278,7 +278,7 @@ export class InkStrokeProperties {
const [controlPoint, handleA, handleB] = [ink[controlIndex], ink[handleIndexA], ink[handleIndexB]];
const oppositeHandleA = this.rotatePoint(handleA, controlPoint, Math.PI);
const angleDifference = this.angleChange(handleB, oppositeHandleA, controlPoint);
- const inkCopy = ink.slice();
+ const inkCopy = ink.slice(); // have to make a new copy of the array to keep from corrupting undo/redo. without slicing, the same array will be stored in each undo step meaning earlier undo steps will be inadvertently updated to store the latest value.
inkCopy[handleIndexB] = this.rotatePoint(handleB, controlPoint, angleDifference);
return inkCopy;
}
@@ -330,7 +330,7 @@ export class InkStrokeProperties {
*/
@undoBatch
@action
- moveHandle = (deltaX: number, deltaY: number, handleIndex: number, oppositeHandleIndex: number, controlIndex: number) =>
+ moveTangentHandle = (deltaX: number, deltaY: number, handleIndex: number, oppositeHandleIndex: number, controlIndex: number) =>
this.applyFunction((doc: Doc, ink: InkData, xScale: number, yScale: number) => {
const closed = InkingStroke.IsClosed(ink);
const oldHandlePoint = ink[handleIndex];