@next2d/display 2.4.1 → 2.5.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next2d/display",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "description": "Next2D Display Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -24,13 +24,13 @@
24
24
  "url": "git+https://github.com/Next2D/Player.git"
25
25
  },
26
26
  "dependencies": {
27
- "@next2d/ui": "2.4.1",
28
- "@next2d/text": "2.4.1",
29
- "@next2d/geom": "2.4.1",
30
- "@next2d/media": "2.4.1",
31
- "@next2d/net": "2.4.1",
32
- "@next2d/events": "2.4.1",
33
- "@next2d/filters": "2.4.1",
34
- "@next2d/render-queue": "2.4.1"
27
+ "@next2d/ui": "2.5.0",
28
+ "@next2d/text": "2.5.0",
29
+ "@next2d/geom": "2.5.0",
30
+ "@next2d/media": "2.5.0",
31
+ "@next2d/net": "2.5.0",
32
+ "@next2d/events": "2.5.0",
33
+ "@next2d/filters": "2.5.0",
34
+ "@next2d/render-queue": "2.5.0"
35
35
  }
36
36
  }
@@ -15,7 +15,8 @@ export const execute = (display_object) => {
15
15
  if (!matrix) {
16
16
  return 1;
17
17
  }
18
- const xScale = Math.round(Math.sqrt(matrix[0] * matrix[0]
19
- + matrix[1] * matrix[1]) * 10000) / 10000;
20
- return 0 > matrix[0] ? xScale * -1 : xScale;
18
+ const EPS = 1e-12;
19
+ const signX = (Math.abs(matrix[0]) >= EPS ? Math.sign(matrix[0]) : Math.sign(matrix[1])) || 1;
20
+ const xScale = Math.hypot(matrix[0], matrix[1]);
21
+ return Math.round(xScale * signX * 10000) / 10000;
21
22
  };
@@ -15,7 +15,8 @@ export const execute = (display_object) => {
15
15
  if (!matrix) {
16
16
  return 1;
17
17
  }
18
- const yScale = Math.round(Math.sqrt(matrix[2] * matrix[2]
19
- + matrix[3] * matrix[3]) * 10000) / 10000;
20
- return 0 > matrix[3] ? yScale * -1 : yScale;
18
+ const EPS = 1e-12;
19
+ const sxAbs = Math.hypot(matrix[0], matrix[1]);
20
+ const signX = (Math.abs(matrix[0]) >= EPS ? Math.sign(matrix[0]) : Math.sign(matrix[1])) || 1;
21
+ return Math.round((matrix[0] * matrix[3] - matrix[1] * matrix[2]) / (sxAbs * signX) * 10000) / 10000;
21
22
  };
@@ -18,7 +18,7 @@ const $Deg2Rad = Math.PI / 180;
18
18
  * @protected
19
19
  */
20
20
  export const execute = (display_object, rotation) => {
21
- rotation = $clamp(rotation % 360, 0 - 360, 360, 0);
21
+ rotation = $clamp(rotation % 360, -360, 360, 0);
22
22
  if (display_object.$rotation === rotation) {
23
23
  return;
24
24
  }
@@ -58,6 +58,8 @@ export const execute = (display_object, rotation) => {
58
58
  matrix.d = scaleY * Math.cos(radianY);
59
59
  }
60
60
  }
61
+ display_object.$scaleX = null;
62
+ display_object.$scaleY = null;
61
63
  display_object.$rotation = rotation;
62
64
  displayObjectApplyChangesService(display_object);
63
65
  };
@@ -26,16 +26,21 @@ export const execute = (display_object, scale_x) => {
26
26
  : new Matrix();
27
27
  }
28
28
  if (matrix.b === 0 || isNaN(matrix.b)) {
29
- matrix.a = scale_x;
29
+ matrix.a = scaleX;
30
30
  }
31
31
  else {
32
- let radianX = Math.atan2(matrix.b, matrix.a);
33
- if (radianX === -Math.PI) {
34
- radianX = 0;
35
- }
36
- matrix.b = scale_x * Math.sin(radianX);
37
- matrix.a = scale_x * Math.cos(radianX);
32
+ const EPS = 1e-12;
33
+ const theta = Math.atan2(matrix.b, matrix.a);
34
+ const sxAbs = Math.hypot(matrix.a, matrix.b);
35
+ const signX = (Math.abs(matrix.a) >= EPS ? Math.sign(matrix.a) : Math.sign(matrix.b)) || 1;
36
+ const sxSigned = sxAbs * signX;
37
+ const thetaPos = sxSigned >= 0 ? theta : theta - Math.PI;
38
+ const thetaUse = thetaPos + (scaleX < 0 ? Math.PI : 0);
39
+ const use = Math.abs(scaleX);
40
+ matrix.a = use * Math.cos(thetaUse);
41
+ matrix.b = use * Math.sin(thetaUse);
38
42
  }
39
43
  display_object.$scaleX = scaleX;
44
+ display_object.$rotation = null;
40
45
  displayObjectApplyChangesService(display_object);
41
46
  };
@@ -26,16 +26,26 @@ export const execute = (display_object, scale_y) => {
26
26
  : new Matrix();
27
27
  }
28
28
  if (matrix.c === 0 || isNaN(matrix.c)) {
29
- matrix.d = scale_y;
29
+ matrix.d = scaleY;
30
30
  }
31
31
  else {
32
- let radianY = Math.atan2(-matrix.c, matrix.d);
33
- if (radianY === -Math.PI) {
34
- radianY = 0;
32
+ const targetAbs = Math.max(0, Math.abs(scaleY));
33
+ const EPS = 1e-12;
34
+ let theta = Math.atan2(matrix.b, matrix.a);
35
+ if (matrix.a < 0 || Math.abs(matrix.a) < EPS && matrix.b < 0) {
36
+ theta -= Math.PI;
35
37
  }
36
- matrix.c = -scale_y * Math.sin(radianY);
37
- matrix.d = scale_y * Math.cos(radianY);
38
+ if (theta <= -Math.PI) {
39
+ theta += 2 * Math.PI;
40
+ }
41
+ if (theta > Math.PI) {
42
+ theta -= 2 * Math.PI;
43
+ }
44
+ const thetaUse = theta + (scaleY < 0 ? Math.PI : 0);
45
+ matrix.c = -targetAbs * Math.sin(thetaUse);
46
+ matrix.d = targetAbs * Math.cos(thetaUse);
38
47
  }
39
48
  display_object.$scaleY = scaleY;
49
+ display_object.$rotation = null;
40
50
  displayObjectApplyChangesService(display_object);
41
51
  };