aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/InkStrokeProperties.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts
index f218b4fbf..1a3585f3e 100644
--- a/src/client/views/InkStrokeProperties.ts
+++ b/src/client/views/InkStrokeProperties.ts
@@ -94,15 +94,17 @@ export class InkStrokeProperties {
if (end === 0) end = points.length-1;
// Index of new control point with regards to the ink data.
const newIndex = Math.floor(counter / 2) * 4 + 2;
- // Creating new ink data with new control point and handle points inputted.
+ // Creating new ink data with the new control point and handle points inputted.
for (let i = 0; i < ink.length; i++) {
if (i === newIndex) {
const [handleA, handleB] = this.getNewHandlePoints(points.slice(start, index+1), points.slice(index, end), newControl);
newPoints.push(handleA, newControl, newControl, handleB);
+ // Adjusting the magnitude of the left handle line of the right neighboring control point.
const [rightControl, rightHandle] = [points[end], ink[i]];
const scaledVector = this.getScaledHandlePoint(false, start, end, index, rightControl, rightHandle);
rightHandle && newPoints.push({ X: rightControl.X - scaledVector.X, Y: rightControl.Y - scaledVector.Y });
} else if (i === newIndex - 1) {
+ // Adjusting the magnitude of the right handle line of the left neighboring control point.
const [leftControl, leftHandle] = [points[start], ink[i]];
const scaledVector = this.getScaledHandlePoint(true, start, end, index, leftControl, leftHandle);
leftHandle && newPoints.push({ X: leftControl.X - scaledVector.X, Y: leftControl.Y - scaledVector.Y });
@@ -157,6 +159,8 @@ export class InkStrokeProperties {
const [m, n] = [C.length, D.length];
let handleSizeA = Math.sqrt((Math.pow(newControl.X - C[0].X, 2)) + (Math.pow(newControl.Y - C[0].Y, 2)));
let handleSizeB = Math.sqrt((Math.pow(D[n-1].X - newControl.X, 2)) + (Math.pow(D[n-1].Y - newControl.Y, 2)));
+ // Scaling adjustments to improve the ratio between the magnitudes of the two handle lines.
+ // (Ensures that the new point added doesn't augment the inital shape of the curve much).
if (handleSizeA < 75 && handleSizeB < 75) {
handleSizeA *= 3;
handleSizeB *= 3;