diff options
| author | bobzel <zzzman@gmail.com> | 2024-05-19 02:08:43 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-05-19 02:08:43 -0400 |
| commit | 6841dc0fd2aecf31eda2102e660c58905d1e6f44 (patch) | |
| tree | 821b79178aa07001274759c716badb2a8a170056 /src/client/util/Transform.ts | |
| parent | 2fc1fb7d322ab0950afb0d334c17aa93bd16f6c0 (diff) | |
| parent | 13dc6de0e0099f699ad0d2bb54401e6a0aa25018 (diff) | |
merged with soon-to-be-master
Diffstat (limited to 'src/client/util/Transform.ts')
| -rw-r--r-- | src/client/util/Transform.ts | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/client/util/Transform.ts b/src/client/util/Transform.ts index dca37c960..1a07dd6ae 100644 --- a/src/client/util/Transform.ts +++ b/src/client/util/Transform.ts @@ -116,20 +116,14 @@ export class Transform { preTransformed = (transform: Transform): Transform => this.copy().preTransform(transform); - transformPoint = (x: number, y: number): [number, number] => { - x *= this._scale; - x += this._translateX; - y *= this._scale; - y += this._translateY; - return [x, y]; - }; + transformPoint = (x: number, y: number): [number, number] => [x * this._scale + this._translateX, y * this._scale + this._translateY]; transformDirection = (x: number, y: number): [number, number] => [x * this._scale, y * this._scale]; transformBounds(x: number, y: number, width: number, height: number): { x: number; y: number; width: number; height: number } { - [x, y] = this.transformPoint(x, y); - [width, height] = this.transformDirection(width, height); - return { x, y, width, height }; + const [tx, ty] = this.transformPoint(x, y); + const [twidth, theight] = this.transformDirection(width, height); + return { x: tx, y: ty, width: twidth, height: theight }; } inverse = () => new Transform(-this._translateX / this._scale, -this._translateY / this._scale, 1 / this._scale, -this._rotate); |
