aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/DocumentDecorations.tsx8
-rw-r--r--src/client/views/InkStrokeProperties.ts34
2 files changed, 16 insertions, 26 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 2f4126a1e..744683a0f 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -271,10 +271,10 @@ export class DocumentDecorations extends React.Component<{ boundsLeft: number, b
const right = Math.max(...xs);
const bottom = Math.max(...ys);
- doc._height = (bottom - top) * element.props.ScreenToLocalTransform().Scale;
- doc._width = (right - left) * element.props.ScreenToLocalTransform().Scale;
- // doc._height = (bottom - top);
- // doc._width = (right - left);
+ // doc._height = (bottom - top) * element.props.ScreenToLocalTransform().Scale;
+ // doc._width = (right - left) * element.props.ScreenToLocalTransform().Scale;
+ doc._height = (bottom - top);
+ doc._width = (right - left);
}
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts
index df0f354cd..73591c6a6 100644
--- a/src/client/views/InkStrokeProperties.ts
+++ b/src/client/views/InkStrokeProperties.ts
@@ -7,8 +7,6 @@ import { Cast, NumCast } from "../../fields/Types";
import { DocumentType } from "../documents/DocumentTypes";
import { SelectionManager } from "../util/SelectionManager";
import { undoBatch } from "../util/UndoManager";
-import { DocumentView } from "./nodes/DocumentView";
-import { returnVal } from "../../Utils";
export class InkStrokeProperties {
static Instance: InkStrokeProperties | undefined;
@@ -216,35 +214,28 @@ export class InkStrokeProperties {
if (doc.type === DocumentType.INK && doc.x && doc.y && doc._width && doc._height && doc.data) {
const ink = Cast(doc.data, InkField)?.inkData;
if (ink) {
-
const newPoints: { X: number, Y: number }[] = [];
const order = controlNum % 4;
for (var i = 0; i < ink.length; i++) {
- if (controlNum === i ||
- (order === 0 && i === controlNum + 1) ||
- (order === 0 && controlNum !== 0 && i === controlNum - 2) ||
- (order === 0 && controlNum !== 0 && i === controlNum - 1) ||
- (order === 3 && i === controlNum - 1) ||
- (order === 3 && controlNum !== ink.length - 1 && i === controlNum + 1) ||
- (order === 3 && controlNum !== ink.length - 1 && i === controlNum + 2)
- || ((ink[0].X === ink[ink.length - 1].X) && (ink[0].Y === ink[ink.length - 1].Y) && (i === 0 || i === ink.length - 1) && (controlNum === 0 || controlNum === ink.length - 1))
- ) {
- newPoints.push({ X: ink[i].X - (xDiff), Y: ink[i].Y - (yDiff) });
- }
- else {
- newPoints.push({ X: ink[i].X, Y: ink[i].Y });
- }
+ newPoints.push(
+ (controlNum === i ||
+ (order === 0 && i === controlNum + 1) ||
+ (order === 0 && controlNum !== 0 && i === controlNum - 2) ||
+ (order === 0 && controlNum !== 0 && i === controlNum - 1) ||
+ (order === 3 && i === controlNum - 1) ||
+ (order === 3 && controlNum !== ink.length - 1 && i === controlNum + 1) ||
+ (order === 3 && controlNum !== ink.length - 1 && i === controlNum + 2) ||
+ ((ink[0].X === ink[ink.length - 1].X) && (ink[0].Y === ink[ink.length - 1].Y) && (i === 0 || i === ink.length - 1) && (controlNum === 0 || controlNum === ink.length - 1))
+ ) ?
+ { X: ink[i].X - xDiff, Y: ink[i].Y - yDiff } :
+ { X: ink[i].X, Y: ink[i].Y })
}
- const oldHeight = doc._height;
- const oldWidth = doc._width;
const oldx = doc.x;
const oldy = doc.y;
const oldxs = ink.map(p => p.X);
const oldys = ink.map(p => p.Y);
const oldleft = Math.min(...oldxs);
const oldtop = Math.min(...oldys);
- const oldright = Math.max(...oldxs);
- const oldbottom = Math.max(...oldys);
Doc.GetProto(doc).data = new InkField(newPoints);
const newxs = newPoints.map(p => p.X);
const newys = newPoints.map(p => p.Y);
@@ -259,7 +250,6 @@ export class InkStrokeProperties {
doc.x = oldx - (oldleft - newleft) * inkView.props.ScreenToLocalTransform().Scale;
doc.y = oldy - (oldtop - newtop) * inkView.props.ScreenToLocalTransform().Scale;
-
}
}
}