core2d 2.11.1 → 2.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/Point.mjs CHANGED
@@ -4,71 +4,71 @@
4
4
  * Represents a point with x and y coordinates.
5
5
  */
6
6
  export class Point {
7
- /**
8
- * Creates a new Point.
9
- * @param {number} [x=0] The x-coordinate.
10
- * @param {number} [y=0] The y-coordinate.
11
- */
12
- constructor(x = 0, y = 0) {
13
- this.x = x;
14
- this.y = y;
15
- }
7
+ /**
8
+ * Creates a new Point.
9
+ * @param {number} [x=0] The x-coordinate.
10
+ * @param {number} [y=0] The y-coordinate.
11
+ */
12
+ constructor(x = 0, y = 0) {
13
+ this.x = x;
14
+ this.y = y;
15
+ }
16
16
 
17
- /**
18
- * The position of the point.
19
- * @type {Point}
20
- */
21
- get position() {
22
- return this;
23
- }
17
+ /**
18
+ * The position of the point.
19
+ * @type {Point}
20
+ */
21
+ get position() {
22
+ return this;
23
+ }
24
24
 
25
- /**
26
- * Sets the x-coordinate of the point.
27
- * @param {number} x The x-coordinate.
28
- * @returns {Point} This point.
29
- */
30
- setX(x) {
31
- this.x = x;
32
- return this;
33
- }
25
+ /**
26
+ * Sets the x-coordinate of the point.
27
+ * @param {number} x The x-coordinate.
28
+ * @returns {Point} This point.
29
+ */
30
+ setX(x) {
31
+ this.x = x;
32
+ return this;
33
+ }
34
34
 
35
- /**
36
- * Sets the y-coordinate of the point.
37
- * @param {number} y The y-coordinate.
38
- * @returns {Point} This point.
39
- */
40
- setY(y) {
41
- this.y = y;
42
- return this;
43
- }
35
+ /**
36
+ * Sets the y-coordinate of the point.
37
+ * @param {number} y The y-coordinate.
38
+ * @returns {Point} This point.
39
+ */
40
+ setY(y) {
41
+ this.y = y;
42
+ return this;
43
+ }
44
44
 
45
- /**
46
- * Sets the position of the point.
47
- * @param {Point} point The new position.
48
- * @returns {Point} This point.
49
- */
50
- setPosition(point) {
51
- this.x = point.x;
52
- this.y = point.y;
53
- return this;
54
- }
45
+ /**
46
+ * Sets the position of the point.
47
+ * @param {Point} point The new position.
48
+ * @returns {Point} This point.
49
+ */
50
+ setPosition(point) {
51
+ this.x = point.x;
52
+ this.y = point.y;
53
+ return this;
54
+ }
55
55
 
56
- /**
57
- * The position of the point.
58
- * @type {Point}
59
- */
60
- set position(point) {
61
- this.setPosition(point);
62
- }
56
+ /**
57
+ * The position of the point.
58
+ * @type {Point}
59
+ */
60
+ set position(point) {
61
+ this.setPosition(point);
62
+ }
63
63
 
64
- /**
65
- * Calculates the distance to another point.
66
- * @param {Point} point The other point.
67
- * @returns {number} The distance to the other point.
68
- */
69
- distance(point) {
70
- const dx = point.x - this.x;
71
- const dy = point.y - this.y;
72
- return Math.sqrt(dx * dx + dy * dy);
73
- }
64
+ /**
65
+ * Calculates the distance to another point.
66
+ * @param {Point} point The other point.
67
+ * @returns {number} The distance to the other point.
68
+ */
69
+ distance(point) {
70
+ const dx = point.x - this.x;
71
+ const dy = point.y - this.y;
72
+ return Math.sqrt(dx * dx + dy * dy);
73
+ }
74
74
  }
package/src/Pointer.mjs CHANGED
@@ -8,59 +8,59 @@ import { Point } from "./Point.mjs";
8
8
  * @extends Point
9
9
  */
10
10
  export class Pointer extends Point {
11
- /**
12
- * Creates a new Pointer.
13
- */
14
- constructor() {
15
- super();
16
- this._active = false;
17
- this._device = null;
18
- this._hold = false;
19
- }
11
+ /**
12
+ * Creates a new Pointer.
13
+ */
14
+ constructor() {
15
+ super();
16
+ this._active = false;
17
+ this._device = null;
18
+ this._hold = false;
19
+ }
20
20
 
21
- /**
22
- * Whether the pointer is down.
23
- * @type {boolean}
24
- */
25
- get down() {
26
- return this._active;
27
- }
21
+ /**
22
+ * Whether the pointer is down.
23
+ * @type {boolean}
24
+ */
25
+ get down() {
26
+ return this._active;
27
+ }
28
28
 
29
- /**
30
- * Whether the pointer was just pushed.
31
- * @type {boolean}
32
- */
33
- get push() {
34
- return this._active && !this._hold;
35
- }
29
+ /**
30
+ * Whether the pointer was just pushed.
31
+ * @type {boolean}
32
+ */
33
+ get push() {
34
+ return this._active && !this._hold;
35
+ }
36
36
 
37
- /**
38
- * Sets the device of the pointer.
39
- * @param {object} device The device.
40
- */
41
- setDevice(device) {
42
- this._device = device;
43
- }
37
+ /**
38
+ * Sets the device of the pointer.
39
+ * @param {object} device The device.
40
+ */
41
+ setDevice(device) {
42
+ this._device = device;
43
+ }
44
44
 
45
- /**
46
- * Updates the pointer.
47
- */
48
- update() {
49
- if (!this._device) {
50
- return;
51
- }
45
+ /**
46
+ * Updates the pointer.
47
+ */
48
+ update() {
49
+ if (!this._device) {
50
+ return;
51
+ }
52
52
 
53
- this._hold = false;
54
- const LAST = this._active;
55
- this._active = this._device.command;
53
+ this._hold = false;
54
+ const LAST = this._active;
55
+ this._active = this._device.command;
56
56
 
57
- if (this._active && LAST) {
58
- this._hold = true;
59
- }
57
+ if (this._active && LAST) {
58
+ this._hold = true;
59
+ }
60
60
 
61
- const REAL_X = this._device.x - Engine.offsetLeft;
62
- const REAL_Y = this._device.y - Engine.offsetTop;
63
- this.x = Math.floor((REAL_X * Engine.width) / Engine.realWidth);
64
- this.y = Math.floor((REAL_Y * Engine.height) / Engine.realHeight);
65
- }
61
+ const REAL_X = this._device.x - Engine.offsetLeft;
62
+ const REAL_Y = this._device.y - Engine.offsetTop;
63
+ this.x = Math.floor((REAL_X * Engine.width) / Engine.realWidth);
64
+ this.y = Math.floor((REAL_Y * Engine.height) / Engine.realHeight);
65
+ }
66
66
  }