@visactor/vrender 1.0.45 → 1.0.46-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/cjs/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import '@visactor/vrender-core';
2
- export declare const version = "1.0.45";
2
+ export declare const version = "1.0.46-alpha.1";
3
3
  export * from '@visactor/vrender-core';
4
4
  export * from '@visactor/vrender-kits';
5
5
  export * from '@visactor/vrender-animate';
package/cjs/index.js CHANGED
@@ -21,16 +21,17 @@ Object.defineProperty(exports, "__esModule", {
21
21
 
22
22
  const vrender_core_1 = require("@visactor/vrender-core"), vrender_kits_1 = require("@visactor/vrender-kits"), vrender_kits_2 = require("@visactor/vrender-kits"), vrender_animate_1 = require("@visactor/vrender-animate");
23
23
 
24
- exports.version = "1.0.45", (0, vrender_core_1.preLoadAllModule)(), (0, vrender_core_1.isBrowserEnv)() ? (0,
25
- vrender_kits_1.loadBrowserEnv)(vrender_core_1.container) : (0, vrender_core_1.isNodeEnv)() && (0,
26
- vrender_kits_1.loadNodeEnv)(vrender_core_1.container), (0, vrender_kits_2.registerArc)(),
27
- (0, vrender_kits_2.registerArc3d)(), (0, vrender_kits_2.registerArea)(), (0, vrender_kits_2.registerCircle)(),
28
- (0, vrender_kits_2.registerGlyph)(), (0, vrender_kits_2.registerGroup)(), (0, vrender_kits_2.registerImage)(),
29
- (0, vrender_kits_2.registerLine)(), (0, vrender_kits_2.registerPath)(), (0, vrender_kits_2.registerPolygon)(),
30
- (0, vrender_kits_2.registerPyramid3d)(), (0, vrender_kits_2.registerRect)(), (0,
31
- vrender_kits_2.registerRect3d)(), (0, vrender_kits_2.registerRichtext)(), (0, vrender_kits_2.registerShadowRoot)(),
32
- (0, vrender_kits_2.registerSymbol)(), (0, vrender_kits_2.registerText)(), (0, vrender_kits_2.registerWrapText)(),
33
- (0, vrender_kits_1.registerStar)(), (0, vrender_core_1.registerFlexLayoutPlugin)(),
24
+ exports.version = "1.0.46-alpha.1", (0, vrender_core_1.preLoadAllModule)(), (0,
25
+ vrender_core_1.isBrowserEnv)() ? (0, vrender_kits_1.loadBrowserEnv)(vrender_core_1.container) : (0,
26
+ vrender_core_1.isNodeEnv)() && (0, vrender_kits_1.loadNodeEnv)(vrender_core_1.container),
27
+ (0, vrender_kits_2.registerArc)(), (0, vrender_kits_2.registerArc3d)(), (0, vrender_kits_2.registerArea)(),
28
+ (0, vrender_kits_2.registerCircle)(), (0, vrender_kits_2.registerGlyph)(), (0, vrender_kits_2.registerGroup)(),
29
+ (0, vrender_kits_2.registerImage)(), (0, vrender_kits_2.registerLine)(), (0, vrender_kits_2.registerPath)(),
30
+ (0, vrender_kits_2.registerPolygon)(), (0, vrender_kits_2.registerPyramid3d)(),
31
+ (0, vrender_kits_2.registerRect)(), (0, vrender_kits_2.registerRect3d)(), (0, vrender_kits_2.registerRichtext)(),
32
+ (0, vrender_kits_2.registerShadowRoot)(), (0, vrender_kits_2.registerSymbol)(),
33
+ (0, vrender_kits_2.registerText)(), (0, vrender_kits_2.registerWrapText)(), (0,
34
+ vrender_kits_1.registerStar)(), (0, vrender_core_1.registerFlexLayoutPlugin)(),
34
35
  (0, vrender_core_1.registerViewTransform3dPlugin)(), (0, vrender_core_1.registerHtmlAttributePlugin)(),
35
36
  (0, vrender_core_1.registerReactAttributePlugin)(), (0, vrender_core_1.registerDirectionalLight)(),
36
37
  (0, vrender_core_1.registerOrthoCamera)(), (0, vrender_animate_1.registerCustomAnimate)(),
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAWgC;AAChC,yDAAmF;AACnF,yDAmBgC;AAChC,+DAAmF;AAEtE,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,IAAA,+BAAgB,GAAE,CAAC;AAEnB,IAAI,IAAA,2BAAY,GAAE,EAAE;IAClB,IAAA,6BAAc,EAAC,wBAAS,CAAC,CAAC;CAC3B;KAAM,IAAI,IAAA,wBAAS,GAAE,EAAE;IACtB,IAAA,0BAAW,EAAC,wBAAS,CAAC,CAAC;CACxB;AACD,IAAA,0BAAW,GAAE,CAAC;AACd,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,8BAAe,GAAE,CAAC;AAClB,IAAA,gCAAiB,GAAE,CAAC;AACpB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,+BAAgB,GAAE,CAAC;AACnB,IAAA,iCAAkB,GAAE,CAAC;AACrB,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,+BAAgB,GAAE,CAAC;AACnB,IAAA,2BAAY,GAAE,CAAC;AAEf,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,4CAA6B,GAAE,CAAC;AAChC,IAAA,0CAA2B,GAAE,CAAC;AAC9B,IAAA,2CAA4B,GAAE,CAAC;AAC/B,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,kCAAmB,GAAE,CAAC;AAEtB,IAAA,uCAAqB,GAAE,CAAC;AACxB,IAAA,iCAAe,GAAE,CAAC;AAElB,yDAAuC;AACvC,yDAAuC;AACvC,4DAA0C;AAC1C,+DAA6C;AAG7C,6DAAkD;AAAzC,wGAAA,KAAK,OAAA;AACd,uDAAmD;AAA1C,yGAAA,SAAS,OAAA","file":"index.js","sourcesContent":["import '@visactor/vrender-core';\nimport {\n container,\n isBrowserEnv,\n isNodeEnv,\n preLoadAllModule,\n registerFlexLayoutPlugin,\n registerViewTransform3dPlugin,\n registerHtmlAttributePlugin,\n registerReactAttributePlugin,\n registerDirectionalLight,\n registerOrthoCamera\n} from '@visactor/vrender-core';\nimport { loadBrowserEnv, loadNodeEnv, registerStar } from '@visactor/vrender-kits';\nimport {\n registerArc,\n registerArc3d,\n registerArea,\n registerCircle,\n registerGlyph,\n registerGroup,\n registerImage,\n registerLine,\n registerPath,\n registerPolygon,\n registerPyramid3d,\n registerRect,\n registerRect3d,\n registerRichtext,\n registerShadowRoot,\n registerSymbol,\n registerText,\n registerWrapText\n} from '@visactor/vrender-kits';\nimport { registerCustomAnimate, registerAnimate } from '@visactor/vrender-animate';\n// 导出版本号\nexport const version = \"1.0.45\";\n\npreLoadAllModule();\n\nif (isBrowserEnv()) {\n loadBrowserEnv(container);\n} else if (isNodeEnv()) {\n loadNodeEnv(container);\n}\nregisterArc();\nregisterArc3d();\nregisterArea();\nregisterCircle();\nregisterGlyph();\nregisterGroup();\nregisterImage();\nregisterLine();\nregisterPath();\nregisterPolygon();\nregisterPyramid3d();\nregisterRect();\nregisterRect3d();\nregisterRichtext();\nregisterShadowRoot();\nregisterSymbol();\nregisterText();\nregisterWrapText();\nregisterStar();\n\nregisterFlexLayoutPlugin();\nregisterViewTransform3dPlugin();\nregisterHtmlAttributePlugin();\nregisterReactAttributePlugin();\nregisterDirectionalLight();\nregisterOrthoCamera();\n\nregisterCustomAnimate();\nregisterAnimate();\n\nexport * from '@visactor/vrender-core';\nexport * from '@visactor/vrender-kits';\nexport * from '@visactor/vrender-animate';\nexport * from '@visactor/vrender-components';\n\n// avoid naming conflicts with 'State' & 'Direction' in '@visactor/vrender-components'\nexport { State } from '@visactor/vrender-animate';\nexport { Direction } from '@visactor/vrender-core';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAWgC;AAChC,yDAAmF;AACnF,yDAmBgC;AAChC,+DAAmF;AAEtE,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAExC,IAAA,+BAAgB,GAAE,CAAC;AAEnB,IAAI,IAAA,2BAAY,GAAE,EAAE;IAClB,IAAA,6BAAc,EAAC,wBAAS,CAAC,CAAC;CAC3B;KAAM,IAAI,IAAA,wBAAS,GAAE,EAAE;IACtB,IAAA,0BAAW,EAAC,wBAAS,CAAC,CAAC;CACxB;AACD,IAAA,0BAAW,GAAE,CAAC;AACd,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,8BAAe,GAAE,CAAC;AAClB,IAAA,gCAAiB,GAAE,CAAC;AACpB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,+BAAgB,GAAE,CAAC;AACnB,IAAA,iCAAkB,GAAE,CAAC;AACrB,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,+BAAgB,GAAE,CAAC;AACnB,IAAA,2BAAY,GAAE,CAAC;AAEf,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,4CAA6B,GAAE,CAAC;AAChC,IAAA,0CAA2B,GAAE,CAAC;AAC9B,IAAA,2CAA4B,GAAE,CAAC;AAC/B,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,kCAAmB,GAAE,CAAC;AAEtB,IAAA,uCAAqB,GAAE,CAAC;AACxB,IAAA,iCAAe,GAAE,CAAC;AAElB,yDAAuC;AACvC,yDAAuC;AACvC,4DAA0C;AAC1C,+DAA6C;AAG7C,6DAAkD;AAAzC,wGAAA,KAAK,OAAA;AACd,uDAAmD;AAA1C,yGAAA,SAAS,OAAA","file":"index.js","sourcesContent":["import '@visactor/vrender-core';\nimport {\n container,\n isBrowserEnv,\n isNodeEnv,\n preLoadAllModule,\n registerFlexLayoutPlugin,\n registerViewTransform3dPlugin,\n registerHtmlAttributePlugin,\n registerReactAttributePlugin,\n registerDirectionalLight,\n registerOrthoCamera\n} from '@visactor/vrender-core';\nimport { loadBrowserEnv, loadNodeEnv, registerStar } from '@visactor/vrender-kits';\nimport {\n registerArc,\n registerArc3d,\n registerArea,\n registerCircle,\n registerGlyph,\n registerGroup,\n registerImage,\n registerLine,\n registerPath,\n registerPolygon,\n registerPyramid3d,\n registerRect,\n registerRect3d,\n registerRichtext,\n registerShadowRoot,\n registerSymbol,\n registerText,\n registerWrapText\n} from '@visactor/vrender-kits';\nimport { registerCustomAnimate, registerAnimate } from '@visactor/vrender-animate';\n// 导出版本号\nexport const version = \"1.0.46-alpha.1\";\n\npreLoadAllModule();\n\nif (isBrowserEnv()) {\n loadBrowserEnv(container);\n} else if (isNodeEnv()) {\n loadNodeEnv(container);\n}\nregisterArc();\nregisterArc3d();\nregisterArea();\nregisterCircle();\nregisterGlyph();\nregisterGroup();\nregisterImage();\nregisterLine();\nregisterPath();\nregisterPolygon();\nregisterPyramid3d();\nregisterRect();\nregisterRect3d();\nregisterRichtext();\nregisterShadowRoot();\nregisterSymbol();\nregisterText();\nregisterWrapText();\nregisterStar();\n\nregisterFlexLayoutPlugin();\nregisterViewTransform3dPlugin();\nregisterHtmlAttributePlugin();\nregisterReactAttributePlugin();\nregisterDirectionalLight();\nregisterOrthoCamera();\n\nregisterCustomAnimate();\nregisterAnimate();\n\nexport * from '@visactor/vrender-core';\nexport * from '@visactor/vrender-kits';\nexport * from '@visactor/vrender-animate';\nexport * from '@visactor/vrender-components';\n\n// avoid naming conflicts with 'State' & 'Direction' in '@visactor/vrender-components'\nexport { State } from '@visactor/vrender-animate';\nexport { Direction } from '@visactor/vrender-core';\n"]}
package/dist/index.es.js CHANGED
@@ -4685,7 +4685,9 @@ const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({
4685
4685
  background: null,
4686
4686
  autoAnimateTexture: !1,
4687
4687
  textureRatio: 1,
4688
- textureOptions: null,
4688
+ textureOptions: {
4689
+ alignToGraphic: !0
4690
+ },
4689
4691
  backgroundOpacity: 1,
4690
4692
  backgroundCornerRadius: 0,
4691
4693
  texture: null,
@@ -9455,6 +9457,7 @@ const GRAPHIC_UPDATE_TAG_KEY = ["lineWidth", "scaleX", "scaleY", "angle", "ancho
9455
9457
  const tempConstantXYKey = ["x", "y"],
9456
9458
  tempConstantScaleXYKey = ["scaleX", "scaleY"],
9457
9459
  tempConstantAngleKey = ["angle"],
9460
+ builtinTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave"]),
9458
9461
  point = new Point();
9459
9462
  const NOWORK_ANIMATE_ATTR = {
9460
9463
  strokeSeg: 1,
@@ -9511,7 +9514,7 @@ class Graphic extends Node {
9511
9514
  }
9512
9515
  constructor(params = {}) {
9513
9516
  var _a;
9514
- 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);
9517
+ 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);
9515
9518
  }
9516
9519
  getGraphicService() {
9517
9520
  var _a, _b;
@@ -9700,7 +9703,7 @@ class Graphic extends Node {
9700
9703
  });
9701
9704
  }
9702
9705
  setAttributes(params, forceUpdateTag = !1, context) {
9703
- 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));
9706
+ 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));
9704
9707
  }
9705
9708
  _setAttributes(params, forceUpdateTag = !1, context) {
9706
9709
  const keys = Object.keys(params);
@@ -9715,7 +9718,7 @@ class Graphic extends Node {
9715
9718
  const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
9716
9719
  [key]: value
9717
9720
  }, this.attribute, key, context);
9718
- 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);
9721
+ 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);
9719
9722
  }
9720
9723
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
9721
9724
  for (let i = 0; i < k.length; i++) {
@@ -9734,7 +9737,7 @@ class Graphic extends Node {
9734
9737
  const context = {
9735
9738
  type: AttributeUpdateType.INIT
9736
9739
  };
9737
- 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);
9740
+ 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);
9738
9741
  }
9739
9742
  translate(x, y) {
9740
9743
  var _a, _b;
@@ -10125,6 +10128,9 @@ class Graphic extends Node {
10125
10128
  function backgroundNotImage(image) {
10126
10129
  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));
10127
10130
  }
10131
+ function isExternalTexture(texture) {
10132
+ return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$1(texture));
10133
+ }
10128
10134
  Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget);
10129
10135
 
10130
10136
  var GroupUpdateAABBBoundsMode;
@@ -14165,38 +14171,42 @@ class DefaultBaseTextureRenderContribution {
14165
14171
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
14166
14172
  }
14167
14173
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
14168
- var _a;
14174
+ var _a, _b, _c, _d, _e;
14169
14175
  const {
14170
14176
  textureRatio = graphicAttribute.textureRatio,
14171
14177
  textureOptions = null
14172
14178
  } = graphic.attribute;
14173
- let pattern = this.textureMap.get(texture);
14174
- if (!pattern) switch (texture) {
14175
- case "circle":
14176
- pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
14177
- break;
14178
- case "diamond":
14179
- pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
14180
- break;
14181
- case "rect":
14182
- pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
14183
- break;
14184
- case "vertical-line":
14185
- pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
14186
- break;
14187
- case "horizontal-line":
14188
- pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
14189
- break;
14190
- case "bias-lr":
14191
- pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
14192
- break;
14193
- case "bias-rl":
14194
- pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
14195
- break;
14196
- case "grid":
14197
- pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
14179
+ let pattern = null;
14180
+ const patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr);
14181
+ if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
14182
+ if ("string" == typeof texture) switch (texture) {
14183
+ case "circle":
14184
+ pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
14185
+ break;
14186
+ case "diamond":
14187
+ pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
14188
+ break;
14189
+ case "rect":
14190
+ pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
14191
+ break;
14192
+ case "vertical-line":
14193
+ pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
14194
+ break;
14195
+ case "horizontal-line":
14196
+ pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
14197
+ break;
14198
+ case "bias-lr":
14199
+ pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
14200
+ break;
14201
+ case "bias-rl":
14202
+ pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
14203
+ break;
14204
+ case "grid":
14205
+ pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
14206
+ }
14207
+ pattern || (pattern = this.createResourcePattern(texture, graphic, context)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
14198
14208
  }
14199
- if (textureOptions && textureOptions.dynamicTexture) {
14209
+ if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
14200
14210
  const {
14201
14211
  gridConfig = {},
14202
14212
  useNewCanvas: useNewCanvas
@@ -14244,7 +14254,21 @@ class DefaultBaseTextureRenderContribution {
14244
14254
  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());
14245
14255
  }
14246
14256
  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();
14247
- } else if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
14257
+ } else if (pattern) {
14258
+ if (pattern.setTransform) {
14259
+ const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
14260
+ alignOffsetX = null !== (_b = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _b ? _b : 0,
14261
+ alignOffsetY = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _c ? _c : 0;
14262
+ let translateX = 0,
14263
+ translateY = 0;
14264
+ if (alignToGraphic) {
14265
+ const m = context.currentMatrix;
14266
+ 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;
14267
+ } else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
14268
+ pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
14269
+ }
14270
+ context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
14271
+ } else if ("wave" === texture) {
14248
14272
  context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
14249
14273
  const b = graphic.AABBBounds;
14250
14274
  drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
@@ -14252,6 +14276,17 @@ class DefaultBaseTextureRenderContribution {
14252
14276
  }), x + b.x1 - x, y + b.y1 - y), context.restore();
14253
14277
  }
14254
14278
  }
14279
+ getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr) {
14280
+ return "string" != typeof texture ? texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
14281
+ }
14282
+ createResourcePattern(texture, graphic, context) {
14283
+ var _a;
14284
+ const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
14285
+ data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
14286
+ if (!data) return null;
14287
+ const pattern = context.createPattern(data, "repeat");
14288
+ return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
14289
+ }
14255
14290
  }
14256
14291
  const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();
14257
14292
 
@@ -52928,7 +52963,7 @@ TableSeriesNumber.defaultAttributes = {
52928
52963
  select: !0
52929
52964
  };
52930
52965
 
52931
- const version = "1.0.45";
52966
+ const version = "1.0.46-alpha.1";
52932
52967
  preLoadAllModule();
52933
52968
  if (isBrowserEnv()) {
52934
52969
  loadBrowserEnv(container);
package/dist/index.js CHANGED
@@ -4691,7 +4691,9 @@
4691
4691
  background: null,
4692
4692
  autoAnimateTexture: !1,
4693
4693
  textureRatio: 1,
4694
- textureOptions: null,
4694
+ textureOptions: {
4695
+ alignToGraphic: !0
4696
+ },
4695
4697
  backgroundOpacity: 1,
4696
4698
  backgroundCornerRadius: 0,
4697
4699
  texture: null,
@@ -9461,6 +9463,7 @@
9461
9463
  const tempConstantXYKey = ["x", "y"],
9462
9464
  tempConstantScaleXYKey = ["scaleX", "scaleY"],
9463
9465
  tempConstantAngleKey = ["angle"],
9466
+ builtinTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave"]),
9464
9467
  point = new Point();
9465
9468
  const NOWORK_ANIMATE_ATTR = {
9466
9469
  strokeSeg: 1,
@@ -9517,7 +9520,7 @@
9517
9520
  }
9518
9521
  constructor(params = {}) {
9519
9522
  var _a;
9520
- super(), this._AABBBounds = new AABBBounds(), this._updateTag = exports.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);
9523
+ super(), this._AABBBounds = new AABBBounds(), this._updateTag = exports.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);
9521
9524
  }
9522
9525
  getGraphicService() {
9523
9526
  var _a, _b;
@@ -9706,7 +9709,7 @@
9706
9709
  });
9707
9710
  }
9708
9711
  setAttributes(params, forceUpdateTag = !1, context) {
9709
- 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));
9712
+ 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));
9710
9713
  }
9711
9714
  _setAttributes(params, forceUpdateTag = !1, context) {
9712
9715
  const keys = Object.keys(params);
@@ -9721,7 +9724,7 @@
9721
9724
  const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
9722
9725
  [key]: value
9723
9726
  }, this.attribute, key, context);
9724
- 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);
9727
+ 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);
9725
9728
  }
9726
9729
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
9727
9730
  for (let i = 0; i < k.length; i++) {
@@ -9740,7 +9743,7 @@
9740
9743
  const context = {
9741
9744
  type: exports.AttributeUpdateType.INIT
9742
9745
  };
9743
- 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 = exports.UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
9746
+ 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 = exports.UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
9744
9747
  }
9745
9748
  translate(x, y) {
9746
9749
  var _a, _b;
@@ -10131,6 +10134,9 @@
10131
10134
  function backgroundNotImage(image) {
10132
10135
  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));
10133
10136
  }
10137
+ function isExternalTexture(texture) {
10138
+ return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$1(texture));
10139
+ }
10134
10140
  Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget);
10135
10141
 
10136
10142
  exports.GroupUpdateAABBBoundsMode = void 0;
@@ -14171,38 +14177,42 @@
14171
14177
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
14172
14178
  }
14173
14179
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
14174
- var _a;
14180
+ var _a, _b, _c, _d, _e;
14175
14181
  const {
14176
14182
  textureRatio = graphicAttribute.textureRatio,
14177
14183
  textureOptions = null
14178
14184
  } = graphic.attribute;
14179
- let pattern = this.textureMap.get(texture);
14180
- if (!pattern) switch (texture) {
14181
- case "circle":
14182
- pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
14183
- break;
14184
- case "diamond":
14185
- pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
14186
- break;
14187
- case "rect":
14188
- pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
14189
- break;
14190
- case "vertical-line":
14191
- pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
14192
- break;
14193
- case "horizontal-line":
14194
- pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
14195
- break;
14196
- case "bias-lr":
14197
- pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
14198
- break;
14199
- case "bias-rl":
14200
- pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
14201
- break;
14202
- case "grid":
14203
- pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
14185
+ let pattern = null;
14186
+ const patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr);
14187
+ if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
14188
+ if ("string" == typeof texture) switch (texture) {
14189
+ case "circle":
14190
+ pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
14191
+ break;
14192
+ case "diamond":
14193
+ pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
14194
+ break;
14195
+ case "rect":
14196
+ pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
14197
+ break;
14198
+ case "vertical-line":
14199
+ pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
14200
+ break;
14201
+ case "horizontal-line":
14202
+ pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
14203
+ break;
14204
+ case "bias-lr":
14205
+ pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
14206
+ break;
14207
+ case "bias-rl":
14208
+ pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
14209
+ break;
14210
+ case "grid":
14211
+ pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
14212
+ }
14213
+ pattern || (pattern = this.createResourcePattern(texture, graphic, context)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
14204
14214
  }
14205
- if (textureOptions && textureOptions.dynamicTexture) {
14215
+ if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
14206
14216
  const {
14207
14217
  gridConfig = {},
14208
14218
  useNewCanvas: useNewCanvas
@@ -14250,7 +14260,21 @@
14250
14260
  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());
14251
14261
  }
14252
14262
  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();
14253
- } else if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
14263
+ } else if (pattern) {
14264
+ if (pattern.setTransform) {
14265
+ const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
14266
+ alignOffsetX = null !== (_b = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _b ? _b : 0,
14267
+ alignOffsetY = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _c ? _c : 0;
14268
+ let translateX = 0,
14269
+ translateY = 0;
14270
+ if (alignToGraphic) {
14271
+ const m = context.currentMatrix;
14272
+ 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;
14273
+ } else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
14274
+ pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
14275
+ }
14276
+ context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
14277
+ } else if ("wave" === texture) {
14254
14278
  context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
14255
14279
  const b = graphic.AABBBounds;
14256
14280
  drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
@@ -14258,6 +14282,17 @@
14258
14282
  }), x + b.x1 - x, y + b.y1 - y), context.restore();
14259
14283
  }
14260
14284
  }
14285
+ getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr) {
14286
+ return "string" != typeof texture ? texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
14287
+ }
14288
+ createResourcePattern(texture, graphic, context) {
14289
+ var _a;
14290
+ const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
14291
+ data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
14292
+ if (!data) return null;
14293
+ const pattern = context.createPattern(data, "repeat");
14294
+ return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
14295
+ }
14261
14296
  }
14262
14297
  const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();
14263
14298
 
@@ -52934,7 +52969,7 @@
52934
52969
  select: !0
52935
52970
  };
52936
52971
 
52937
- const version = "1.0.45";
52972
+ const version = "1.0.46-alpha.1";
52938
52973
  preLoadAllModule();
52939
52974
  if (isBrowserEnv()) {
52940
52975
  loadBrowserEnv(container);