diff options
author | bobzel <zzzman@gmail.com> | 2021-05-08 11:24:13 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2021-05-08 11:24:13 -0400 |
commit | 62f143a6daf4e396ef031cfae70150fc122a0ecc (patch) | |
tree | aa6fff74dadf1ed13cc0f894128a331f02c45d5e /src | |
parent | c1a664b55ff39c3f1697249e6a712c741efc2458 (diff) |
fixed ink control point selection to not change scale of ink stroke
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/InkStrokeProperties.ts | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts index 9257ee4e6..358cce35b 100644 --- a/src/client/views/InkStrokeProperties.ts +++ b/src/client/views/InkStrokeProperties.ts @@ -222,26 +222,18 @@ export class InkStrokeProperties { { X: ink[i].X - xDiff, Y: ink[i].Y - yDiff } : { X: ink[i].X, Y: ink[i].Y }); } - 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); - Doc.GetProto(doc).data = new InkField(newPoints); - const newxs = newPoints.map(p => p.X); - const newys = newPoints.map(p => p.Y); - const newleft = Math.min(...newxs); - const newtop = Math.min(...newys); - const newright = Math.max(...newxs); - const newbottom = Math.max(...newys); - //if points move out of bounds - doc._height = (newbottom - newtop) * inkView.props.ScreenToLocalTransform().Scale; - doc._width = (newright - newleft) * inkView.props.ScreenToLocalTransform().Scale; + const oldXrange = (xs => ({ min: Math.min(...xs), max: Math.max(...xs) }))(ink.map(p => p.X)); + const oldYrange = (ys => ({ min: Math.min(...ys), max: Math.max(...ys) }))(ink.map(p => p.Y)); + const newXrange = (xs => ({ min: Math.min(...xs), max: Math.max(...xs) }))(newPoints.map(p => p.X)); + const newYrange = (ys => ({ min: Math.min(...ys), max: Math.max(...ys) }))(newPoints.map(p => p.Y)); - doc.x = oldx - (oldleft - newleft) * inkView.props.ScreenToLocalTransform().Scale; - doc.y = oldy - (oldtop - newtop) * inkView.props.ScreenToLocalTransform().Scale; + //if points move out of bounds + doc._height = (newYrange.max - newYrange.min) * NumCast(doc._height) / (oldYrange.max - oldYrange.min); + doc._width = (newXrange.max - newXrange.min) * NumCast(doc._width) / (oldXrange.max - oldXrange.min); + doc.x = doc.x - (oldXrange.min - newXrange.min); + doc.y = doc.y - (oldYrange.min - newYrange.min); + Doc.GetProto(doc).data = new InkField(newPoints); } } } |