@meta2d/core 1.0.7 → 1.0.9

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.7",
3
+ "version": "1.0.9",
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",
@@ -337,7 +337,7 @@ var Canvas = /** @class */ (function () {
337
337
  }
338
338
  break;
339
339
  case 'Alt':
340
- if (_this.drawingLine) {
340
+ if (!e.ctrlKey && !e.shiftKey && _this.drawingLine) {
341
341
  var to = getToAnchor(_this.drawingLine);
342
342
  if (to !== _this.drawingLine.calculative.activeAnchor) {
343
343
  deleteTempAnchor(_this.drawingLine);
@@ -812,10 +812,13 @@ var Canvas = /** @class */ (function () {
812
812
  }
813
813
  //shift 快捷添加锚点并连线
814
814
  if (!_this.store.options.autoAnchor && !_this.drawingLine) {
815
- if (e.shiftKey && !e.ctrlKey) {
815
+ if (e.shiftKey && e.ctrlKey && e.altKey) {
816
816
  _this.setAnchor(_this.store.pointAt);
817
817
  _this.drawingLineName = _this.store.options.drawingLineName;
818
818
  var anchor = _this.store.activeAnchor;
819
+ if (!anchor) {
820
+ return;
821
+ }
819
822
  var pt = {
820
823
  id: s8(),
821
824
  x: anchor.x,
@@ -849,10 +852,13 @@ var Canvas = /** @class */ (function () {
849
852
  }
850
853
  //shift快捷添加锚点并完成连线
851
854
  if (!_this.store.options.autoAnchor) {
852
- if (e.shiftKey) {
855
+ if (e.shiftKey && e.altKey && e.ctrlKey) {
853
856
  _this.setAnchor(_this.store.pointAt);
854
857
  var to_2 = getToAnchor(_this.drawingLine);
855
858
  var anchor = _this.store.activeAnchor;
859
+ if (!anchor) {
860
+ return;
861
+ }
856
862
  to_2.x = anchor.x;
857
863
  to_2.y = anchor.y;
858
864
  connectLine(_this.store.hover, anchor, _this.drawingLine, to_2);
@@ -3615,6 +3621,7 @@ var Canvas = /** @class */ (function () {
3615
3621
  };
3616
3622
  Canvas.prototype.makePen = function (pen) {
3617
3623
  var _this = this;
3624
+ var _a;
3618
3625
  if (!pen.id) {
3619
3626
  pen.id = s8();
3620
3627
  }
@@ -3631,14 +3638,14 @@ var Canvas = /** @class */ (function () {
3631
3638
  if (pen.lineWidth == undefined) {
3632
3639
  pen.lineWidth = 1;
3633
3640
  }
3634
- var _a = this.store.options, fontSize = _a.fontSize, lineHeight = _a.lineHeight;
3641
+ var _b = this.store.options, fontSize = _b.fontSize, lineHeight = _b.lineHeight;
3635
3642
  if (!pen.fontSize) {
3636
3643
  pen.fontSize = fontSize;
3637
3644
  }
3638
3645
  if (!pen.lineHeight) {
3639
3646
  pen.lineHeight = lineHeight;
3640
3647
  }
3641
- pen.calculative = { canvas: this };
3648
+ pen.calculative = { canvas: this, singleton: (_a = pen.calculative) === null || _a === void 0 ? void 0 : _a.singleton };
3642
3649
  if (pen.video || pen.audio) {
3643
3650
  pen.calculative.onended = function (pen) {
3644
3651
  _this.nextAnimate(pen);
@@ -4328,6 +4335,9 @@ var Canvas = /** @class */ (function () {
4328
4335
  });
4329
4336
  this.store.hover = undefined;
4330
4337
  }
4338
+ if (!this.mouseDown) {
4339
+ return;
4340
+ }
4331
4341
  var x = e.x - this.mouseDown.x;
4332
4342
  var y = e.y - this.mouseDown.y;
4333
4343
  e.shiftKey && !e.ctrlKey && (y = 0);
@@ -4638,11 +4648,13 @@ var Canvas = /** @class */ (function () {
4638
4648
  case 6:
4639
4649
  this.hotkeyType = HotkeyType.None;
4640
4650
  this.render();
4641
- this.pushHistory({
4642
- type: EditType.Update,
4643
- pens: [deepClone(hoverPen, true)],
4644
- initPens: initPens,
4645
- });
4651
+ if (hoverPen) {
4652
+ this.pushHistory({
4653
+ type: EditType.Update,
4654
+ pens: [deepClone(hoverPen, true)],
4655
+ initPens: initPens,
4656
+ });
4657
+ }
4646
4658
  return [2 /*return*/];
4647
4659
  }
4648
4660
  });
@@ -5075,7 +5087,14 @@ var Canvas = /** @class */ (function () {
5075
5087
  continue;
5076
5088
  }
5077
5089
  if (typeof pen[k] !== 'object' || k === 'lineDash') {
5078
- pen[k] = pen.calculative[k];
5090
+ if (k === 'lineWidth') {
5091
+ pen[k] =
5092
+ pen.calculative[k] /
5093
+ pen.calculative.canvas.store.data.scale;
5094
+ }
5095
+ else {
5096
+ pen[k] = pen.calculative[k];
5097
+ }
5079
5098
  }
5080
5099
  }
5081
5100
  calcPenRect(pen);
@@ -5083,7 +5102,13 @@ var Canvas = /** @class */ (function () {
5083
5102
  else {
5084
5103
  for (var k in pen) {
5085
5104
  if (typeof pen[k] !== 'object' || k === 'lineDash') {
5086
- pen.calculative[k] = pen[k];
5105
+ if (k === 'lineWidth') {
5106
+ pen.calculative[k] =
5107
+ pen[k] * pen.calculative.canvas.store.data.scale;
5108
+ }
5109
+ else {
5110
+ pen.calculative[k] = pen[k];
5111
+ }
5087
5112
  }
5088
5113
  }
5089
5114
  }
@@ -5418,6 +5443,7 @@ var Canvas = /** @class */ (function () {
5418
5443
  pens.forEach(function (pen) {
5419
5444
  if (!pen.parentId) {
5420
5445
  if (pen.locked) {
5446
+ // TODO: canDelLocked 是 true , locked 仍然删不掉
5421
5447
  return;
5422
5448
  }
5423
5449
  else {
@@ -5434,7 +5460,7 @@ var Canvas = /** @class */ (function () {
5434
5460
  return;
5435
5461
  }
5436
5462
  else {
5437
- var parentPen = _this.store.data.pens[pen.parentId];
5463
+ var parentPen = getParent(pen);
5438
5464
  var _index = parentPen.children.indexOf(pen.id);
5439
5465
  parentPen.children.splice(_index, 1);
5440
5466
  if (delPens) {
@@ -5779,6 +5805,20 @@ var Canvas = /** @class */ (function () {
5779
5805
  pen.calculative.strokeImage = undefined;
5780
5806
  this.loadImage(pen);
5781
5807
  }
5808
+ if (data.lineGradientColors) {
5809
+ pen.calculative.lineGradient = undefined;
5810
+ pen.calculative.gradientColorStop = undefined;
5811
+ }
5812
+ if (data.gradientColors) {
5813
+ pen.calculative.gradient = undefined;
5814
+ pen.calculative.radialGradient = undefined;
5815
+ }
5816
+ if (data.animateLineWidth) {
5817
+ pen.calculative.gradientAnimatePath = undefined;
5818
+ }
5819
+ if (data.gradientSmooth) {
5820
+ pen.calculative.gradientAnimatePath = undefined;
5821
+ }
5782
5822
  if (containIsBottom) {
5783
5823
  this.canvasImage.init();
5784
5824
  this.canvasImageBottom.init();