@meta2d/core 1.0.37-alpha.1 → 1.0.38

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": "@meta2d/core",
3
- "version": "1.0.37-alpha.1",
3
+ "version": "1.0.38",
4
4
  "description": "@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -3695,28 +3695,27 @@ var Canvas = /** @class */ (function () {
3695
3695
  }
3696
3696
  }
3697
3697
  //取最近角度
3698
- var _min = 999;
3699
- var index = -1;
3700
- for (var i = 0; i < angleArr.length; i++) {
3701
- if (angle < 0) {
3702
- if (Math.abs(angle + angleArr[i]) < _min) {
3703
- index = i;
3704
- _min = Math.abs(angle + angleArr[i]);
3705
- }
3706
- }
3707
- else {
3708
- if (Math.abs(angle - angleArr[i]) < _min) {
3709
- index = i;
3710
- _min = Math.abs(angle - angleArr[i]);
3711
- }
3712
- }
3713
- }
3714
- if (angle < 0) {
3715
- angle = -angleArr[index];
3716
- }
3717
- else {
3718
- angle = angleArr[index];
3719
- }
3698
+ // let _min = 999;
3699
+ // let index = -1;
3700
+ // for (let i = 0; i < angleArr.length; i++) {
3701
+ // if (angle < 0) {
3702
+ // if (Math.abs(angle + angleArr[i]) < _min) {
3703
+ // index = i;
3704
+ // _min = Math.abs(angle + angleArr[i]);
3705
+ // }
3706
+ // } else {
3707
+ // if (Math.abs(angle - angleArr[i]) < _min) {
3708
+ // index = i;
3709
+ // _min = Math.abs(angle - angleArr[i]);
3710
+ // }
3711
+ // }
3712
+ // }
3713
+ // if (angle < 0) {
3714
+ // angle = -angleArr[index];
3715
+ // } else {
3716
+ // angle = angleArr[index];
3717
+ // }
3718
+ angle = Math.round(angle / 15) * 15;
3720
3719
  var length = Math.sqrt((last.x - to.x) * (last.x - to.x) + (last.y - to.y) * (last.y - to.y));
3721
3720
  to.x = last.x + Math.cos((angle / 180) * Math.PI) * length;
3722
3721
  to.y = last.y - Math.sin((angle / 180) * Math.PI) * length;
@@ -5263,25 +5262,29 @@ var Canvas = /** @class */ (function () {
5263
5262
  else {
5264
5263
  var offsetX = 0;
5265
5264
  var offsetY = 0;
5266
- if (line.lineName === 'line' &&
5267
- line.calculative.worldAnchors[line.calculative.worldAnchors.length - 1] === this.store.activeAnchor) {
5265
+ if (line.lineName === 'line') {
5266
+ var index = line.calculative.worldAnchors.findIndex(function (anchor) { return anchor.id === _this.store.activeAnchor.id; });
5267
+ if (index === 0) {
5268
+ index = 2;
5269
+ }
5270
+ var relativePt = line.calculative.worldAnchors[index - 1];
5268
5271
  if (keyOptions.ctrlKey && keyOptions.shiftKey) {
5269
5272
  var _pt = deepClone(pt);
5270
- this.getSpecialAngle(_pt, line.calculative.worldAnchors[line.calculative.worldAnchors.length - 2]);
5273
+ this.getSpecialAngle(_pt, relativePt);
5271
5274
  offsetX = _pt.x - this.store.activeAnchor.x;
5272
5275
  offsetY = _pt.y - this.store.activeAnchor.y;
5273
5276
  }
5274
5277
  else if (!keyOptions.ctrlKey && keyOptions.shiftKey) {
5275
5278
  var _pt = {
5276
5279
  x: pt.x,
5277
- y: line.calculative.worldAnchors[line.calculative.worldAnchors.length - 2].y,
5280
+ y: relativePt.y,
5278
5281
  };
5279
5282
  offsetX = _pt.x - this.store.activeAnchor.x;
5280
5283
  offsetY = _pt.y - this.store.activeAnchor.y;
5281
5284
  }
5282
5285
  else if (keyOptions.ctrlKey && !keyOptions.shiftKey) {
5283
5286
  var _pt = {
5284
- x: line.calculative.worldAnchors[line.calculative.worldAnchors.length - 2].x,
5287
+ x: relativePt.x,
5285
5288
  y: pt.y,
5286
5289
  };
5287
5290
  offsetX = _pt.x - this.store.activeAnchor.x;