@meta2d/core 1.0.79 → 1.0.81-alpha.1

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.79",
3
+ "version": "1.0.81-alpha.1",
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",
@@ -260,6 +260,7 @@ export declare class Canvas {
260
260
  */
261
261
  private firefoxLoadSvg;
262
262
  loadImage(pen: Pen): void;
263
+ __loadImage(src: string): Promise<unknown>;
263
264
  private imageTimer;
264
265
  imageLoaded(): void;
265
266
  private templateImageTimer;
@@ -2424,7 +2424,7 @@ export class Canvas {
2424
2424
  // const pens = deepClone(this.store.active, true);
2425
2425
  const gridSize = this.store.data.gridSize || this.store.options.gridSize;
2426
2426
  const { origin, scale } = this.store.data;
2427
- const autoAlignGrid = this.store.options.autoAlignGrid && this.store.data.grid;
2427
+ const autoAlignGrid = this.store.options.autoAlignGrid && (this.store.data.grid || this.store.options.grid);
2428
2428
  movedPens.forEach((pen) => {
2429
2429
  const i = this.movingPens.findIndex((item) => item.id === pen.id + movingSuffix);
2430
2430
  if (i < 0) {
@@ -3259,6 +3259,7 @@ export class Canvas {
3259
3259
  else if (!pen.height) {
3260
3260
  pen.width = this.width;
3261
3261
  }
3262
+ this.updatePenRect(pen);
3262
3263
  }
3263
3264
  calcInView(pen);
3264
3265
  }
@@ -3645,6 +3646,12 @@ export class Canvas {
3645
3646
  });
3646
3647
  }
3647
3648
  !pen.rotate && (pen.rotate = 0);
3649
+ pen.lineAnimateImages ??= [];
3650
+ if (pen.lineAnimateImages) {
3651
+ pen.lineAnimateImages.forEach((src) => {
3652
+ this.__loadImage(src);
3653
+ });
3654
+ }
3648
3655
  this.loadImage(pen);
3649
3656
  this.parent.penNetwork(pen);
3650
3657
  }
@@ -3965,6 +3972,29 @@ export class Canvas {
3965
3972
  pen.calculative.strokeImage = pen.strokeImage;
3966
3973
  }
3967
3974
  }
3975
+ // 加载图片到全局缓存
3976
+ __loadImage(src) {
3977
+ return new Promise(resolve => {
3978
+ if (!globalStore.htmlElements[src]) {
3979
+ const img = new Image();
3980
+ img.crossOrigin = 'anonymous';
3981
+ img.src = src;
3982
+ if (this.store.options.cdn &&
3983
+ !(src.startsWith('http') ||
3984
+ src.startsWith('//') ||
3985
+ src.startsWith('data:image'))) {
3986
+ img.src = this.store.options.cdn + src;
3987
+ }
3988
+ img.onload = () => {
3989
+ globalStore.htmlElements[src] = img;
3990
+ resolve(img);
3991
+ };
3992
+ }
3993
+ else {
3994
+ resolve(globalStore.htmlElements[src]);
3995
+ }
3996
+ });
3997
+ }
3968
3998
  imageTimer;
3969
3999
  // 避免初始化图片加载重复调用 render,此处防抖
3970
4000
  imageLoaded() {