diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2023-06-13 01:43:37 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2023-06-13 01:43:37 +0200 |
commit | 03322672782a6318b019eff33fe44ec800d6f12c (patch) | |
tree | 9d807e1585cf28a1ea98e87b855932dba00f1880 /src/types/Point.js | |
parent | 8e18b4698edd00f83af0be05bb3374f92fecaeb9 (diff) | |
download | svg.js-03322672782a6318b019eff33fe44ec800d6f12c.tar.gz svg.js-03322672782a6318b019eff33fe44ec800d6f12c.zip |
dependency updates, easier formatting
Diffstat (limited to 'src/types/Point.js')
-rw-r--r-- | src/types/Point.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/types/Point.js b/src/types/Point.js index 76fd985..5d44733 100644 --- a/src/types/Point.js +++ b/src/types/Point.js @@ -2,24 +2,24 @@ import Matrix from './Matrix.js' export default class Point { // Initialize - constructor (...args) { + constructor(...args) { this.init(...args) } // Clone point - clone () { + clone() { return new Point(this) } - init (x, y) { + init(x, y) { const base = { x: 0, y: 0 } // ensure source as object const source = Array.isArray(x) ? { x: x[0], y: x[1] } : typeof x === 'object' - ? { x: x.x, y: x.y } - : { x: x, y: y } + ? { x: x.x, y: x.y } + : { x: x, y: y } // merge source this.x = source.x == null ? base.x : source.x @@ -28,16 +28,16 @@ export default class Point { return this } - toArray () { - return [ this.x, this.y ] + toArray() { + return [this.x, this.y] } - transform (m) { + transform(m) { return this.clone().transformO(m) } // Transform point with matrix - transformO (m) { + transformO(m) { if (!Matrix.isMatrixLike(m)) { m = new Matrix(m) } @@ -50,9 +50,8 @@ export default class Point { return this } - } -export function point (x, y) { +export function point(x, y) { return new Point(x, y).transformO(this.screenCTM().inverseO()) } |