@visactor/vchart 2.0.21 → 2.0.22-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/build/index.es.js CHANGED
@@ -11430,7 +11430,9 @@ const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({
11430
11430
  background: null,
11431
11431
  autoAnimateTexture: !1,
11432
11432
  textureRatio: 1,
11433
- textureOptions: null,
11433
+ textureOptions: {
11434
+ alignToGraphic: !0
11435
+ },
11434
11436
  backgroundOpacity: 1,
11435
11437
  backgroundCornerRadius: 0,
11436
11438
  texture: null,
@@ -16065,6 +16067,7 @@ const GRAPHIC_UPDATE_TAG_KEY = ["lineWidth", "scaleX", "scaleY", "angle", "ancho
16065
16067
  const tempConstantXYKey = ["x", "y"],
16066
16068
  tempConstantScaleXYKey = ["scaleX", "scaleY"],
16067
16069
  tempConstantAngleKey = ["angle"],
16070
+ builtinTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave"]),
16068
16071
  point = new Point();
16069
16072
  const NOWORK_ANIMATE_ATTR = {
16070
16073
  strokeSeg: 1,
@@ -16121,7 +16124,7 @@ class Graphic extends Node {
16121
16124
  }
16122
16125
  constructor(params = {}) {
16123
16126
  var _a;
16124
- super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
16127
+ super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background && this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0), isExternalTexture(params.texture) ? this.loadImage(params.texture, !1) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
16125
16128
  }
16126
16129
  getGraphicService() {
16127
16130
  var _a, _b;
@@ -16310,7 +16313,7 @@ class Graphic extends Node {
16310
16313
  });
16311
16314
  }
16312
16315
  setAttributes(params, forceUpdateTag = !1, context) {
16313
- params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
16316
+ params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0), isExternalTexture(params.texture) ? this.loadImage(params.texture, !1) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
16314
16317
  }
16315
16318
  _setAttributes(params, forceUpdateTag = !1, context) {
16316
16319
  const keys = Object.keys(params);
@@ -16325,7 +16328,7 @@ class Graphic extends Node {
16325
16328
  const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
16326
16329
  [key]: value
16327
16330
  }, this.attribute, key, context);
16328
- params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "shadowGraphic" === key && this.setShadowGraphic(value);
16331
+ params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
16329
16332
  }
16330
16333
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
16331
16334
  for (let i = 0; i < k.length; i++) {
@@ -16344,7 +16347,7 @@ class Graphic extends Node {
16344
16347
  const context = {
16345
16348
  type: AttributeUpdateType.INIT
16346
16349
  };
16347
- params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
16350
+ params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background && this.loadImage(params.background, !0), isExternalTexture(params.texture) ? this.loadImage(params.texture, !1) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
16348
16351
  }
16349
16352
  translate(x, y) {
16350
16353
  var _a, _b;
@@ -16735,6 +16738,9 @@ class Graphic extends Node {
16735
16738
  function backgroundNotImage(image) {
16736
16739
  return "string" == typeof image ? !(image.startsWith("<svg") || isValidUrl$1(image) || image.includes("/") || isBase64$1(image)) : !(!image.fill && !image.stroke) || !("string" != typeof image.gradient || !Array.isArray(image.stops));
16737
16740
  }
16741
+ function isExternalTexture(texture) {
16742
+ return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$2(texture));
16743
+ }
16738
16744
  Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget);
16739
16745
 
16740
16746
  var GroupUpdateAABBBoundsMode;
@@ -20499,38 +20505,42 @@ class DefaultBaseTextureRenderContribution {
20499
20505
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
20500
20506
  }
20501
20507
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
20502
- var _a;
20508
+ var _a, _b, _c, _d, _e;
20503
20509
  const {
20504
20510
  textureRatio = graphicAttribute.textureRatio,
20505
20511
  textureOptions = null
20506
20512
  } = graphic.attribute;
20507
- let pattern = this.textureMap.get(texture);
20508
- if (!pattern) switch (texture) {
20509
- case "circle":
20510
- pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
20511
- break;
20512
- case "diamond":
20513
- pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
20514
- break;
20515
- case "rect":
20516
- pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
20517
- break;
20518
- case "vertical-line":
20519
- pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
20520
- break;
20521
- case "horizontal-line":
20522
- pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
20523
- break;
20524
- case "bias-lr":
20525
- pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
20526
- break;
20527
- case "bias-rl":
20528
- pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
20529
- break;
20530
- case "grid":
20531
- pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
20513
+ let pattern = null;
20514
+ const patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr);
20515
+ if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
20516
+ if ("string" == typeof texture) switch (texture) {
20517
+ case "circle":
20518
+ pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
20519
+ break;
20520
+ case "diamond":
20521
+ pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
20522
+ break;
20523
+ case "rect":
20524
+ pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
20525
+ break;
20526
+ case "vertical-line":
20527
+ pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
20528
+ break;
20529
+ case "horizontal-line":
20530
+ pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
20531
+ break;
20532
+ case "bias-lr":
20533
+ pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
20534
+ break;
20535
+ case "bias-rl":
20536
+ pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
20537
+ break;
20538
+ case "grid":
20539
+ pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
20540
+ }
20541
+ pattern || (pattern = this.createResourcePattern(texture, graphic, context)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
20532
20542
  }
20533
- if (textureOptions && textureOptions.dynamicTexture) {
20543
+ if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
20534
20544
  const {
20535
20545
  gridConfig = {},
20536
20546
  useNewCanvas: useNewCanvas
@@ -20578,7 +20588,21 @@ class DefaultBaseTextureRenderContribution {
20578
20588
  null === (_a = textureOptions.beforeDynamicTexture) || void 0 === _a || _a.call(textureOptions, context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height()), context.beginPath(), !1 === parsedPath.draw(context, Math.min(sizeW - gutterColumn, sizeH - gutterRow), _x, _y, 0) && context.closePath(), context.fillStyle = textureColor, textureOptions.dynamicTexture(context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height());
20579
20589
  }
20580
20590
  useNewCanvas && (originalContext.globalAlpha = 1, originalContext.drawImage(newCanvas.nativeCanvas, 0, 0, newCanvas.nativeCanvas.width, newCanvas.nativeCanvas.height, b.x1, b.y1, b.width() * originalContext.dpr, b.height() * originalContext.dpr)), originalContext.restore();
20581
- } else if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
20591
+ } else if (pattern) {
20592
+ if (pattern.setTransform) {
20593
+ const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
20594
+ alignOffsetX = null !== (_b = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _b ? _b : 0,
20595
+ alignOffsetY = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _c ? _c : 0;
20596
+ let translateX = 0,
20597
+ translateY = 0;
20598
+ if (alignToGraphic) {
20599
+ const m = context.currentMatrix;
20600
+ translateX = (null !== (_d = null == m ? void 0 : m.e) && void 0 !== _d ? _d : 0) + x + alignOffsetX, translateY = (null !== (_e = null == m ? void 0 : m.f) && void 0 !== _e ? _e : 0) + y + alignOffsetY;
20601
+ } else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
20602
+ pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
20603
+ }
20604
+ context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
20605
+ } else if ("wave" === texture) {
20582
20606
  context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
20583
20607
  const b = graphic.AABBBounds;
20584
20608
  drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
@@ -20586,6 +20610,17 @@ class DefaultBaseTextureRenderContribution {
20586
20610
  }), x + b.x1 - x, y + b.y1 - y), context.restore();
20587
20611
  }
20588
20612
  }
20613
+ getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr) {
20614
+ return "string" != typeof texture ? texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
20615
+ }
20616
+ createResourcePattern(texture, graphic, context) {
20617
+ var _a;
20618
+ const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
20619
+ data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
20620
+ if (!data) return null;
20621
+ const pattern = context.createPattern(data, "repeat");
20622
+ return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
20623
+ }
20589
20624
  }
20590
20625
  const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();
20591
20626
 
package/build/index.js CHANGED
@@ -11436,7 +11436,9 @@
11436
11436
  background: null,
11437
11437
  autoAnimateTexture: !1,
11438
11438
  textureRatio: 1,
11439
- textureOptions: null,
11439
+ textureOptions: {
11440
+ alignToGraphic: !0
11441
+ },
11440
11442
  backgroundOpacity: 1,
11441
11443
  backgroundCornerRadius: 0,
11442
11444
  texture: null,
@@ -16071,6 +16073,7 @@
16071
16073
  const tempConstantXYKey = ["x", "y"],
16072
16074
  tempConstantScaleXYKey = ["scaleX", "scaleY"],
16073
16075
  tempConstantAngleKey = ["angle"],
16076
+ builtinTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave"]),
16074
16077
  point = new Point();
16075
16078
  const NOWORK_ANIMATE_ATTR = {
16076
16079
  strokeSeg: 1,
@@ -16127,7 +16130,7 @@
16127
16130
  }
16128
16131
  constructor(params = {}) {
16129
16132
  var _a;
16130
- super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
16133
+ super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background && this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0), isExternalTexture(params.texture) ? this.loadImage(params.texture, !1) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
16131
16134
  }
16132
16135
  getGraphicService() {
16133
16136
  var _a, _b;
@@ -16316,7 +16319,7 @@
16316
16319
  });
16317
16320
  }
16318
16321
  setAttributes(params, forceUpdateTag = !1, context) {
16319
- params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
16322
+ params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0), isExternalTexture(params.texture) ? this.loadImage(params.texture, !1) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
16320
16323
  }
16321
16324
  _setAttributes(params, forceUpdateTag = !1, context) {
16322
16325
  const keys = Object.keys(params);
@@ -16331,7 +16334,7 @@
16331
16334
  const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
16332
16335
  [key]: value
16333
16336
  }, this.attribute, key, context);
16334
- params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "shadowGraphic" === key && this.setShadowGraphic(value);
16337
+ params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
16335
16338
  }
16336
16339
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
16337
16340
  for (let i = 0; i < k.length; i++) {
@@ -16350,7 +16353,7 @@
16350
16353
  const context = {
16351
16354
  type: AttributeUpdateType.INIT
16352
16355
  };
16353
- params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
16356
+ params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background && this.loadImage(params.background, !0), isExternalTexture(params.texture) ? this.loadImage(params.texture, !1) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
16354
16357
  }
16355
16358
  translate(x, y) {
16356
16359
  var _a, _b;
@@ -16741,6 +16744,9 @@
16741
16744
  function backgroundNotImage(image) {
16742
16745
  return "string" == typeof image ? !(image.startsWith("<svg") || isValidUrl$1(image) || image.includes("/") || isBase64$1(image)) : !(!image.fill && !image.stroke) || !("string" != typeof image.gradient || !Array.isArray(image.stops));
16743
16746
  }
16747
+ function isExternalTexture(texture) {
16748
+ return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$2(texture));
16749
+ }
16744
16750
  Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget);
16745
16751
 
16746
16752
  var GroupUpdateAABBBoundsMode;
@@ -20505,38 +20511,42 @@
20505
20511
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
20506
20512
  }
20507
20513
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
20508
- var _a;
20514
+ var _a, _b, _c, _d, _e;
20509
20515
  const {
20510
20516
  textureRatio = graphicAttribute.textureRatio,
20511
20517
  textureOptions = null
20512
20518
  } = graphic.attribute;
20513
- let pattern = this.textureMap.get(texture);
20514
- if (!pattern) switch (texture) {
20515
- case "circle":
20516
- pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
20517
- break;
20518
- case "diamond":
20519
- pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
20520
- break;
20521
- case "rect":
20522
- pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
20523
- break;
20524
- case "vertical-line":
20525
- pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
20526
- break;
20527
- case "horizontal-line":
20528
- pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
20529
- break;
20530
- case "bias-lr":
20531
- pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
20532
- break;
20533
- case "bias-rl":
20534
- pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
20535
- break;
20536
- case "grid":
20537
- pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
20519
+ let pattern = null;
20520
+ const patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr);
20521
+ if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
20522
+ if ("string" == typeof texture) switch (texture) {
20523
+ case "circle":
20524
+ pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
20525
+ break;
20526
+ case "diamond":
20527
+ pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
20528
+ break;
20529
+ case "rect":
20530
+ pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
20531
+ break;
20532
+ case "vertical-line":
20533
+ pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
20534
+ break;
20535
+ case "horizontal-line":
20536
+ pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
20537
+ break;
20538
+ case "bias-lr":
20539
+ pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
20540
+ break;
20541
+ case "bias-rl":
20542
+ pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
20543
+ break;
20544
+ case "grid":
20545
+ pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
20546
+ }
20547
+ pattern || (pattern = this.createResourcePattern(texture, graphic, context)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
20538
20548
  }
20539
- if (textureOptions && textureOptions.dynamicTexture) {
20549
+ if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
20540
20550
  const {
20541
20551
  gridConfig = {},
20542
20552
  useNewCanvas: useNewCanvas
@@ -20584,7 +20594,21 @@
20584
20594
  null === (_a = textureOptions.beforeDynamicTexture) || void 0 === _a || _a.call(textureOptions, context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height()), context.beginPath(), !1 === parsedPath.draw(context, Math.min(sizeW - gutterColumn, sizeH - gutterRow), _x, _y, 0) && context.closePath(), context.fillStyle = textureColor, textureOptions.dynamicTexture(context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height());
20585
20595
  }
20586
20596
  useNewCanvas && (originalContext.globalAlpha = 1, originalContext.drawImage(newCanvas.nativeCanvas, 0, 0, newCanvas.nativeCanvas.width, newCanvas.nativeCanvas.height, b.x1, b.y1, b.width() * originalContext.dpr, b.height() * originalContext.dpr)), originalContext.restore();
20587
- } else if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
20597
+ } else if (pattern) {
20598
+ if (pattern.setTransform) {
20599
+ const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
20600
+ alignOffsetX = null !== (_b = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _b ? _b : 0,
20601
+ alignOffsetY = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _c ? _c : 0;
20602
+ let translateX = 0,
20603
+ translateY = 0;
20604
+ if (alignToGraphic) {
20605
+ const m = context.currentMatrix;
20606
+ translateX = (null !== (_d = null == m ? void 0 : m.e) && void 0 !== _d ? _d : 0) + x + alignOffsetX, translateY = (null !== (_e = null == m ? void 0 : m.f) && void 0 !== _e ? _e : 0) + y + alignOffsetY;
20607
+ } else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
20608
+ pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
20609
+ }
20610
+ context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
20611
+ } else if ("wave" === texture) {
20588
20612
  context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
20589
20613
  const b = graphic.AABBBounds;
20590
20614
  drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
@@ -20592,6 +20616,17 @@
20592
20616
  }), x + b.x1 - x, y + b.y1 - y), context.restore();
20593
20617
  }
20594
20618
  }
20619
+ getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr) {
20620
+ return "string" != typeof texture ? texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
20621
+ }
20622
+ createResourcePattern(texture, graphic, context) {
20623
+ var _a;
20624
+ const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
20625
+ data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
20626
+ if (!data) return null;
20627
+ const pattern = context.createPattern(data, "repeat");
20628
+ return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
20629
+ }
20595
20630
  }
20596
20631
  const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();
20597
20632