@meta2d/core 1.0.86 → 1.0.88

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.86",
3
+ "version": "1.0.88",
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",
@@ -369,6 +369,12 @@ export class Canvas {
369
369
  }
370
370
  let data = JSON.parse(e.data);
371
371
  if (typeof data === 'object') {
372
+ if (data.name === 'onload') {
373
+ this.dialog.iframe.contentWindow.postMessage(JSON.stringify({
374
+ name: 'dialog',
375
+ data: this.dialog.data
376
+ }), '*');
377
+ }
372
378
  this.parent.doMessageEvent(data.name, JSON.stringify(data.data));
373
379
  }
374
380
  else {
@@ -2631,15 +2637,16 @@ export class Canvas {
2631
2637
  pen.calculative.hover = false;
2632
2638
  setChildrenActive(pen, false);
2633
2639
  });
2634
- !drawing && this.store.emitter.emit('inactive', this.store.active);
2640
+ const activePens = [...this.store.active];
2635
2641
  this.store.active = [];
2636
2642
  this.activeRect = undefined;
2637
2643
  this.sizeCPs = undefined;
2638
2644
  this.store.activeAnchor = undefined;
2639
2645
  this.patchFlags = true;
2646
+ !drawing && this.store.emitter.emit('inactive', activePens);
2640
2647
  }
2641
2648
  active(pens, emit = true) {
2642
- if (this.store.active) {
2649
+ if (this.store.active && this.store.active.length) {
2643
2650
  emit && this.store.emitter.emit('inactive', this.store.active);
2644
2651
  for (const pen of this.store.active) {
2645
2652
  pen.calculative.active = undefined;
@@ -4025,6 +4032,7 @@ export class Canvas {
4025
4032
  const scale = this.store.data.scale;
4026
4033
  pen.calculative.lineWidth = pen.lineWidth * scale;
4027
4034
  pen.calculative.fontSize = pen.fontSize * scale;
4035
+ pen.calculative.letterSpacing = (pen.letterSpacing || 0) * scale;
4028
4036
  if (pen.fontSize < 1 && pen.fontSize > 0) {
4029
4037
  pen.calculative.fontSize =
4030
4038
  pen.fontSize * pen.calculative.worldRect.height;
@@ -4081,22 +4089,24 @@ export class Canvas {
4081
4089
  });
4082
4090
  }
4083
4091
  pen.type && this.initLineRect(pen);
4084
- if (pen.calculative.gradientTimer) {
4085
- clearTimeout(pen.calculative.gradientTimer);
4086
- }
4087
- pen.calculative.gradientTimer = setTimeout(() => {
4088
- if (pen.calculative.lineGradient) {
4089
- pen.calculative.lineGradient = null;
4090
- }
4091
- if (pen.calculative.gradient) {
4092
- pen.calculative.gradient = null;
4093
- }
4094
- if (pen.calculative.radialGradient) {
4095
- pen.calculative.radialGradient = null;
4092
+ if (pen.gradientColors || pen.lineGradientColors) {
4093
+ if (pen.calculative.gradientTimer) {
4094
+ clearTimeout(pen.calculative.gradientTimer);
4096
4095
  }
4097
- this.patchFlags = true;
4098
- pen.calculative.gradientTimer = undefined;
4099
- }, 50);
4096
+ pen.calculative.gradientTimer = setTimeout(() => {
4097
+ if (pen.calculative.lineGradient) {
4098
+ pen.calculative.lineGradient = null;
4099
+ }
4100
+ if (pen.calculative.gradient) {
4101
+ pen.calculative.gradient = null;
4102
+ }
4103
+ if (pen.calculative.radialGradient) {
4104
+ pen.calculative.radialGradient = null;
4105
+ }
4106
+ this.patchFlags = true;
4107
+ pen.calculative.gradientTimer = undefined;
4108
+ }, 50);
4109
+ }
4100
4110
  }
4101
4111
  initGlobalStyle() {
4102
4112
  if (this.store.options.themeOnlyCanvas || this.store.data.themeOnlyCanvas) {
@@ -4106,15 +4116,16 @@ export class Canvas {
4106
4116
  const data = {};
4107
4117
  const theme = {};
4108
4118
  themeKeys.forEach(key => {
4109
- if (this.store.options[key] !== undefined) {
4119
+ // 过滤调 null undefined ''
4120
+ if (this.store.options[key] != null && this.store.options[key] !== '') {
4110
4121
  options[key] = this.store.options[key];
4111
4122
  }
4112
- if (this.store.data[key] !== undefined) {
4123
+ if (this.store.data[key] != null && this.store.data[key] !== '') {
4113
4124
  data[key] = this.store.data[key];
4114
4125
  }
4115
4126
  if (this.store.data.theme) {
4116
4127
  const value = this.store.theme[this.store.data.theme]?.[key];
4117
- if (value !== undefined) {
4128
+ if (value != null && value !== '') {
4118
4129
  theme[key] = value;
4119
4130
  }
4120
4131
  }
@@ -4195,7 +4206,7 @@ export class Canvas {
4195
4206
  pen.calculative.img) {
4196
4207
  ctx.save();
4197
4208
  ctxFlip(ctx, pen);
4198
- if (pen.calculative.rotate) {
4209
+ if (pen.rotateByRoot || pen.calculative.rotate) {
4199
4210
  ctxRotate(ctx, pen);
4200
4211
  }
4201
4212
  setGlobalAlpha(ctx, pen);
@@ -5554,7 +5565,10 @@ export class Canvas {
5554
5565
  * @param angle 本次的旋转值,加到 pen.calculative.rotate 上
5555
5566
  */
5556
5567
  rotatePen(pen, angle, rect) {
5557
- if (pen.type) {
5568
+ if (pen.rotateByRoot) {
5569
+ return;
5570
+ }
5571
+ if (pen.name === 'line') {
5558
5572
  pen.calculative.worldAnchors.forEach((anchor) => {
5559
5573
  rotatePoint(anchor, angle, rect.center);
5560
5574
  });
@@ -6474,6 +6488,9 @@ export class Canvas {
6474
6488
  }
6475
6489
  style += `height:${height}px;`;
6476
6490
  }
6491
+ if (pen.letterSpacing) {
6492
+ style += `letter-spacing:${pen.calculative.letterSpacing}px;`;
6493
+ }
6477
6494
  let _textWidth = null;
6478
6495
  if (pen.textWidth) {
6479
6496
  _textWidth =