@visactor/vchart 2.0.4-alpha.6 → 2.0.4-alpha.7

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.
Files changed (118) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.es.js +1508 -84
  3. package/build/index.js +1508 -84
  4. package/build/index.min.js +2 -2
  5. package/build/tsconfig.tsbuildinfo +1 -1
  6. package/cjs/animation/utils.js +1 -1
  7. package/cjs/animation/utils.js.map +1 -1
  8. package/cjs/chart/base/base-chart.js +2 -1
  9. package/cjs/chart/base/base-chart.js.map +1 -1
  10. package/cjs/chart/range-area/range-area-transformer.js +2 -1
  11. package/cjs/chart/range-area/range-area-transformer.js.map +1 -1
  12. package/cjs/compile/compiler.js +4 -3
  13. package/cjs/compile/compiler.js.map +1 -1
  14. package/cjs/component/data-zoom/data-filter-base-component.d.ts +2 -0
  15. package/cjs/component/data-zoom/data-filter-base-component.js +15 -5
  16. package/cjs/component/data-zoom/data-filter-base-component.js.map +1 -1
  17. package/cjs/component/data-zoom/interface.d.ts +1 -0
  18. package/cjs/component/data-zoom/interface.js.map +1 -1
  19. package/cjs/component/marker/mark-point/cartesian-mark-point.js +2 -2
  20. package/cjs/component/marker/mark-point/cartesian-mark-point.js.map +1 -1
  21. package/cjs/constant/event.d.ts +2 -1
  22. package/cjs/constant/event.js +1 -1
  23. package/cjs/constant/event.js.map +1 -1
  24. package/cjs/core/factory.d.ts +4 -0
  25. package/cjs/core/factory.js +8 -2
  26. package/cjs/core/factory.js.map +1 -1
  27. package/cjs/core/index.d.ts +1 -1
  28. package/cjs/core/index.js +1 -1
  29. package/cjs/core/index.js.map +1 -1
  30. package/cjs/core/interface.d.ts +2 -0
  31. package/cjs/core/interface.js.map +1 -1
  32. package/cjs/core/vchart.d.ts +3 -1
  33. package/cjs/core/vchart.js +7 -1
  34. package/cjs/core/vchart.js.map +1 -1
  35. package/cjs/model/interface.d.ts +1 -0
  36. package/cjs/model/interface.js.map +1 -1
  37. package/cjs/plugin/components/tooltip-handler/dom-tooltip-handler.d.ts +1 -1
  38. package/cjs/plugin/components/tooltip-handler/dom-tooltip-handler.js +17 -17
  39. package/cjs/plugin/components/tooltip-handler/dom-tooltip-handler.js.map +1 -1
  40. package/cjs/plugin/vchart/index.d.ts +2 -0
  41. package/cjs/plugin/vchart/index.js +21 -0
  42. package/cjs/plugin/vchart/index.js.map +1 -0
  43. package/cjs/plugin/vchart/interface.d.ts +16 -0
  44. package/cjs/plugin/vchart/interface.js +6 -0
  45. package/cjs/plugin/vchart/interface.js.map +1 -0
  46. package/cjs/plugin/vchart/plugin-service.d.ts +9 -0
  47. package/cjs/plugin/vchart/plugin-service.js +24 -0
  48. package/cjs/plugin/vchart/plugin-service.js.map +1 -0
  49. package/cjs/plugin/vchart/register.d.ts +2 -0
  50. package/cjs/plugin/vchart/register.js +12 -0
  51. package/cjs/plugin/vchart/register.js.map +1 -0
  52. package/cjs/plugin/vchart/rotate/index.d.ts +1 -0
  53. package/cjs/plugin/vchart/rotate/index.js +21 -0
  54. package/cjs/plugin/vchart/rotate/index.js.map +1 -0
  55. package/cjs/plugin/vchart/rotate/rotate.d.ts +18 -0
  56. package/cjs/plugin/vchart/rotate/rotate.js +67 -0
  57. package/cjs/plugin/vchart/rotate/rotate.js.map +1 -0
  58. package/cjs/series/word-cloud/base.js +15 -1
  59. package/cjs/series/word-cloud/base.js.map +1 -1
  60. package/cjs/typings/spec/common.d.ts +1 -0
  61. package/cjs/typings/spec/common.js.map +1 -1
  62. package/esm/animation/utils.js +1 -1
  63. package/esm/animation/utils.js.map +1 -1
  64. package/esm/chart/base/base-chart.js +2 -1
  65. package/esm/chart/base/base-chart.js.map +1 -1
  66. package/esm/chart/range-area/range-area-transformer.js +2 -1
  67. package/esm/chart/range-area/range-area-transformer.js.map +1 -1
  68. package/esm/compile/compiler.js +4 -3
  69. package/esm/compile/compiler.js.map +1 -1
  70. package/esm/component/data-zoom/data-filter-base-component.d.ts +2 -0
  71. package/esm/component/data-zoom/data-filter-base-component.js +16 -6
  72. package/esm/component/data-zoom/data-filter-base-component.js.map +1 -1
  73. package/esm/component/data-zoom/interface.d.ts +1 -0
  74. package/esm/component/data-zoom/interface.js.map +1 -1
  75. package/esm/component/marker/mark-point/cartesian-mark-point.js +2 -2
  76. package/esm/component/marker/mark-point/cartesian-mark-point.js.map +1 -1
  77. package/esm/constant/event.d.ts +2 -1
  78. package/esm/constant/event.js +1 -1
  79. package/esm/constant/event.js.map +1 -1
  80. package/esm/core/factory.d.ts +4 -0
  81. package/esm/core/factory.js +8 -1
  82. package/esm/core/factory.js.map +1 -1
  83. package/esm/core/index.d.ts +1 -1
  84. package/esm/core/index.js +1 -1
  85. package/esm/core/index.js.map +1 -1
  86. package/esm/core/interface.d.ts +2 -0
  87. package/esm/core/interface.js.map +1 -1
  88. package/esm/core/vchart.d.ts +3 -1
  89. package/esm/core/vchart.js +8 -0
  90. package/esm/core/vchart.js.map +1 -1
  91. package/esm/model/interface.d.ts +1 -0
  92. package/esm/model/interface.js.map +1 -1
  93. package/esm/plugin/components/tooltip-handler/dom-tooltip-handler.d.ts +1 -1
  94. package/esm/plugin/components/tooltip-handler/dom-tooltip-handler.js +17 -17
  95. package/esm/plugin/components/tooltip-handler/dom-tooltip-handler.js.map +1 -1
  96. package/esm/plugin/vchart/index.d.ts +2 -0
  97. package/esm/plugin/vchart/index.js +4 -0
  98. package/esm/plugin/vchart/index.js.map +1 -0
  99. package/esm/plugin/vchart/interface.d.ts +16 -0
  100. package/esm/plugin/vchart/interface.js +2 -0
  101. package/esm/plugin/vchart/interface.js.map +1 -0
  102. package/esm/plugin/vchart/plugin-service.d.ts +9 -0
  103. package/esm/plugin/vchart/plugin-service.js +16 -0
  104. package/esm/plugin/vchart/plugin-service.js.map +1 -0
  105. package/esm/plugin/vchart/register.d.ts +2 -0
  106. package/esm/plugin/vchart/register.js +6 -0
  107. package/esm/plugin/vchart/register.js.map +1 -0
  108. package/esm/plugin/vchart/rotate/index.d.ts +1 -0
  109. package/esm/plugin/vchart/rotate/index.js +2 -0
  110. package/esm/plugin/vchart/rotate/index.js.map +1 -0
  111. package/esm/plugin/vchart/rotate/rotate.d.ts +18 -0
  112. package/esm/plugin/vchart/rotate/rotate.js +62 -0
  113. package/esm/plugin/vchart/rotate/rotate.js.map +1 -0
  114. package/esm/series/word-cloud/base.js +16 -0
  115. package/esm/series/word-cloud/base.js.map +1 -1
  116. package/esm/typings/spec/common.d.ts +1 -0
  117. package/esm/typings/spec/common.js.map +1 -1
  118. package/package.json +8 -8
package/build/index.js CHANGED
@@ -9499,7 +9499,8 @@
9499
9499
  y1: 0,
9500
9500
  strokeBoundsBuffer: 0,
9501
9501
  cornerRadius: 0,
9502
- cornerType: "round"
9502
+ cornerType: "round",
9503
+ drawStrokeWhenZeroWH: !1
9503
9504
  });
9504
9505
  Object.assign(Object.assign({}, DefaultAttribute), {
9505
9506
  width: 0,
@@ -9508,7 +9509,8 @@
9508
9509
  y1: 0,
9509
9510
  cornerRadius: 0,
9510
9511
  length: 0,
9511
- cornerType: "round"
9512
+ cornerType: "round",
9513
+ drawStrokeWhenZeroWH: !1
9512
9514
  });
9513
9515
  const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
9514
9516
  symbolType: "circle",
@@ -9735,6 +9737,34 @@
9735
9737
  }
9736
9738
  return c;
9737
9739
  }
9740
+ static processColorStops(colorStops) {
9741
+ if (!colorStops || 0 === colorStops.length) return [];
9742
+ if (colorStops.some(item => item.length)) {
9743
+ const stops = colorStops.map(item => ({
9744
+ color: item.value,
9745
+ offset: item.length ? parseFloat(item.length.value) / 100 : -1
9746
+ }));
9747
+ stops[0].offset < 0 && (stops[0].offset = 0), stops[stops.length - 1].offset < 0 && (stops[stops.length - 1].offset = 1);
9748
+ for (let i = 1; i < stops.length - 1; i++) if (stops[i].offset < 0) {
9749
+ const prevWithOffsetIdx = i - 1;
9750
+ let nextWithOffsetIdx = i + 1;
9751
+ for (; nextWithOffsetIdx < stops.length && stops[nextWithOffsetIdx].offset < 0;) nextWithOffsetIdx++;
9752
+ const startOffset = stops[prevWithOffsetIdx].offset,
9753
+ endOffset = stops[nextWithOffsetIdx].offset,
9754
+ unspecCount = nextWithOffsetIdx - prevWithOffsetIdx;
9755
+ for (let j = 1; j < unspecCount; j++) stops[prevWithOffsetIdx + j].offset = startOffset + (endOffset - startOffset) * j / unspecCount;
9756
+ i = nextWithOffsetIdx - 1;
9757
+ }
9758
+ return stops;
9759
+ }
9760
+ return colorStops.map((item, index) => {
9761
+ const offset = colorStops.length > 1 ? index / (colorStops.length - 1) : 0;
9762
+ return {
9763
+ color: item.value,
9764
+ offset: offset
9765
+ };
9766
+ });
9767
+ }
9738
9768
  static ParseConic(datum) {
9739
9769
  const {
9740
9770
  orientation: orientation,
@@ -9748,10 +9778,7 @@
9748
9778
  y: .5,
9749
9779
  startAngle: sa,
9750
9780
  endAngle: sa + pi2,
9751
- stops: colorStops.map(item => ({
9752
- color: item.value,
9753
- offset: parseFloat(item.length.value) / 100
9754
- }))
9781
+ stops: GradientParser.processColorStops(colorStops)
9755
9782
  };
9756
9783
  }
9757
9784
  static ParseRadial(datum) {
@@ -9766,10 +9793,7 @@
9766
9793
  y1: .5,
9767
9794
  r0: 0,
9768
9795
  r1: 1,
9769
- stops: colorStops.map(item => ({
9770
- color: item.value,
9771
- offset: parseFloat(item.length.value) / 100
9772
- }))
9796
+ stops: GradientParser.processColorStops(colorStops)
9773
9797
  };
9774
9798
  }
9775
9799
  static ParseLinear(datum) {
@@ -9791,10 +9815,7 @@
9791
9815
  y0: y0,
9792
9816
  x1: x1,
9793
9817
  y1: y1,
9794
- stops: colorStops.map(item => ({
9795
- color: item.value,
9796
- offset: parseFloat(item.length.value) / 100
9797
- }))
9818
+ stops: GradientParser.processColorStops(colorStops)
9798
9819
  };
9799
9820
  }
9800
9821
  }
@@ -14181,7 +14202,7 @@
14181
14202
  });
14182
14203
  }
14183
14204
  setAttributes(params, forceUpdateTag = !1, context) {
14184
- (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);
14205
+ 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));
14185
14206
  }
14186
14207
  _setAttributes(params, forceUpdateTag = !1, context) {
14187
14208
  const keys = Object.keys(params);
@@ -15006,8 +15027,8 @@
15006
15027
  function strokeVisible(opacity, strokeOpacity) {
15007
15028
  return opacity * strokeOpacity > 0;
15008
15029
  }
15009
- function rectStrokeVisible(opacity, strokeOpacity, width, height) {
15010
- return opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
15030
+ function rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH) {
15031
+ return drawStrokeWhenZeroWH ? opacity * strokeOpacity > 0 : opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
15011
15032
  }
15012
15033
  function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
15013
15034
  const x10 = x1 - x0,
@@ -16377,14 +16398,10 @@
16377
16398
  attrs && (Object.assign(stateAttrs, attrs.attributes), (null === (_a = attrs.subAttributes) || void 0 === _a ? void 0 : _a.length) && subAttrs.forEach((subAttrs, index) => {
16378
16399
  Object.assign(subAttrs, attrs.subAttributes[index]);
16379
16400
  }));
16380
- }), this.subGraphic.forEach((graphic, index) => {
16381
- graphic.updateNormalAttrs(subAttrs[index]), graphic.applyStateAttrs(subAttrs[index], states, hasAnimation);
16382
16401
  }), this.updateNormalAttrs(stateAttrs), this.currentStates = states, this.applyStateAttrs(stateAttrs, states, hasAnimation);
16383
16402
  }
16384
16403
  clearStates(hasAnimation) {
16385
- this.stopStateAnimates(), this.hasState() && this.normalAttrs ? (this.currentStates = [], this.subGraphic.forEach(graphic => {
16386
- graphic.applyStateAttrs(graphic.normalAttrs, this.currentStates, hasAnimation, !0), graphic.normalAttrs = null;
16387
- }), this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
16404
+ this.stopStateAnimates(), this.hasState() && this.normalAttrs ? (this.currentStates = [], this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
16388
16405
  }
16389
16406
  clone() {
16390
16407
  const glyph = new Glyph(Object.assign({}, this.attribute));
@@ -17143,7 +17160,7 @@
17143
17160
  case "right":
17144
17161
  deltaX = -aabbBounds.width();
17145
17162
  }
17146
- return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1, application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
17163
+ return height || ("middle" === this.verticalDirection ? deltaY -= aabbBounds.height() / 2 : "bottom" === this.verticalDirection && (deltaY -= aabbBounds.height())), aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1, application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
17147
17164
  }
17148
17165
  needUpdateTags(keys) {
17149
17166
  return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
@@ -19643,7 +19660,8 @@
19643
19660
  y1: y1,
19644
19661
  x: originX = rectAttribute.x,
19645
19662
  y: originY = rectAttribute.y,
19646
- fillStrokeOrder = rectAttribute.fillStrokeOrder
19663
+ fillStrokeOrder = rectAttribute.fillStrokeOrder,
19664
+ drawStrokeWhenZeroWH = rectAttribute.drawStrokeWhenZeroWH
19647
19665
  } = rect.attribute;
19648
19666
  let {
19649
19667
  width: width,
@@ -19651,7 +19669,7 @@
19651
19669
  } = rect.attribute;
19652
19670
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
19653
19671
  const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
19654
- sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
19672
+ sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH),
19655
19673
  doFill = runFill(fill, background),
19656
19674
  doStroke = runStroke(stroke, lineWidth);
19657
19675
  if (!rect.valid || !visible) return;
@@ -21709,13 +21727,13 @@
21709
21727
  this._skipRender > 1 && this.renderNextFrame(), this._skipRender = 0;
21710
21728
  } else this._skipRender = 1;
21711
21729
  }, this.beforeRender = stage => {
21712
- this._beforeRender && this._beforeRender(stage);
21730
+ this._beforeRenderList.forEach(cb => cb(stage));
21713
21731
  }, this.afterClearScreen = drawParams => {
21714
21732
  this._afterClearScreen && this._afterClearScreen(drawParams);
21715
21733
  }, this.afterClearRect = drawParams => {
21716
21734
  this._afterClearRect && this._afterClearRect(drawParams);
21717
21735
  }, this.afterRender = stage => {
21718
- this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
21736
+ this.renderCount++, this._afterRenderList.forEach(cb => cb(stage)), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
21719
21737
  }, this.afterTickCb = () => {
21720
21738
  this.tickedBeforeRender = !0, "rendering" !== this.state && this.renderNextFrame();
21721
21739
  }, this.params = params, this.theme = new Theme(), this.hooks = {
@@ -21723,7 +21741,7 @@
21723
21741
  afterRender: new SyncHook(["stage"]),
21724
21742
  afterClearScreen: new SyncHook(["stage"]),
21725
21743
  afterClearRect: new SyncHook(["stage"])
21726
- }, this.global = application.global, !this.global.env && isBrowserEnv() && this.global.setEnv("browser"), this.window = container.get(VWindow), this.renderService = container.get(RenderService), this.pluginService = container.get(PluginService), this.layerService = container.get(LayerService), this.graphicService = container.get(GraphicService), this.pluginService.active(this, params), this.window.create({
21744
+ }, this.global = application.global, !this.global.env && isBrowserEnv() && this.global.setEnv("browser"), this.window = container.get(VWindow), this.renderService = container.get(RenderService), this.pluginService = container.get(PluginService), this.layerService = container.get(LayerService), this.graphicService = container.get(GraphicService), this.pluginService.active(this, params), this._beforeRenderList = [], this._afterRenderList = [], this.window.create({
21727
21745
  width: params.width,
21728
21746
  height: params.height,
21729
21747
  viewBox: params.viewBox,
@@ -21734,7 +21752,7 @@
21734
21752
  canvas: params.canvas
21735
21753
  }), this.state = "normal", this.renderCount = 0, this.tryInitEventSystem(), this._background = null !== (_a = params.background) && void 0 !== _a ? _a : DefaultConfig.BACKGROUND, this.appendChild(this.layerService.createLayer(this, {
21736
21754
  main: !0
21737
- })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), this.hooks.afterClearScreen.tap("constructor", this.afterClearScreen), this.hooks.afterClearRect.tap("constructor", this.afterClearRect), this._beforeRender = params.beforeRender, this._afterRender = params.afterRender, this._afterClearScreen = params.afterClearScreen, this._afterClearRect = params.afterClearRect, this.supportInteractiveLayer = !1 !== params.interactiveLayer, params.optimize || (params.optimize = {
21755
+ })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), params.beforeRender && this._beforeRenderList.push(params.beforeRender), params.afterRender && this._afterRenderList.push(params.afterRender), this.hooks.afterClearScreen.tap("constructor", this.afterClearScreen), this.hooks.afterClearRect.tap("constructor", this.afterClearRect), this._afterClearScreen = params.afterClearScreen, this._afterClearRect = params.afterClearRect, this.supportInteractiveLayer = !1 !== params.interactiveLayer, params.optimize || (params.optimize = {
21738
21756
  tickRenderMode: "effect"
21739
21757
  }), this.optmize(params.optimize), params.background && isString$1(this._background) && this._background.includes("/") && this.setAttributes({
21740
21758
  background: this._background
@@ -21849,10 +21867,16 @@
21849
21867
  options.enableView3dTransform && this.enableView3dTransform();
21850
21868
  }
21851
21869
  setBeforeRender(cb) {
21852
- this._beforeRender = cb;
21870
+ this._beforeRenderList.push(cb);
21871
+ }
21872
+ removeBeforeRender(cb) {
21873
+ this._beforeRenderList = this._beforeRenderList.filter(c => c !== cb);
21853
21874
  }
21854
21875
  setAfterRender(cb) {
21855
- this._afterRender = cb;
21876
+ this._afterRenderList.push(cb);
21877
+ }
21878
+ removeAfterRender(cb) {
21879
+ this._afterRenderList = this._afterRenderList.filter(c => c !== cb);
21856
21880
  }
21857
21881
  afterNextRender(cb) {
21858
21882
  this._afterNextRenderCbs || (this._afterNextRenderCbs = []), this._afterNextRenderCbs.push(cb);
@@ -31719,6 +31743,7 @@
31719
31743
  return this.getEndProps();
31720
31744
  }
31721
31745
  stop() {}
31746
+ release() {}
31722
31747
  }
31723
31748
  class WaitStep extends Step {
31724
31749
  constructor(type, props, duration, easing) {
@@ -31726,8 +31751,6 @@
31726
31751
  }
31727
31752
  onStart() {
31728
31753
  super.onStart();
31729
- }
31730
- onFirstRun() {
31731
31754
  const fromProps = this.getFromProps();
31732
31755
  this.target.setAttributes(fromProps);
31733
31756
  }
@@ -31936,7 +31959,9 @@
31936
31959
  this.status !== AnimateStatus.END && this.onEnd(), this.status = AnimateStatus.END, this.target && ("start" === type ? this.target.setAttributes(this._startProps) : "end" === type ? this.target.setAttributes(this._endProps) : type && this.target.setAttributes(type));
31937
31960
  }
31938
31961
  release() {
31939
- this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [];
31962
+ this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [], this.forEachStep(step => {
31963
+ step.release();
31964
+ });
31940
31965
  }
31941
31966
  getDuration() {
31942
31967
  return this._duration;
@@ -32010,6 +32035,10 @@
32010
32035
  getLoop() {
32011
32036
  return this._loopCount;
32012
32037
  }
32038
+ forEachStep(cb) {
32039
+ let step = this._firstStep;
32040
+ for (; step;) cb(step), step = step.next;
32041
+ }
32013
32042
  }
32014
32043
 
32015
32044
  const performanceRAF = new PerformanceRAF();
@@ -32289,6 +32318,9 @@
32289
32318
  constructor(target) {
32290
32319
  this._animates = [], this._startCallbacks = [], this._endCallbacks = [], this._started = !1, this._activeCount = 0, this._target = target;
32291
32320
  }
32321
+ get started() {
32322
+ return this._started;
32323
+ }
32292
32324
  onStart(cb) {
32293
32325
  cb ? (this._startCallbacks.push(cb), this._started && this._activeCount > 0 && cb()) : this._startCallbacks.forEach(cb => {
32294
32326
  cb();
@@ -32429,14 +32461,14 @@
32429
32461
  return delayAfterValue > 0 && (totalDelay += delayAfterValue), totalDelay > 0 && animate.wait(totalDelay), loop && loop > 0 && animate.loop(loop), bounce && animate.bounce(!0), animate;
32430
32462
  }
32431
32463
  _handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic) {
32432
- var _a, _b, _c, _d;
32464
+ var _a, _b, _c, _d, _e, _f;
32433
32465
  if (custom && customType) {
32434
32466
  const customParams = Object.assign({
32435
- width: graphic.stage.width,
32436
- height: graphic.stage.height,
32467
+ width: (null === (_a = graphic.stage) || void 0 === _a ? void 0 : _a.width) || 0,
32468
+ height: (null === (_b = graphic.stage) || void 0 === _b ? void 0 : _b.height) || 0,
32437
32469
  group: this._target.parent
32438
32470
  }, this.resolveValue(customParameters, graphic)),
32439
- objOptions = isFunction$1(options) ? options.call(null, null !== (_b = customParams && (null === (_a = customParams.data) || void 0 === _a ? void 0 : _a[0])) && void 0 !== _b ? _b : null === (_d = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.data) || void 0 === _d ? void 0 : _d[0], graphic, customParams) : options;
32471
+ objOptions = isFunction$1(options) ? options.call(null, null !== (_d = customParams && (null === (_c = customParams.data) || void 0 === _c ? void 0 : _c[0])) && void 0 !== _d ? _d : null === (_f = null === (_e = graphic.context) || void 0 === _e ? void 0 : _e.data) || void 0 === _f ? void 0 : _f[0], graphic, customParams) : options;
32440
32472
  customParams.options = objOptions, customParams.controlOptions = controlOptions, 1 === customType ? this.createCustomAnimation(animate, custom, from, props, duration, easing, customParams) : 2 === customType && this.createCustomInterpolatorAnimation(animate, custom, props, duration, easing, customParams);
32441
32473
  } else "to" === type ? animate.to(props, duration, easing) : "from" === type && animate.from(props, duration, easing);
32442
32474
  }
@@ -32656,7 +32688,7 @@
32656
32688
  reApplyState(state) {
32657
32689
  var _a;
32658
32690
  const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find(stateInfo => stateInfo.state === state);
32659
- if (stateInfo) {
32691
+ if (stateInfo && stateInfo.executor.started) {
32660
32692
  const stateList = this.stateList.slice();
32661
32693
  stateInfo.executor.stop(), this.stateList = stateList, stateInfo.executor.execute(stateInfo.animationConfig);
32662
32694
  }
@@ -32799,6 +32831,45 @@
32799
32831
  this._animator && this._animator.stop();
32800
32832
  }
32801
32833
  }
32834
+ class AStageAnimate extends ACustomAnimate {
32835
+ constructor(customFrom, customTo, duration, easing, params) {
32836
+ super(customFrom, customTo, duration, easing, params), this.willCallBeforeStageRender = !0, this.willCallAfterStageRender = !0, this._beforeStageRender = () => {
32837
+ if (!this.willCallBeforeStageRender) return;
32838
+ this.willCallBeforeStageRender = !1;
32839
+ const stage = this.target.stage,
32840
+ canvas = stage.window.getContext().canvas.nativeCanvas,
32841
+ outputCanvas = this.beforeStageRender(stage, canvas);
32842
+ outputCanvas && this.renderToStage(stage, outputCanvas);
32843
+ }, this._afterStageRender = () => {
32844
+ if (!this.willCallAfterStageRender) return;
32845
+ this.willCallAfterStageRender = !1;
32846
+ const stage = this.target.stage,
32847
+ canvas = stage.window.getContext().canvas.nativeCanvas,
32848
+ outputCanvas = this.afterStageRender(stage, canvas);
32849
+ outputCanvas && this.renderToStage(stage, outputCanvas);
32850
+ }, this.props = {};
32851
+ }
32852
+ beforeStageRender(stage, canvas) {
32853
+ return !1;
32854
+ }
32855
+ afterStageRender(stage, canvas) {
32856
+ return !1;
32857
+ }
32858
+ onFirstRun() {
32859
+ super.onFirstRun(), this.target.stage.setBeforeRender(this._beforeStageRender), this.target.stage.setAfterRender(this._afterStageRender), this.target.stage.disableDirtyBounds();
32860
+ }
32861
+ stop() {
32862
+ super.stop(), this.target.stage.removeBeforeRender(this._beforeStageRender), this.target.stage.removeAfterRender(this._afterStageRender);
32863
+ }
32864
+ onUpdate(end, ratio, out) {
32865
+ super.onUpdate(end, ratio, out), this.willCallBeforeStageRender = !0, this.willCallAfterStageRender = !0;
32866
+ }
32867
+ renderToStage(stage, canvas) {
32868
+ const stageCanvas = stage.window.getContext().canvas.nativeCanvas,
32869
+ ctx = stageCanvas.getContext("2d");
32870
+ return !!ctx && (ctx.clearRect(0, 0, stageCanvas.width, stageCanvas.height), ctx.drawImage(canvas, 0, 0), stageCanvas);
32871
+ }
32872
+ }
32802
32873
 
32803
32874
  class ComponentAnimator {
32804
32875
  constructor(component) {
@@ -33700,7 +33771,7 @@
33700
33771
  }
33701
33772
  class GrowAngleIn extends GrowAngleBase {
33702
33773
  onBind() {
33703
- var _a, _b;
33774
+ var _a, _b, _c;
33704
33775
  super.onBind();
33705
33776
  const {
33706
33777
  from: from,
@@ -33709,7 +33780,7 @@
33709
33780
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
33710
33781
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
33711
33782
  const finalAttribute = this.target.getFinalAttribute();
33712
- finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs), this.determineUpdateFunction();
33783
+ finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs), this.determineUpdateFunction();
33713
33784
  }
33714
33785
  }
33715
33786
  class GrowAngleOut extends GrowAngleBase {
@@ -34317,7 +34388,7 @@
34317
34388
  }
34318
34389
  class GrowRadiusIn extends GrowPointsBase {
34319
34390
  onBind() {
34320
- var _a, _b;
34391
+ var _a, _b, _c;
34321
34392
  super.onBind();
34322
34393
  const {
34323
34394
  from: from,
@@ -34326,7 +34397,7 @@
34326
34397
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
34327
34398
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
34328
34399
  const finalAttribute = this.target.getFinalAttribute();
34329
- finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
34400
+ finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
34330
34401
  }
34331
34402
  }
34332
34403
  class GrowRadiusOut extends GrowPointsBase {
@@ -34441,7 +34512,7 @@
34441
34512
  super(from, to, duration, easing, params);
34442
34513
  }
34443
34514
  onBind() {
34444
- var _a, _b;
34515
+ var _a, _b, _c;
34445
34516
  super.onBind();
34446
34517
  const {
34447
34518
  from: from,
@@ -34450,7 +34521,7 @@
34450
34521
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
34451
34522
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
34452
34523
  const finalAttribute = this.target.getFinalAttribute();
34453
- finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
34524
+ finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
34454
34525
  }
34455
34526
  onEnd(cb) {
34456
34527
  super.onEnd(cb);
@@ -36234,8 +36305,1277 @@
36234
36305
  }
36235
36306
  }
36236
36307
 
36308
+ class DisappearAnimateBase extends AStageAnimate {
36309
+ constructor(from, to, duration, easing, params) {
36310
+ super(from, to, duration, easing, params), this.webglCanvas = null, this.gl = null, this.program = null, this.currentAnimationRatio = 0, this.animationTime = 0;
36311
+ }
36312
+ onUpdate(end, ratio, out) {
36313
+ super.onUpdate(end, ratio, out), this.currentAnimationRatio = ratio, this.animationTime = ratio * Math.PI * 2;
36314
+ }
36315
+ getAnimationTime() {
36316
+ return this.currentAnimationRatio > 0 ? this.animationTime : Date.now() / 1e3;
36317
+ }
36318
+ getDurationFromParent() {
36319
+ return this.duration || 1e3;
36320
+ }
36321
+ initWebGL(canvas) {
36322
+ try {
36323
+ if (this.webglCanvas = vglobal.createCanvas({
36324
+ width: canvas.width,
36325
+ height: canvas.height,
36326
+ dpr: vglobal.devicePixelRatio
36327
+ }), !this.webglCanvas) return console.warn("WebGL canvas creation failed"), !1;
36328
+ this.webglCanvas.style.width = canvas.style.width || `${canvas.width}px`, this.webglCanvas.style.height = canvas.style.height || `${canvas.height}px`;
36329
+ let glContext = null;
36330
+ try {
36331
+ glContext = this.webglCanvas.getContext("webgl"), glContext || (glContext = this.webglCanvas.getContext("experimental-webgl"));
36332
+ } catch (e) {
36333
+ console.warn("Failed to get WebGL context:", e);
36334
+ }
36335
+ if (this.gl = glContext, !this.gl) return console.warn("WebGL not supported"), !1;
36336
+ const shaders = this.getShaderSources();
36337
+ return this.program = this.createShaderProgram(shaders.vertex, shaders.fragment), null !== this.program;
36338
+ } catch (error) {
36339
+ return console.warn("Failed to initialize WebGL:", error), !1;
36340
+ }
36341
+ }
36342
+ createShaderProgram(vertexSource, fragmentSource) {
36343
+ if (!this.gl) return null;
36344
+ const vertexShader = this.createShader(this.gl.VERTEX_SHADER, vertexSource),
36345
+ fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, fragmentSource);
36346
+ if (!vertexShader || !fragmentShader) return null;
36347
+ const program = this.gl.createProgram();
36348
+ return program ? (this.gl.attachShader(program, vertexShader), this.gl.attachShader(program, fragmentShader), this.gl.linkProgram(program), this.gl.getProgramParameter(program, this.gl.LINK_STATUS) ? program : (console.error("Shader program link error:", this.gl.getProgramInfoLog(program)), null)) : null;
36349
+ }
36350
+ createShader(type, source) {
36351
+ if (!this.gl) return null;
36352
+ const shader = this.gl.createShader(type);
36353
+ return shader ? (this.gl.shaderSource(shader, source), this.gl.compileShader(shader), this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS) ? shader : (console.error("Shader compile error:", this.gl.getShaderInfoLog(shader)), this.gl.deleteShader(shader), null)) : null;
36354
+ }
36355
+ setupWebGLState(canvas) {
36356
+ this.gl && this.webglCanvas && (this.webglCanvas.width === canvas.width && this.webglCanvas.height === canvas.height || (this.webglCanvas.width = canvas.width, this.webglCanvas.height = canvas.height), this.gl.viewport(0, 0, this.webglCanvas.width, this.webglCanvas.height), this.gl.clearColor(0, 0, 0, 0), this.gl.clear(this.gl.COLOR_BUFFER_BIT));
36357
+ }
36358
+ createFullScreenQuad() {
36359
+ if (!this.gl) return null;
36360
+ const vertices = new Float32Array([-1, -1, 0, 1, 1, -1, 1, 1, -1, 1, 0, 0, 1, 1, 1, 0]),
36361
+ vertexBuffer = this.gl.createBuffer();
36362
+ return this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertexBuffer), this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW), vertexBuffer;
36363
+ }
36364
+ createTextureFromCanvas(canvas) {
36365
+ if (!this.gl) return null;
36366
+ const texture = this.gl.createTexture();
36367
+ return this.gl.activeTexture(this.gl.TEXTURE0), this.gl.bindTexture(this.gl.TEXTURE_2D, texture), this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, canvas), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR), texture;
36368
+ }
36369
+ setupVertexAttributes() {
36370
+ if (!this.gl || !this.program) return;
36371
+ const positionLocation = this.gl.getAttribLocation(this.program, "a_position"),
36372
+ texCoordLocation = this.gl.getAttribLocation(this.program, "a_texCoord");
36373
+ this.gl.enableVertexAttribArray(positionLocation), this.gl.vertexAttribPointer(positionLocation, 2, this.gl.FLOAT, !1, 16, 0), this.gl.enableVertexAttribArray(texCoordLocation), this.gl.vertexAttribPointer(texCoordLocation, 2, this.gl.FLOAT, !1, 16, 8);
36374
+ }
36375
+ createOutputCanvas(canvas) {
36376
+ const outputCanvas = vglobal.createCanvas({
36377
+ width: canvas.width,
36378
+ height: canvas.height,
36379
+ dpr: vglobal.devicePixelRatio
36380
+ }),
36381
+ ctx = outputCanvas.getContext("2d");
36382
+ return ctx ? (ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.drawImage(canvas, 0, 0), {
36383
+ canvas: outputCanvas,
36384
+ ctx: ctx
36385
+ }) : null;
36386
+ }
36387
+ getShaderSources() {
36388
+ return null;
36389
+ }
36390
+ applyWebGLEffect(canvas) {
36391
+ return null;
36392
+ }
36393
+ applyCanvas2DEffect(canvas) {
36394
+ return null;
36395
+ }
36396
+ supportsWebGL() {
36397
+ return null !== this.getShaderSources();
36398
+ }
36399
+ supportsCanvas2D() {
36400
+ return this.applyCanvas2DEffect !== DisappearAnimateBase.prototype.applyCanvas2DEffect;
36401
+ }
36402
+ release() {
36403
+ super.release(), this.gl && (this.program && (this.gl.deleteProgram(this.program), this.program = null), this.gl = null), this.webglCanvas && (this.webglCanvas = null), this.currentAnimationRatio = 0, this.animationTime = 0;
36404
+ }
36405
+ afterStageRender(stage, canvas) {
36406
+ let result = null;
36407
+ if (this.supportsWebGL() && (this.gl || this.initWebGL(canvas) || console.warn("WebGL初始化失败,尝试Canvas 2D回退"), this.gl)) {
36408
+ if (result = this.applyWebGLEffect(canvas), result) return result;
36409
+ console.warn("WebGL特效执行失败,尝试Canvas 2D回退");
36410
+ }
36411
+ if (this.supportsCanvas2D()) {
36412
+ if (result = this.applyCanvas2DEffect(canvas), result) return result;
36413
+ console.warn("Canvas 2D特效执行失败");
36414
+ }
36415
+ return this.supportsWebGL() || this.supportsCanvas2D() || console.error(`特效类 ${this.constructor.name} 未实现任何渲染方法。请实现 applyWebGLEffect 或 applyCanvas2DEffect 方法。`), canvas;
36416
+ }
36417
+ }
36418
+
36419
+ class Canvas2DEffectBase extends DisappearAnimateBase {
36420
+ constructor(from, to, duration, easing, params) {
36421
+ super(from, to, duration, easing, params);
36422
+ }
36423
+ getShaderSources() {
36424
+ return null;
36425
+ }
36426
+ applyWebGLEffect(canvas) {
36427
+ return null;
36428
+ }
36429
+ }
36430
+ class HybridEffectBase extends DisappearAnimateBase {
36431
+ constructor(from, to, duration, easing, params) {
36432
+ super(from, to, duration, easing, params);
36433
+ }
36434
+ getShaderSources() {
36435
+ return null;
36436
+ }
36437
+ applyWebGLEffect(canvas) {
36438
+ return null;
36439
+ }
36440
+ applyCanvas2DEffect(canvas) {
36441
+ return null;
36442
+ }
36443
+ supportsWebGL() {
36444
+ return this.getShaderSources !== HybridEffectBase.prototype.getShaderSources && null !== this.getShaderSources();
36445
+ }
36446
+ supportsCanvas2D() {
36447
+ return this.applyCanvas2DEffect !== HybridEffectBase.prototype.applyCanvas2DEffect;
36448
+ }
36449
+ afterStageRender(stage, canvas) {
36450
+ var _a, _b;
36451
+ let result = null;
36452
+ if (!1 !== (null === (_b = null === (_a = this.params) || void 0 === _a ? void 0 : _a.options) || void 0 === _b ? void 0 : _b.useWebGL)) {
36453
+ if (this.supportsWebGL() && (this.gl || this.initWebGL(canvas) || console.warn("WebGL初始化失败,尝试Canvas 2D回退"), this.gl)) {
36454
+ if (result = this.applyWebGLEffect(canvas), result) return result;
36455
+ console.warn("WebGL特效执行失败,尝试Canvas 2D回退");
36456
+ }
36457
+ if (this.supportsCanvas2D()) {
36458
+ if (result = this.applyCanvas2DEffect(canvas), result) return result;
36459
+ console.warn("Canvas 2D特效执行失败");
36460
+ }
36461
+ } else if (this.supportsCanvas2D()) {
36462
+ if (result = this.applyCanvas2DEffect(canvas), result) return result;
36463
+ console.warn("Canvas 2D特效执行失败");
36464
+ } else console.warn(`${this.constructor.name}: useWebGL=false 但未实现Canvas 2D方法`);
36465
+ return this.supportsWebGL() || this.supportsCanvas2D() || console.error(`特效类 ${this.constructor.name} 未实现任何渲染方法。请实现 applyWebGLEffect 或 applyCanvas2DEffect 方法。`), canvas;
36466
+ }
36467
+ }
36468
+
36469
+ class ImageProcessUtils {
36470
+ static createTempCanvas(width, height, dpr) {
36471
+ return vglobal.createCanvas({
36472
+ width: width,
36473
+ height: height,
36474
+ dpr: dpr || vglobal.devicePixelRatio
36475
+ });
36476
+ }
36477
+ static cloneImageData(imageData) {
36478
+ const clonedData = new Uint8ClampedArray(imageData.data);
36479
+ return new ImageData(clonedData, imageData.width, imageData.height);
36480
+ }
36481
+ static lerp(start, end, t) {
36482
+ return start * (1 - t) + end * t;
36483
+ }
36484
+ static smoothstep(edge0, edge1, x) {
36485
+ const t = Math.max(0, Math.min(1, (x - edge0) / (edge1 - edge0)));
36486
+ return t * t * (3 - 2 * t);
36487
+ }
36488
+ static distance(x1, y1, x2, y2) {
36489
+ const dx = x2 - x1,
36490
+ dy = y2 - y1;
36491
+ return Math.sqrt(dx * dx + dy * dy);
36492
+ }
36493
+ static normalizeAngle(angle) {
36494
+ return (angle + Math.PI) / (2 * Math.PI);
36495
+ }
36496
+ static pixelNoise(x, y, pixelSize) {
36497
+ if (pixelSize <= 0) return 0;
36498
+ const gridX = Math.floor(x / pixelSize) * pixelSize,
36499
+ gridY = Math.floor(y / pixelSize) * pixelSize,
36500
+ n = 43758.5453 * Math.sin(12.9898 * gridX + 78.233 * gridY);
36501
+ return n - Math.floor(n);
36502
+ }
36503
+ static generateNoiseTexture(width, height) {
36504
+ const data = new Uint8Array(width * height);
36505
+ for (let i = 0; i < data.length; i++) data[i] = Math.floor(256 * Math.random());
36506
+ return data;
36507
+ }
36508
+ static applyCSSFilter(canvas, filter) {
36509
+ const outputCanvas = this.createTempCanvas(canvas.width, canvas.height),
36510
+ ctx = outputCanvas.getContext("2d");
36511
+ return ctx ? (ctx.filter = filter, ctx.drawImage(canvas, 0, 0), ctx.filter = "none", outputCanvas) : canvas;
36512
+ }
36513
+ static extractChannel(imageData, channelIndex) {
36514
+ const {
36515
+ data: data,
36516
+ width: width,
36517
+ height: height
36518
+ } = imageData,
36519
+ channelData = new Uint8ClampedArray(data.length);
36520
+ for (let i = 0; i < data.length; i += 4) channelData[i] = 0, channelData[i + 1] = 0, channelData[i + 2] = 0, channelData[i + 3] = data[i + 3], channelIndex >= 0 && channelIndex <= 2 && (channelData[i + channelIndex] = data[i + channelIndex]);
36521
+ return new ImageData(channelData, width, height);
36522
+ }
36523
+ static blendImageData(imageData1, imageData2, ratio) {
36524
+ const {
36525
+ data: data1,
36526
+ width: width,
36527
+ height: height
36528
+ } = imageData1,
36529
+ {
36530
+ data: data2
36531
+ } = imageData2,
36532
+ result = new Uint8ClampedArray(data1.length);
36533
+ for (let i = 0; i < data1.length; i += 4) result[i] = Math.round(this.lerp(data1[i], data2[i], ratio)), result[i + 1] = Math.round(this.lerp(data1[i + 1], data2[i + 1], ratio)), result[i + 2] = Math.round(this.lerp(data1[i + 2], data2[i + 2], ratio)), result[i + 3] = Math.round(this.lerp(data1[i + 3], data2[i + 3], ratio));
36534
+ return new ImageData(result, width, height);
36535
+ }
36536
+ static getLuminance(r, g, b) {
36537
+ return .299 * r + .587 * g + .114 * b;
36538
+ }
36539
+ static applySepiaToPixel(r, g, b) {
36540
+ return [Math.min(255, .393 * r + .769 * g + .189 * b), Math.min(255, .349 * r + .686 * g + .168 * b), Math.min(255, .272 * r + .534 * g + .131 * b)];
36541
+ }
36542
+ static calculateDynamicStrength(baseStrength, animationTime) {
36543
+ return baseStrength * (animationTime / (2 * Math.PI));
36544
+ }
36545
+ }
36546
+ class ShaderLibrary {}
36547
+ ShaderLibrary.STANDARD_VERTEX_SHADER = "\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n varying vec2 v_texCoord;\n\n void main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texCoord = a_texCoord;\n }\n ", ShaderLibrary.SHADER_FUNCTIONS = "\n // 亮度计算函数\n float luminance(vec3 color) {\n return dot(color, vec3(0.299, 0.587, 0.114));\n }\n\n // 褐色调函数\n vec3 sepia(vec3 color) {\n float r = color.r * 0.393 + color.g * 0.769 + color.b * 0.189;\n float g = color.r * 0.349 + color.g * 0.686 + color.b * 0.168;\n float b = color.r * 0.272 + color.g * 0.534 + color.b * 0.131;\n return vec3(r, g, b);\n }\n\n // 线性插值函数\n float lerp(float a, float b, float t) {\n return a * (1.0 - t) + b * t;\n }\n\n\n // 简单噪声函数\n float pixelNoise(vec2 coord, float pixelSize) {\n vec2 gridCoord = floor(coord / pixelSize) * pixelSize;\n return fract(sin(dot(gridCoord, vec2(12.9898, 78.233))) * 43758.5453123);\n }\n\n // 动态强度计算\n float calculateDynamicStrength(float baseStrength, float time) {\n return baseStrength * (time / 6.28318531); // 2π\n }\n ";
36548
+
36549
+ class Dissolve extends HybridEffectBase {
36550
+ constructor(from, to, duration, easing, params) {
36551
+ var _a, _b, _c, _d;
36552
+ super(from, to, duration, easing, params), this.noiseData = null;
36553
+ const rawNoiseScale = null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.noiseScale,
36554
+ clampedNoiseScale = void 0 !== rawNoiseScale ? Math.max(0, Math.floor(rawNoiseScale)) : 8;
36555
+ this.dissolveConfig = {
36556
+ dissolveType: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.dissolveType) || "outward",
36557
+ useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL,
36558
+ noiseScale: clampedNoiseScale,
36559
+ fadeEdge: void 0 === (null === (_d = null == params ? void 0 : params.options) || void 0 === _d ? void 0 : _d.fadeEdge) || params.options.fadeEdge
36560
+ };
36561
+ }
36562
+ getShaderSources() {
36563
+ return {
36564
+ vertex: ShaderLibrary.STANDARD_VERTEX_SHADER,
36565
+ fragment: `\n precision mediump float;\n uniform sampler2D u_texture;\n uniform sampler2D u_noiseTexture;\n uniform float u_time;\n uniform int u_dissolveType;\n uniform vec2 u_resolution;\n uniform float u_noiseScale;\n uniform bool u_fadeEdge;\n varying vec2 v_texCoord;\n\n ${ShaderLibrary.SHADER_FUNCTIONS}\n\n // 向外溶解函数\n float outwardDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n vec2 center = vec2(0.5, 0.5);\n float distFromCenter = length(uv - center);\n float maxDist = length(vec2(0.5, 0.5));\n\n // 归一化距离 (0为中心,1为边缘)\n float normalizedDist = distFromCenter / maxDist;\n\n // 向外溶解:从边缘开始溶解,time控制溶解进度\n // 增加安全边距,确保动画结束时完全溶解\n float edgeThreshold = 1.2 - time * 1.5;\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n // 添加基于像素大小的噪声,让边缘呈现颗粒状\n vec2 pixelCoord = uv * resolution; // 转换为像素坐标\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.4; // 增强噪声影响\n edgeThreshold += noiseInfluence;\n return normalizedDist > edgeThreshold ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.15; // 渐变宽度\n return 1.0 - smoothstep(edgeThreshold - fadeWidth, edgeThreshold, normalizedDist);\n } else {\n // 硬边缘:返回0或1\n return normalizedDist > edgeThreshold ? 0.0 : 1.0;\n }\n }\n }\n\n // 向内溶解函数\n float inwardDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n vec2 center = vec2(0.5, 0.5);\n float distFromCenter = length(uv - center);\n float maxDist = length(vec2(0.5, 0.5));\n\n float normalizedDist = distFromCenter / maxDist;\n\n // 向内溶解:从中心开始溶解,time控制溶解进度\n // 增加系数,确保动画结束时完全溶解\n float centerThreshold = time * 1.4;\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.4;\n centerThreshold += noiseInfluence;\n return normalizedDist < centerThreshold ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.15; // 渐变宽度\n return smoothstep(centerThreshold, centerThreshold + fadeWidth, normalizedDist);\n } else {\n // 硬边缘:返回0或1\n return normalizedDist < centerThreshold ? 0.0 : 1.0;\n }\n }\n }\n\n // 径向溶解函数\n float radialDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n vec2 center = vec2(0.5, 0.5);\n float angle = atan(uv.y - center.y, uv.x - center.x);\n float normalizedAngle = (angle + 3.14159) / (2.0 * 3.14159);\n\n // 径向溶解:按角度顺序溶解,time控制溶解进度\n // 增加系数,确保动画结束时完全溶解\n float angleThreshold = time * 1.2;\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.3;\n angleThreshold += noiseInfluence;\n return normalizedAngle < angleThreshold ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.08; // 渐变宽度\n return smoothstep(angleThreshold, angleThreshold + fadeWidth, normalizedAngle);\n } else {\n // 硬边缘:返回0或1\n return normalizedAngle < angleThreshold ? 0.0 : 1.0;\n }\n }\n }\n\n // 从左到右溶解函数\n float leftToRightDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n // 左到右溶解:从x=0开始向x=1溶解\n float dissolvePosition = time * 1.2; // 增加系数确保完全溶解\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.3;\n dissolvePosition += noiseInfluence;\n return uv.x < dissolvePosition ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.08; // 渐变宽度\n return smoothstep(dissolvePosition, dissolvePosition + fadeWidth, uv.x);\n } else {\n // 硬边缘:返回0或1\n return uv.x < dissolvePosition ? 0.0 : 1.0;\n }\n }\n }\n\n // 从右到左溶解函数\n float rightToLeftDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n // 右到左溶解:从x=1开始向x=0溶解\n float dissolvePosition = 1.0 - time * 1.2; // 增加系数确保完全溶解\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.3;\n dissolvePosition += noiseInfluence;\n return uv.x > dissolvePosition ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.08; // 渐变宽度\n return smoothstep(dissolvePosition - fadeWidth, dissolvePosition, uv.x);\n } else {\n // 硬边缘:返回0或1\n return uv.x > dissolvePosition ? 0.0 : 1.0;\n }\n }\n }\n\n // 从上到下溶解函数\n float topToBottomDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n // 上到下溶解:从y=0开始向y=1溶解\n float dissolvePosition = time * 1.2; // 增加系数确保完全溶解\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.3;\n dissolvePosition += noiseInfluence;\n return uv.y < dissolvePosition ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.08; // 渐变宽度\n return smoothstep(dissolvePosition, dissolvePosition + fadeWidth, uv.y);\n } else {\n // 硬边缘:返回0或1\n return uv.y < dissolvePosition ? 0.0 : 1.0;\n }\n }\n }\n\n // 从下到上溶解函数\n float bottomToTopDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n // 下到上溶解:从y=1开始向y=0溶解\n float dissolvePosition = 1.0 - time * 1.2; // 增加系数确保完全溶解\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.3;\n dissolvePosition += noiseInfluence;\n return uv.y > dissolvePosition ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.08; // 渐变宽度\n return smoothstep(dissolvePosition - fadeWidth, dissolvePosition, uv.y);\n } else {\n // 硬边缘:返回0或1\n return uv.y > dissolvePosition ? 0.0 : 1.0;\n }\n }\n }\n\n void main() {\n vec2 uv = v_texCoord;\n vec4 texColor = texture2D(u_texture, uv);\n\n float alpha = 1.0;\n\n // 根据溶解类型选择对应的溶解函数\n if (u_dissolveType == 0) {\n alpha = outwardDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 1) {\n alpha = inwardDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 2) {\n alpha = radialDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 3) {\n alpha = leftToRightDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 4) {\n alpha = rightToLeftDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 5) {\n alpha = topToBottomDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 6) {\n alpha = bottomToTopDissolve(uv, u_time, u_noiseScale, u_resolution);\n }\n\n gl_FragColor = vec4(texColor.rgb, texColor.a * alpha);\n }\n `
36566
+ };
36567
+ }
36568
+ applyWebGLEffect(canvas) {
36569
+ if (!this.gl || !this.program || !this.webglCanvas) return canvas;
36570
+ this.setupWebGLState(canvas);
36571
+ const texture = this.createTextureFromCanvas(canvas);
36572
+ if (!texture) return canvas;
36573
+ this.noiseData || (this.noiseData = ImageProcessUtils.generateNoiseTexture(256, 256));
36574
+ const noiseTexture = this.gl.createTexture();
36575
+ this.gl.activeTexture(this.gl.TEXTURE1), this.gl.bindTexture(this.gl.TEXTURE_2D, noiseTexture), this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.LUMINANCE, 256, 256, 0, this.gl.LUMINANCE, this.gl.UNSIGNED_BYTE, this.noiseData), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.REPEAT), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.REPEAT), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
36576
+ const vertexBuffer = this.createFullScreenQuad();
36577
+ return vertexBuffer ? (this.gl.useProgram(this.program), this.setupVertexAttributes(), this.setUniforms(), this.gl.enable(this.gl.BLEND), this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4), this.gl.deleteTexture(texture), this.gl.deleteTexture(noiseTexture), this.gl.deleteBuffer(vertexBuffer), this.webglCanvas) : canvas;
36578
+ }
36579
+ setUniforms() {
36580
+ if (!this.gl || !this.program || !this.webglCanvas) return;
36581
+ const textureLocation = this.gl.getUniformLocation(this.program, "u_texture"),
36582
+ noiseTextureLocation = this.gl.getUniformLocation(this.program, "u_noiseTexture"),
36583
+ timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
36584
+ dissolveTypeLocation = this.gl.getUniformLocation(this.program, "u_dissolveType"),
36585
+ resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution"),
36586
+ noiseScaleLocation = this.gl.getUniformLocation(this.program, "u_noiseScale"),
36587
+ fadeEdgeLocation = this.gl.getUniformLocation(this.program, "u_fadeEdge");
36588
+ this.gl.uniform1i(textureLocation, 0), this.gl.uniform1i(noiseTextureLocation, 1), this.gl.uniform1f(timeLocation, this.currentAnimationRatio), this.gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height), this.gl.uniform1f(noiseScaleLocation, this.dissolveConfig.noiseScale), this.gl.uniform1i(fadeEdgeLocation, this.dissolveConfig.fadeEdge ? 1 : 0);
36589
+ this.gl.uniform1i(dissolveTypeLocation, {
36590
+ outward: 0,
36591
+ inward: 1,
36592
+ radial: 2,
36593
+ leftToRight: 3,
36594
+ rightToLeft: 4,
36595
+ topToBottom: 5,
36596
+ bottomToTop: 6
36597
+ }[this.dissolveConfig.dissolveType] || 0);
36598
+ }
36599
+ applyCanvas2DEffect(canvas) {
36600
+ const outputCanvas = this.createOutputCanvas(canvas);
36601
+ if (!outputCanvas) return canvas;
36602
+ const {
36603
+ canvas: outputCanvasElement,
36604
+ ctx: ctx
36605
+ } = outputCanvas,
36606
+ imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
36607
+ progress = this.currentAnimationRatio;
36608
+ let dissolvedImageData;
36609
+ switch (this.dissolveConfig.dissolveType) {
36610
+ case "outward":
36611
+ dissolvedImageData = this.applyOutwardDissolve(imageData, progress);
36612
+ break;
36613
+ case "inward":
36614
+ dissolvedImageData = this.applyInwardDissolve(imageData, progress);
36615
+ break;
36616
+ case "radial":
36617
+ dissolvedImageData = this.applyRadialDissolve(imageData, progress);
36618
+ break;
36619
+ case "leftToRight":
36620
+ dissolvedImageData = this.applyLeftToRightDissolve(imageData, progress);
36621
+ break;
36622
+ case "rightToLeft":
36623
+ dissolvedImageData = this.applyRightToLeftDissolve(imageData, progress);
36624
+ break;
36625
+ case "topToBottom":
36626
+ dissolvedImageData = this.applyTopToBottomDissolve(imageData, progress);
36627
+ break;
36628
+ case "bottomToTop":
36629
+ dissolvedImageData = this.applyBottomToTopDissolve(imageData, progress);
36630
+ break;
36631
+ default:
36632
+ dissolvedImageData = imageData;
36633
+ }
36634
+ return ctx.putImageData(dissolvedImageData, 0, 0), outputCanvasElement;
36635
+ }
36636
+ applyOutwardDissolve(imageData, progress) {
36637
+ const {
36638
+ data: data,
36639
+ width: width,
36640
+ height: height
36641
+ } = imageData,
36642
+ result = new Uint8ClampedArray(data.length);
36643
+ result.set(data);
36644
+ const centerX = width / 2,
36645
+ centerY = height / 2,
36646
+ maxDist = Math.sqrt(centerX * centerX + centerY * centerY),
36647
+ pixelSize = this.dissolveConfig.noiseScale;
36648
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36649
+ const dx = x - centerX,
36650
+ dy = y - centerY,
36651
+ normalizedDist = Math.sqrt(dx * dx + dy * dy) / maxDist;
36652
+ let dissolveThreshold = 1.2 - 1.4 * progress,
36653
+ alpha = 1;
36654
+ if (pixelSize > 0) {
36655
+ dissolveThreshold += .4 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedDist > dissolveThreshold ? 0 : 1;
36656
+ } else if (this.dissolveConfig.fadeEdge) {
36657
+ const fadeStart = dissolveThreshold - .15;
36658
+ alpha = normalizedDist < fadeStart ? 1 : normalizedDist > dissolveThreshold ? 0 : 1 - (normalizedDist - fadeStart) / (dissolveThreshold - fadeStart);
36659
+ } else alpha = normalizedDist > dissolveThreshold ? 0 : 1;
36660
+ const index = 4 * (y * width + x);
36661
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36662
+ }
36663
+ return new ImageData(result, width, height);
36664
+ }
36665
+ applyInwardDissolve(imageData, progress) {
36666
+ const {
36667
+ data: data,
36668
+ width: width,
36669
+ height: height
36670
+ } = imageData,
36671
+ result = new Uint8ClampedArray(data.length);
36672
+ result.set(data);
36673
+ const centerX = width / 2,
36674
+ centerY = height / 2,
36675
+ maxDist = Math.sqrt(centerX * centerX + centerY * centerY),
36676
+ pixelSize = this.dissolveConfig.noiseScale;
36677
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36678
+ const dx = x - centerX,
36679
+ dy = y - centerY,
36680
+ normalizedDist = Math.sqrt(dx * dx + dy * dy) / maxDist;
36681
+ let dissolveThreshold = 1.4 * progress,
36682
+ alpha = 1;
36683
+ if (pixelSize > 0) {
36684
+ dissolveThreshold += .4 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedDist < dissolveThreshold ? 0 : 1;
36685
+ } else if (this.dissolveConfig.fadeEdge) {
36686
+ const fadeEnd = dissolveThreshold + .15;
36687
+ alpha = normalizedDist < dissolveThreshold ? 0 : normalizedDist > fadeEnd ? 1 : (normalizedDist - dissolveThreshold) / (fadeEnd - dissolveThreshold);
36688
+ } else alpha = normalizedDist < dissolveThreshold ? 0 : 1;
36689
+ const index = 4 * (y * width + x);
36690
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36691
+ }
36692
+ return new ImageData(result, width, height);
36693
+ }
36694
+ applyRadialDissolve(imageData, progress) {
36695
+ const {
36696
+ data: data,
36697
+ width: width,
36698
+ height: height
36699
+ } = imageData,
36700
+ result = new Uint8ClampedArray(data.length);
36701
+ result.set(data);
36702
+ const centerX = width / 2,
36703
+ centerY = height / 2,
36704
+ pixelSize = this.dissolveConfig.noiseScale;
36705
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36706
+ const dx = x - centerX,
36707
+ dy = y - centerY,
36708
+ normalizedAngle = (Math.atan2(dy, dx) + Math.PI) / (2 * Math.PI);
36709
+ let dissolveThreshold = 1.2 * progress,
36710
+ alpha = 1;
36711
+ if (pixelSize > 0) {
36712
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedAngle < dissolveThreshold ? 0 : 1;
36713
+ } else if (this.dissolveConfig.fadeEdge) {
36714
+ const fadeEnd = dissolveThreshold + .08;
36715
+ alpha = normalizedAngle < dissolveThreshold ? 0 : normalizedAngle > fadeEnd ? 1 : (normalizedAngle - dissolveThreshold) / (fadeEnd - dissolveThreshold);
36716
+ } else alpha = normalizedAngle < dissolveThreshold ? 0 : 1;
36717
+ const index = 4 * (y * width + x);
36718
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36719
+ }
36720
+ return new ImageData(result, width, height);
36721
+ }
36722
+ applyLeftToRightDissolve(imageData, progress) {
36723
+ const {
36724
+ data: data,
36725
+ width: width,
36726
+ height: height
36727
+ } = imageData,
36728
+ result = new Uint8ClampedArray(data.length);
36729
+ result.set(data);
36730
+ const pixelSize = this.dissolveConfig.noiseScale;
36731
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36732
+ const normalizedX = x / width;
36733
+ let dissolveThreshold = 1.2 * progress,
36734
+ alpha = 1;
36735
+ if (pixelSize > 0) {
36736
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedX < dissolveThreshold ? 0 : 1;
36737
+ } else if (this.dissolveConfig.fadeEdge) {
36738
+ const fadeEnd = dissolveThreshold + .08;
36739
+ alpha = normalizedX < dissolveThreshold ? 0 : normalizedX > fadeEnd ? 1 : (normalizedX - dissolveThreshold) / (fadeEnd - dissolveThreshold);
36740
+ } else alpha = normalizedX < dissolveThreshold ? 0 : 1;
36741
+ const index = 4 * (y * width + x);
36742
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36743
+ }
36744
+ return new ImageData(result, width, height);
36745
+ }
36746
+ applyRightToLeftDissolve(imageData, progress) {
36747
+ const {
36748
+ data: data,
36749
+ width: width,
36750
+ height: height
36751
+ } = imageData,
36752
+ result = new Uint8ClampedArray(data.length);
36753
+ result.set(data);
36754
+ const pixelSize = this.dissolveConfig.noiseScale;
36755
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36756
+ const normalizedX = x / width;
36757
+ let dissolveThreshold = 1 - 1.2 * progress,
36758
+ alpha = 1;
36759
+ if (pixelSize > 0) {
36760
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedX > dissolveThreshold ? 0 : 1;
36761
+ } else if (this.dissolveConfig.fadeEdge) {
36762
+ const fadeStart = dissolveThreshold - .08;
36763
+ alpha = normalizedX < fadeStart ? 1 : normalizedX > dissolveThreshold ? 0 : 1 - (normalizedX - fadeStart) / (dissolveThreshold - fadeStart);
36764
+ } else alpha = normalizedX > dissolveThreshold ? 0 : 1;
36765
+ const index = 4 * (y * width + x);
36766
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36767
+ }
36768
+ return new ImageData(result, width, height);
36769
+ }
36770
+ applyTopToBottomDissolve(imageData, progress) {
36771
+ const {
36772
+ data: data,
36773
+ width: width,
36774
+ height: height
36775
+ } = imageData,
36776
+ result = new Uint8ClampedArray(data.length);
36777
+ result.set(data);
36778
+ const pixelSize = this.dissolveConfig.noiseScale;
36779
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36780
+ const normalizedY = y / height;
36781
+ let dissolveThreshold = 1.2 * progress,
36782
+ alpha = 1;
36783
+ if (pixelSize > 0) {
36784
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedY < dissolveThreshold ? 0 : 1;
36785
+ } else if (this.dissolveConfig.fadeEdge) {
36786
+ const fadeEnd = dissolveThreshold + .08;
36787
+ alpha = normalizedY < dissolveThreshold ? 0 : normalizedY > fadeEnd ? 1 : (normalizedY - dissolveThreshold) / (fadeEnd - dissolveThreshold);
36788
+ } else alpha = normalizedY < dissolveThreshold ? 0 : 1;
36789
+ const index = 4 * (y * width + x);
36790
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36791
+ }
36792
+ return new ImageData(result, width, height);
36793
+ }
36794
+ applyBottomToTopDissolve(imageData, progress) {
36795
+ const {
36796
+ data: data,
36797
+ width: width,
36798
+ height: height
36799
+ } = imageData,
36800
+ result = new Uint8ClampedArray(data.length);
36801
+ result.set(data);
36802
+ const pixelSize = this.dissolveConfig.noiseScale;
36803
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36804
+ const normalizedY = y / height;
36805
+ let dissolveThreshold = 1 - 1.2 * progress,
36806
+ alpha = 1;
36807
+ if (pixelSize > 0) {
36808
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedY > dissolveThreshold ? 0 : 1;
36809
+ } else if (this.dissolveConfig.fadeEdge) {
36810
+ const fadeStart = dissolveThreshold - .08;
36811
+ alpha = normalizedY < fadeStart ? 1 : normalizedY > dissolveThreshold ? 0 : 1 - (normalizedY - fadeStart) / (dissolveThreshold - fadeStart);
36812
+ } else alpha = normalizedY > dissolveThreshold ? 0 : 1;
36813
+ const index = 4 * (y * width + x);
36814
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36815
+ }
36816
+ return new ImageData(result, width, height);
36817
+ }
36818
+ }
36819
+
36820
+ class Grayscale extends HybridEffectBase {
36821
+ constructor(from, to, duration, easing, params) {
36822
+ var _a, _b, _c;
36823
+ super(from, to, duration, easing, params);
36824
+ const rawStrength = void 0 !== (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.strength) ? params.options.strength : 1,
36825
+ clampedStrength = Math.max(0, Math.min(1, rawStrength));
36826
+ this.colorConfig = {
36827
+ effectType: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.effectType) || "grayscale",
36828
+ strength: clampedStrength,
36829
+ useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL
36830
+ };
36831
+ }
36832
+ getShaderSources() {
36833
+ return {
36834
+ vertex: ShaderLibrary.STANDARD_VERTEX_SHADER,
36835
+ fragment: `\n precision mediump float;\n uniform sampler2D u_texture;\n uniform float u_time;\n uniform float u_strength;\n uniform int u_effectType;\n uniform vec2 u_resolution;\n varying vec2 v_texCoord;\n\n ${ShaderLibrary.SHADER_FUNCTIONS}\n\n void main() {\n vec2 uv = v_texCoord;\n vec4 originalColor = texture2D(u_texture, uv);\n vec3 color = originalColor.rgb;\n\n // 计算动态强度\n float dynamicStrength = calculateDynamicStrength(u_strength, u_time);\n\n if (u_effectType == 0) {\n // 灰度效果\n float gray = luminance(color);\n vec3 grayColor = vec3(gray);\n color = mix(color, grayColor, dynamicStrength);\n } else if (u_effectType == 1) {\n // 褐色调效果\n vec3 sepiaColor = sepia(color);\n color = mix(color, sepiaColor, dynamicStrength);\n }\n\n gl_FragColor = vec4(color, originalColor.a);\n }\n `
36836
+ };
36837
+ }
36838
+ applyWebGLEffect(canvas) {
36839
+ if (!this.gl || !this.program || !this.webglCanvas) return null;
36840
+ this.setupWebGLState(canvas);
36841
+ const texture = this.createTextureFromCanvas(canvas);
36842
+ if (!texture) return null;
36843
+ const vertexBuffer = this.createFullScreenQuad();
36844
+ if (!vertexBuffer) return this.gl.deleteTexture(texture), null;
36845
+ try {
36846
+ return this.gl.useProgram(this.program), this.setupVertexAttributes(), this.setColorUniforms(), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4), this.webglCanvas;
36847
+ } finally {
36848
+ this.gl.deleteTexture(texture), this.gl.deleteBuffer(vertexBuffer);
36849
+ }
36850
+ }
36851
+ setColorUniforms() {
36852
+ if (!this.gl || !this.program) return;
36853
+ const currentTime = this.getAnimationTime(),
36854
+ timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
36855
+ strengthLocation = this.gl.getUniformLocation(this.program, "u_strength"),
36856
+ effectTypeLocation = this.gl.getUniformLocation(this.program, "u_effectType"),
36857
+ resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution");
36858
+ this.gl.uniform1f(timeLocation, currentTime), this.gl.uniform1f(strengthLocation, this.colorConfig.strength), this.gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height);
36859
+ this.gl.uniform1i(effectTypeLocation, {
36860
+ grayscale: 0,
36861
+ sepia: 1
36862
+ }[this.colorConfig.effectType] || 0);
36863
+ }
36864
+ applyCanvas2DEffect(canvas) {
36865
+ if (this.colorConfig.strength <= 0) {
36866
+ const outputCanvas = this.createOutputCanvas(canvas);
36867
+ return outputCanvas ? outputCanvas.canvas : null;
36868
+ }
36869
+ if (this.canUseCSSFilter()) return this.applyCSSFilter(canvas);
36870
+ const outputCanvas = this.createOutputCanvas(canvas);
36871
+ if (!outputCanvas) return null;
36872
+ const {
36873
+ ctx: ctx
36874
+ } = outputCanvas;
36875
+ try {
36876
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
36877
+ currentTime = this.getAnimationTime();
36878
+ let processedImageData;
36879
+ switch (this.colorConfig.effectType) {
36880
+ case "grayscale":
36881
+ default:
36882
+ processedImageData = this.applyGrayscaleEffect(imageData, this.colorConfig.strength, currentTime);
36883
+ break;
36884
+ case "sepia":
36885
+ processedImageData = this.applySepiaEffect(imageData, this.colorConfig.strength, currentTime);
36886
+ }
36887
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(processedImageData, 0, 0), outputCanvas.canvas;
36888
+ } catch (error) {
36889
+ return console.warn("Canvas 2D color effect failed:", error), null;
36890
+ }
36891
+ }
36892
+ canUseCSSFilter() {
36893
+ var _a;
36894
+ return !!window.useFilterAPI && "undefined" != typeof CSS && (null === (_a = CSS.supports) || void 0 === _a ? void 0 : _a.call(CSS, "filter", "grayscale(1)"));
36895
+ }
36896
+ applyCSSFilter(canvas) {
36897
+ try {
36898
+ const outputCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height),
36899
+ ctx = outputCanvas.getContext("2d");
36900
+ if (!ctx) return null;
36901
+ const currentTime = this.getAnimationTime(),
36902
+ dynamicStrength = ImageProcessUtils.calculateDynamicStrength(this.colorConfig.strength, currentTime);
36903
+ let filterValue = "";
36904
+ return "grayscale" === this.colorConfig.effectType ? filterValue = `grayscale(${Math.min(1, dynamicStrength)})` : "sepia" === this.colorConfig.effectType && (filterValue = `sepia(${Math.min(1, dynamicStrength)})`), ctx.filter = filterValue, ctx.drawImage(canvas, 0, 0), ctx.filter = "none", outputCanvas;
36905
+ } catch (error) {
36906
+ return console.warn("CSS Filter API failed, falling back to pixel processing:", error), null;
36907
+ }
36908
+ }
36909
+ applyGrayscaleEffect(imageData, strength, time) {
36910
+ const {
36911
+ data: data,
36912
+ width: width,
36913
+ height: height
36914
+ } = imageData,
36915
+ result = new Uint8ClampedArray(data.length),
36916
+ dynamicStrength = ImageProcessUtils.calculateDynamicStrength(strength, time);
36917
+ for (let i = 0; i < data.length; i += 4) {
36918
+ const r = data[i],
36919
+ g = data[i + 1],
36920
+ b = data[i + 2],
36921
+ a = data[i + 3],
36922
+ gray = ImageProcessUtils.getLuminance(r, g, b);
36923
+ result[i] = Math.round(ImageProcessUtils.lerp(r, gray, dynamicStrength)), result[i + 1] = Math.round(ImageProcessUtils.lerp(g, gray, dynamicStrength)), result[i + 2] = Math.round(ImageProcessUtils.lerp(b, gray, dynamicStrength)), result[i + 3] = a;
36924
+ }
36925
+ return new ImageData(result, width, height);
36926
+ }
36927
+ applySepiaEffect(imageData, strength, time) {
36928
+ const {
36929
+ data: data,
36930
+ width: width,
36931
+ height: height
36932
+ } = imageData,
36933
+ result = new Uint8ClampedArray(data.length),
36934
+ dynamicStrength = ImageProcessUtils.calculateDynamicStrength(strength, time);
36935
+ for (let i = 0; i < data.length; i += 4) {
36936
+ const r = data[i],
36937
+ g = data[i + 1],
36938
+ b = data[i + 2],
36939
+ a = data[i + 3],
36940
+ [sepiaR, sepiaG, sepiaB] = ImageProcessUtils.applySepiaToPixel(r, g, b);
36941
+ result[i] = Math.round(ImageProcessUtils.lerp(r, sepiaR, dynamicStrength)), result[i + 1] = Math.round(ImageProcessUtils.lerp(g, sepiaG, dynamicStrength)), result[i + 2] = Math.round(ImageProcessUtils.lerp(b, sepiaB, dynamicStrength)), result[i + 3] = a;
36942
+ }
36943
+ return new ImageData(result, width, height);
36944
+ }
36945
+ afterStageRender(stage, canvas) {
36946
+ if (this.canUseCSSFilter() && this.colorConfig.strength > 0) {
36947
+ const cssResult = this.applyCSSFilter(canvas);
36948
+ if (cssResult) return cssResult;
36949
+ }
36950
+ return super.afterStageRender(stage, canvas);
36951
+ }
36952
+ }
36953
+
36954
+ class Distortion extends HybridEffectBase {
36955
+ constructor(from, to, duration, easing, params) {
36956
+ var _a, _b, _c;
36957
+ super(from, to, duration, easing, params), this.distortionConfig = {
36958
+ distortionType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.distortionType) || "wave",
36959
+ strength: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.strength) || .3,
36960
+ useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL
36961
+ };
36962
+ }
36963
+ getShaderSources() {
36964
+ return {
36965
+ vertex: "\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n varying vec2 v_texCoord;\n\n void main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texCoord = a_texCoord;\n }\n ",
36966
+ fragment: "\n precision mediump float;\n uniform sampler2D u_texture;\n uniform float u_time;\n uniform float u_strength;\n uniform int u_distortionType;\n uniform vec2 u_resolution;\n varying vec2 v_texCoord;\n\n // 波浪扭曲函数\n vec2 wave(vec2 uv, float time, float strength) {\n float waveX = sin(uv.y * 10.0 + time * 3.0) * strength * 0.1;\n float waveY = sin(uv.x * 10.0 + time * 2.0) * strength * 0.1;\n return uv + vec2(waveX, waveY);\n }\n\n // 涟漪扭曲函数\n vec2 ripple(vec2 uv, float time, float strength) {\n vec2 center = vec2(0.5, 0.5);\n float distance = length(uv - center);\n float ripple = sin(distance * 20.0 - time * 5.0) * strength * 0.1;\n vec2 direction = normalize(uv - center);\n return uv + direction * ripple;\n }\n\n // 漩涡扭曲函数\n vec2 swirl(vec2 uv, float time, float strength) {\n vec2 center = vec2(0.5, 0.5);\n vec2 delta = uv - center;\n float dist = length(delta);\n float originalAngle = atan(delta.y, delta.x);\n float rotationAngle = dist * strength * time * 2.0;\n float finalAngle = originalAngle + rotationAngle;\n return center + dist * vec2(cos(finalAngle), sin(finalAngle));\n }\n\n void main() {\n vec2 uv = v_texCoord;\n\n // 根据扭曲类型应用相应变换\n if (u_distortionType == 0) {\n uv = wave(uv, u_time, u_strength);\n } else if (u_distortionType == 1) {\n uv = ripple(uv, u_time, u_strength);\n } else if (u_distortionType == 2) {\n uv = swirl(uv, u_time, u_strength);\n }\n\n // 边界检查\n if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n } else {\n gl_FragColor = texture2D(u_texture, uv);\n }\n }\n "
36967
+ };
36968
+ }
36969
+ applyWebGLEffect(canvas) {
36970
+ if (!this.gl || !this.program || !this.webglCanvas) return null;
36971
+ this.setupWebGLState(canvas);
36972
+ const texture = this.createTextureFromCanvas(canvas);
36973
+ if (!texture) return null;
36974
+ const vertexBuffer = this.createFullScreenQuad();
36975
+ if (!vertexBuffer) return this.gl.deleteTexture(texture), null;
36976
+ try {
36977
+ return this.gl.useProgram(this.program), this.setupVertexAttributes(), this.setDistortionUniforms(), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4), this.webglCanvas;
36978
+ } finally {
36979
+ this.gl.deleteTexture(texture), this.gl.deleteBuffer(vertexBuffer);
36980
+ }
36981
+ }
36982
+ setDistortionUniforms() {
36983
+ if (!this.gl || !this.program) return;
36984
+ const currentTime = this.getAnimationTime(),
36985
+ timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
36986
+ strengthLocation = this.gl.getUniformLocation(this.program, "u_strength"),
36987
+ distortionTypeLocation = this.gl.getUniformLocation(this.program, "u_distortionType"),
36988
+ resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution");
36989
+ this.gl.uniform1f(timeLocation, currentTime), this.gl.uniform1f(strengthLocation, this.distortionConfig.strength), this.gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height);
36990
+ this.gl.uniform1i(distortionTypeLocation, {
36991
+ wave: 0,
36992
+ ripple: 1,
36993
+ swirl: 2
36994
+ }[this.distortionConfig.distortionType] || 0);
36995
+ }
36996
+ applyCanvas2DEffect(canvas) {
36997
+ const outputCanvas = this.createOutputCanvas(canvas);
36998
+ if (!outputCanvas) return null;
36999
+ const {
37000
+ ctx: ctx
37001
+ } = outputCanvas;
37002
+ try {
37003
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
37004
+ currentTime = this.getAnimationTime();
37005
+ let distortedImageData;
37006
+ switch (this.distortionConfig.distortionType) {
37007
+ case "wave":
37008
+ distortedImageData = this.applyWaveDistortion(imageData, this.distortionConfig.strength, currentTime);
37009
+ break;
37010
+ case "ripple":
37011
+ distortedImageData = this.applyRippleDistortion(imageData, this.distortionConfig.strength, currentTime);
37012
+ break;
37013
+ case "swirl":
37014
+ distortedImageData = this.applySwirlDistortion(imageData, this.distortionConfig.strength, currentTime);
37015
+ break;
37016
+ default:
37017
+ distortedImageData = imageData;
37018
+ }
37019
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(distortedImageData, 0, 0), outputCanvas.canvas;
37020
+ } catch (error) {
37021
+ return console.warn("Canvas 2D distortion effect failed:", error), null;
37022
+ }
37023
+ }
37024
+ applyWaveDistortion(imageData, strength, time) {
37025
+ const {
37026
+ data: data,
37027
+ width: width,
37028
+ height: height
37029
+ } = imageData,
37030
+ result = new Uint8ClampedArray(data.length);
37031
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
37032
+ const waveX = Math.sin(.1 * y + 3 * time) * strength * 20,
37033
+ waveY = Math.sin(.1 * x + 2 * time) * strength * 20,
37034
+ sourceX = Math.round(x - waveX),
37035
+ sourceY = Math.round(y - waveY),
37036
+ targetIndex = 4 * (y * width + x);
37037
+ if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
37038
+ const sourceIndex = 4 * (sourceY * width + sourceX);
37039
+ result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
37040
+ } else result[targetIndex + 3] = 0;
37041
+ }
37042
+ return new ImageData(result, width, height);
37043
+ }
37044
+ applyRippleDistortion(imageData, strength, time) {
37045
+ const {
37046
+ data: data,
37047
+ width: width,
37048
+ height: height
37049
+ } = imageData,
37050
+ result = new Uint8ClampedArray(data.length),
37051
+ centerX = width / 2,
37052
+ centerY = height / 2;
37053
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
37054
+ const dx = x - centerX,
37055
+ dy = y - centerY,
37056
+ distance = Math.sqrt(dx * dx + dy * dy),
37057
+ ripple = Math.sin(.2 * distance - 5 * time) * strength * 10,
37058
+ angle = Math.atan2(dy, dx),
37059
+ sourceX = Math.round(x - Math.cos(angle) * ripple),
37060
+ sourceY = Math.round(y - Math.sin(angle) * ripple),
37061
+ targetIndex = 4 * (y * width + x);
37062
+ if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
37063
+ const sourceIndex = 4 * (sourceY * width + sourceX);
37064
+ result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
37065
+ } else result[targetIndex + 3] = 0;
37066
+ }
37067
+ return new ImageData(result, width, height);
37068
+ }
37069
+ applySwirlDistortion(imageData, strength, time) {
37070
+ const {
37071
+ data: data,
37072
+ width: width,
37073
+ height: height
37074
+ } = imageData,
37075
+ result = new Uint8ClampedArray(data.length),
37076
+ centerX = width / 2,
37077
+ centerY = height / 2;
37078
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
37079
+ const dx = x - centerX,
37080
+ dy = y - centerY,
37081
+ distance = Math.sqrt(dx * dx + dy * dy),
37082
+ finalAngle = Math.atan2(dy, dx) + distance * strength * time * .02,
37083
+ sourceX = Math.round(centerX + distance * Math.cos(finalAngle)),
37084
+ sourceY = Math.round(centerY + distance * Math.sin(finalAngle)),
37085
+ targetIndex = 4 * (y * width + x);
37086
+ if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
37087
+ const sourceIndex = 4 * (sourceY * width + sourceX);
37088
+ result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
37089
+ } else result[targetIndex + 3] = 0;
37090
+ }
37091
+ return new ImageData(result, width, height);
37092
+ }
37093
+ afterStageRender(stage, canvas) {
37094
+ return this.distortionConfig.strength <= 0 ? canvas : super.afterStageRender(stage, canvas);
37095
+ }
37096
+ }
37097
+
37098
+ class Particle extends HybridEffectBase {
37099
+ constructor(from, to, duration, easing, params) {
37100
+ var _a, _b, _c, _d, _e;
37101
+ super(from, to, duration, easing, params), this.particles = [], this.positionBuffer = null, this.colorBuffer = null, this.particleConfig = {
37102
+ effectType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.effectType) || "gravity",
37103
+ count: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.count) || 4e3,
37104
+ size: (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.size) || 20,
37105
+ strength: (null === (_d = null == params ? void 0 : params.options) || void 0 === _d ? void 0 : _d.strength) || 1.5,
37106
+ useWebGL: void 0 === (null === (_e = null == params ? void 0 : params.options) || void 0 === _e ? void 0 : _e.useWebGL) || params.options.useWebGL
37107
+ };
37108
+ }
37109
+ getShaderSources() {
37110
+ return {
37111
+ vertex: "\n attribute vec2 a_position;\n attribute vec4 a_color;\n attribute float a_size;\n\n uniform vec2 u_resolution;\n uniform float u_time;\n uniform float u_forceStrength;\n uniform int u_effectType;\n\n varying vec4 v_color;\n\n void main() {\n // 将像素坐标转换为剪辑空间坐标\n vec2 clipSpace = ((a_position / u_resolution) * 2.0) - 1.0;\n clipSpace.y = -clipSpace.y; // 翻转Y轴\n\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n gl_PointSize = a_size;\n v_color = a_color;\n }\n ",
37112
+ fragment: "\n precision mediump float;\n varying vec4 v_color;\n\n void main() {\n // 创建圆形粒子\n vec2 coord = gl_PointCoord - vec2(0.5);\n float distance = length(coord);\n\n if (distance > 0.5) {\n discard;\n }\n\n // 保持原始颜色,只调整透明度渐变\n gl_FragColor = vec4(v_color.rgb, v_color.a);\n }\n "
37113
+ };
37114
+ }
37115
+ applyWebGLEffect(canvas) {
37116
+ if (!this.gl || !this.program || !this.webglCanvas) return null;
37117
+ this.setupWebGLState(canvas), 0 === this.particles.length && this.extractParticles(canvas), this.updateParticles(canvas);
37118
+ const gl = this.gl;
37119
+ return gl.enable(gl.BLEND), gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA), gl.useProgram(this.program), this.prepareAndDrawParticles(gl), this.webglCanvas;
37120
+ }
37121
+ applyCanvas2DEffect(canvas) {
37122
+ const output = this.createOutputCanvas(canvas);
37123
+ if (!output) return null;
37124
+ const {
37125
+ canvas: outputCanvas,
37126
+ ctx: ctx
37127
+ } = output,
37128
+ progress = this.currentAnimationRatio;
37129
+ switch (this.particleConfig.effectType) {
37130
+ case "explode":
37131
+ this.applyCanvas2DExplode(ctx, canvas, progress);
37132
+ break;
37133
+ case "gravity":
37134
+ this.applyCanvas2DGravity(ctx, canvas, progress);
37135
+ break;
37136
+ case "vortex":
37137
+ this.applyCanvas2DVortex(ctx, canvas, progress);
37138
+ break;
37139
+ default:
37140
+ ctx.globalAlpha = Math.max(0, 1 - progress), ctx.drawImage(canvas, 0, 0);
37141
+ }
37142
+ return outputCanvas;
37143
+ }
37144
+ extractParticles(canvas) {
37145
+ const tempCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height, 1),
37146
+ tempCtx = tempCanvas.getContext("2d");
37147
+ if (!tempCtx) return;
37148
+ tempCtx.drawImage(canvas, 0, 0, tempCanvas.width, tempCanvas.height);
37149
+ const data = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height).data;
37150
+ this.particles = [];
37151
+ const step = Math.max(1, Math.floor(Math.sqrt(tempCanvas.width * tempCanvas.height / (1.5 * this.particleConfig.count))));
37152
+ for (let y = 0; y < tempCanvas.height; y += step) for (let x = 0; x < tempCanvas.width; x += step) {
37153
+ const index = 4 * (y * tempCanvas.width + x),
37154
+ r = data[index],
37155
+ g = data[index + 1],
37156
+ b = data[index + 2],
37157
+ a = data[index + 3];
37158
+ if (a > 5) {
37159
+ const realX = x / tempCanvas.width * canvas.width,
37160
+ realY = y / tempCanvas.height * canvas.height,
37161
+ particle = {
37162
+ x: realX,
37163
+ y: realY,
37164
+ originX: realX,
37165
+ originY: realY,
37166
+ vx: 0,
37167
+ vy: 0,
37168
+ r: r / 255,
37169
+ g: g / 255,
37170
+ b: b / 255,
37171
+ a: Math.max(.6, a / 255),
37172
+ life: 1,
37173
+ size: this.particleConfig.size * (1 + .5 * Math.random())
37174
+ };
37175
+ this.particles.push(particle);
37176
+ }
37177
+ }
37178
+ }
37179
+ updateParticles(canvas) {
37180
+ const centerX = canvas.width / 2,
37181
+ centerY = canvas.height / 2,
37182
+ progress = this.currentAnimationRatio,
37183
+ duration = this.getDurationFromParent(),
37184
+ isShortAnimation = duration < 2e3,
37185
+ timeMultiplier = isShortAnimation ? Math.max(1.5, 3e3 / duration) : 1,
37186
+ intensityBoost = isShortAnimation ? Math.min(2, 2e3 / duration) : 1;
37187
+ this.particles.forEach(particle => {
37188
+ const dx = particle.x - centerX,
37189
+ dy = particle.y - centerY,
37190
+ distance = Math.sqrt(dx * dx + dy * dy),
37191
+ angle = Math.atan2(dy, dx);
37192
+ this.applyParticleForces(particle, angle, distance, progress, intensityBoost, canvas), this.updateParticleProperties(particle, progress, isShortAnimation, timeMultiplier, intensityBoost);
37193
+ });
37194
+ }
37195
+ applyParticleForces(particle, angle, distance, progress, intensityBoost, canvas) {
37196
+ const time = this.getAnimationTime();
37197
+ switch (this.particleConfig.effectType) {
37198
+ case "explode":
37199
+ const explodeIntensity = progress * this.particleConfig.strength * intensityBoost * 5;
37200
+ particle.vx += Math.cos(angle) * explodeIntensity, particle.vy += Math.sin(angle) * explodeIntensity;
37201
+ break;
37202
+ case "gravity":
37203
+ this.applyGravityEffect(particle, progress, intensityBoost, canvas, time);
37204
+ break;
37205
+ case "vortex":
37206
+ this.applyVortexEffect(particle, progress, intensityBoost, canvas, angle, distance);
37207
+ }
37208
+ }
37209
+ applyGravityEffect(particle, progress, intensityBoost, canvas, time) {
37210
+ const gravityThreshold = (particle.originX + .7 * particle.originY) / (canvas.width + canvas.height) * .8;
37211
+ if (progress > gravityThreshold) {
37212
+ const gravityProgress = (progress - gravityThreshold) / (1 - gravityThreshold),
37213
+ gravityForce = this.particleConfig.strength * gravityProgress * gravityProgress * 12 * intensityBoost;
37214
+ particle.vy += gravityForce;
37215
+ const turbulence = Math.sin(3 * time + .02 * particle.originX) * Math.cos(2 * time + .015 * particle.originY);
37216
+ particle.vx += turbulence * this.particleConfig.strength * 2 * intensityBoost;
37217
+ }
37218
+ }
37219
+ applyVortexEffect(particle, progress, intensityBoost, canvas, angle, distance) {
37220
+ const centerX = canvas.width / 2,
37221
+ centerY = canvas.height / 2,
37222
+ spiralAngle = angle + progress * Math.PI * .8,
37223
+ targetRadius = distance + progress * Math.max(canvas.width, canvas.height) * .7 * 1.8,
37224
+ targetX = centerX + Math.cos(spiralAngle) * targetRadius,
37225
+ targetY = centerY + Math.sin(spiralAngle) * targetRadius,
37226
+ baseForce = progress * this.particleConfig.strength * .08 * intensityBoost;
37227
+ particle.vx += (targetX - particle.x) * baseForce, particle.vy += (targetY - particle.y) * baseForce;
37228
+ }
37229
+ updateParticleProperties(particle, progress, isShortAnimation, timeMultiplier, intensityBoost) {
37230
+ const dragCoeff = isShortAnimation ? .99 : .98;
37231
+ if (particle.vx *= dragCoeff, particle.vy *= dragCoeff, particle.x += particle.vx, particle.y += particle.vy, isShortAnimation) {
37232
+ const lifeDecayRate = Math.max(.1, .5 / timeMultiplier);
37233
+ particle.life = Math.max(0, 1 - progress * lifeDecayRate), particle.a = Math.max(.2, particle.life * Math.min(1, 1.2 * particle.a)), particle.size = Math.max(.7 * this.particleConfig.size, this.particleConfig.size * (.5 + .5 * particle.life));
37234
+ } else particle.life = Math.max(0, 1 - .2 * progress), particle.a = Math.max(.1, particle.life * Math.min(1, 1.5 * particle.a)), particle.size = Math.max(.5 * this.particleConfig.size, this.particleConfig.size * (.3 + .7 * particle.life));
37235
+ }
37236
+ prepareAndDrawParticles(gl) {
37237
+ const positions = new Float32Array(2 * this.particles.length),
37238
+ colors = new Float32Array(4 * this.particles.length),
37239
+ sizes = new Float32Array(this.particles.length);
37240
+ this.particles.forEach((particle, i) => {
37241
+ positions[2 * i] = particle.x, positions[2 * i + 1] = particle.y, colors[4 * i] = particle.r, colors[4 * i + 1] = particle.g, colors[4 * i + 2] = particle.b, colors[4 * i + 3] = Math.max(.1, particle.a), sizes[i] = Math.max(6, 1.5 * particle.size);
37242
+ }), this.updateParticleBuffers(gl, positions, colors, sizes), this.setParticleUniforms(gl), gl.drawArrays(gl.POINTS, 0, this.particles.length), this.cleanupTempBuffers(gl);
37243
+ }
37244
+ updateParticleBuffers(gl, positions, colors, sizes) {
37245
+ this.positionBuffer || (this.positionBuffer = gl.createBuffer()), gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer), gl.bufferData(gl.ARRAY_BUFFER, positions, gl.DYNAMIC_DRAW);
37246
+ const positionLocation = gl.getAttribLocation(this.program, "a_position");
37247
+ gl.enableVertexAttribArray(positionLocation), gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, !1, 0, 0), this.colorBuffer || (this.colorBuffer = gl.createBuffer()), gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer), gl.bufferData(gl.ARRAY_BUFFER, colors, gl.DYNAMIC_DRAW);
37248
+ const colorLocation = gl.getAttribLocation(this.program, "a_color");
37249
+ gl.enableVertexAttribArray(colorLocation), gl.vertexAttribPointer(colorLocation, 4, gl.FLOAT, !1, 0, 0);
37250
+ const sizeBuffer = gl.createBuffer();
37251
+ gl.bindBuffer(gl.ARRAY_BUFFER, sizeBuffer), gl.bufferData(gl.ARRAY_BUFFER, sizes, gl.DYNAMIC_DRAW);
37252
+ const sizeLocation = gl.getAttribLocation(this.program, "a_size");
37253
+ gl.enableVertexAttribArray(sizeLocation), gl.vertexAttribPointer(sizeLocation, 1, gl.FLOAT, !1, 0, 0), this._tempSizeBuffer = sizeBuffer;
37254
+ }
37255
+ setParticleUniforms(gl) {
37256
+ const resolutionLocation = gl.getUniformLocation(this.program, "u_resolution"),
37257
+ timeLocation = gl.getUniformLocation(this.program, "u_time"),
37258
+ forceStrengthLocation = gl.getUniformLocation(this.program, "u_forceStrength"),
37259
+ effectTypeLocation = gl.getUniformLocation(this.program, "u_effectType");
37260
+ gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height), gl.uniform1f(timeLocation, this.getAnimationTime()), gl.uniform1f(forceStrengthLocation, this.particleConfig.strength);
37261
+ gl.uniform1i(effectTypeLocation, {
37262
+ explode: 0,
37263
+ vortex: 1,
37264
+ gravity: 2
37265
+ }[this.particleConfig.effectType] || 0);
37266
+ }
37267
+ cleanupTempBuffers(gl) {
37268
+ const tempSizeBuffer = this._tempSizeBuffer;
37269
+ tempSizeBuffer && (gl.deleteBuffer(tempSizeBuffer), delete this._tempSizeBuffer);
37270
+ }
37271
+ applyCanvas2DExplode(ctx, canvas, progress) {
37272
+ const centerX = canvas.width / 2,
37273
+ centerY = canvas.height / 2;
37274
+ ctx.save(), ctx.globalAlpha = Math.max(0, 1 - progress), ctx.translate(centerX, centerY);
37275
+ const scale = 1 + .5 * progress;
37276
+ ctx.scale(scale, scale), ctx.translate(-centerX, -centerY), ctx.drawImage(canvas, 0, 0), ctx.restore();
37277
+ }
37278
+ applyCanvas2DGravity(ctx, canvas, progress) {
37279
+ ctx.save(), ctx.globalAlpha = Math.max(0, 1 - progress);
37280
+ const offsetY = progress * canvas.height * .3;
37281
+ ctx.drawImage(canvas, 0, offsetY), ctx.restore();
37282
+ }
37283
+ applyCanvas2DVortex(ctx, canvas, progress) {
37284
+ const centerX = canvas.width / 2,
37285
+ centerY = canvas.height / 2;
37286
+ ctx.save(), ctx.globalAlpha = Math.max(0, 1 - progress), ctx.translate(centerX, centerY), ctx.rotate(progress * Math.PI * 2), ctx.translate(-centerX, -centerY), ctx.drawImage(canvas, 0, 0), ctx.restore();
37287
+ }
37288
+ }
37289
+
37290
+ class Glitch extends Canvas2DEffectBase {
37291
+ constructor(from, to, duration, easing, params) {
37292
+ var _a, _b;
37293
+ super(from, to, duration, easing, params), this.glitchConfig = {
37294
+ effectType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.effectType) || "rgb-shift",
37295
+ intensity: void 0 !== (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.intensity) ? params.options.intensity : .5
37296
+ };
37297
+ }
37298
+ applyCanvas2DEffect(canvas) {
37299
+ if (this.glitchConfig.intensity <= 0) {
37300
+ const outputCanvas = this.createOutputCanvas(canvas);
37301
+ return outputCanvas ? outputCanvas.canvas : null;
37302
+ }
37303
+ try {
37304
+ switch (this.glitchConfig.effectType) {
37305
+ case "rgb-shift":
37306
+ default:
37307
+ return this.applyRGBShiftGlitch(canvas);
37308
+ case "digital-distortion":
37309
+ return this.applyDigitalDistortionGlitch(canvas);
37310
+ case "scan-lines":
37311
+ return this.applyScanLineGlitch(canvas);
37312
+ case "data-corruption":
37313
+ return this.applyDataCorruptionGlitch(canvas);
37314
+ }
37315
+ } catch (error) {
37316
+ return console.warn("Glitch effect failed:", error), null;
37317
+ }
37318
+ }
37319
+ applyRGBShiftGlitch(canvas) {
37320
+ const outputCanvas = this.createOutputCanvas(canvas);
37321
+ if (!outputCanvas) return null;
37322
+ const {
37323
+ ctx: ctx
37324
+ } = outputCanvas;
37325
+ try {
37326
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
37327
+ const dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
37328
+ maxOffset = Math.floor(20 * dynamicIntensity),
37329
+ redOffset = this.generateRandomOffset(maxOffset),
37330
+ greenOffset = this.generateRandomOffset(maxOffset, .3),
37331
+ blueOffset = this.generateRandomOffset(-maxOffset),
37332
+ tempCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height),
37333
+ tempCtx = tempCanvas.getContext("2d");
37334
+ tempCtx.drawImage(canvas, 0, 0);
37335
+ const originalImageData = tempCtx.getImageData(0, 0, canvas.width, canvas.height),
37336
+ redChannelData = ImageProcessUtils.extractChannel(originalImageData, 0),
37337
+ greenChannelData = ImageProcessUtils.extractChannel(originalImageData, 1),
37338
+ blueChannelData = ImageProcessUtils.extractChannel(originalImageData, 2);
37339
+ return ctx.globalCompositeOperation = "screen", tempCtx.clearRect(0, 0, canvas.width, canvas.height), tempCtx.putImageData(redChannelData, 0, 0), ctx.drawImage(tempCanvas, redOffset.x, redOffset.y), tempCtx.clearRect(0, 0, canvas.width, canvas.height), tempCtx.putImageData(greenChannelData, 0, 0), ctx.drawImage(tempCanvas, greenOffset.x, greenOffset.y), tempCtx.clearRect(0, 0, canvas.width, canvas.height), tempCtx.putImageData(blueChannelData, 0, 0), ctx.drawImage(tempCanvas, blueOffset.x, blueOffset.y), ctx.globalCompositeOperation = "source-over", outputCanvas.canvas;
37340
+ } catch (error) {
37341
+ return console.warn("RGB shift glitch failed:", error), null;
37342
+ }
37343
+ }
37344
+ applyDigitalDistortionGlitch(canvas) {
37345
+ const outputCanvas = this.createOutputCanvas(canvas);
37346
+ if (!outputCanvas) return null;
37347
+ const {
37348
+ ctx: ctx
37349
+ } = outputCanvas;
37350
+ try {
37351
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
37352
+ dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
37353
+ distortedImageData = this.processDigitalDistortion(imageData, dynamicIntensity);
37354
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(distortedImageData, 0, 0), outputCanvas.canvas;
37355
+ } catch (error) {
37356
+ return console.warn("Digital distortion glitch failed:", error), null;
37357
+ }
37358
+ }
37359
+ applyScanLineGlitch(canvas) {
37360
+ const outputCanvas = this.createOutputCanvas(canvas);
37361
+ if (!outputCanvas) return null;
37362
+ const {
37363
+ ctx: ctx
37364
+ } = outputCanvas;
37365
+ try {
37366
+ const dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
37367
+ lineSpacing = Math.max(2, Math.floor(10 - 8 * dynamicIntensity));
37368
+ ctx.globalCompositeOperation = "multiply";
37369
+ for (let y = 0; y < canvas.height; y += lineSpacing) if (Math.random() < dynamicIntensity) {
37370
+ const opacity = .1 + .4 * dynamicIntensity;
37371
+ ctx.fillStyle = `rgba(0, 0, 0, ${opacity})`, ctx.fillRect(0, y, canvas.width, 1);
37372
+ }
37373
+ ctx.globalCompositeOperation = "screen";
37374
+ const brightLineCount = Math.floor(20 * dynamicIntensity);
37375
+ for (let i = 0; i < brightLineCount; i++) {
37376
+ const y = Math.random() * canvas.height,
37377
+ opacity = .3 * dynamicIntensity;
37378
+ ctx.fillStyle = `rgba(255, 255, 255, ${opacity})`, ctx.fillRect(0, Math.floor(y), canvas.width, 1);
37379
+ }
37380
+ return ctx.globalCompositeOperation = "source-over", outputCanvas.canvas;
37381
+ } catch (error) {
37382
+ return console.warn("Scan line glitch failed:", error), null;
37383
+ }
37384
+ }
37385
+ applyDataCorruptionGlitch(canvas) {
37386
+ const outputCanvas = this.createOutputCanvas(canvas);
37387
+ if (!outputCanvas) return null;
37388
+ const {
37389
+ ctx: ctx
37390
+ } = outputCanvas;
37391
+ try {
37392
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
37393
+ dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
37394
+ corruptedImageData = this.processDataCorruption(imageData, dynamicIntensity);
37395
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(corruptedImageData, 0, 0), outputCanvas.canvas;
37396
+ } catch (error) {
37397
+ return console.warn("Data corruption glitch failed:", error), null;
37398
+ }
37399
+ }
37400
+ generateRandomOffset(maxOffset, scale = 1) {
37401
+ return {
37402
+ x: (Math.random() - .5) * maxOffset,
37403
+ y: (Math.random() - .5) * maxOffset * scale
37404
+ };
37405
+ }
37406
+ processDigitalDistortion(imageData, intensity) {
37407
+ const {
37408
+ data: data,
37409
+ width: width,
37410
+ height: height
37411
+ } = imageData,
37412
+ result = new Uint8ClampedArray(data),
37413
+ sliceCount = Math.floor(20 * intensity) + 5,
37414
+ sliceHeight = Math.floor(height / sliceCount);
37415
+ for (let i = 0; i < sliceCount; i++) if (Math.random() < intensity) {
37416
+ const y = i * sliceHeight,
37417
+ sliceEnd = Math.min(y + sliceHeight, height),
37418
+ offset = Math.floor((Math.random() - .5) * width * intensity * .1);
37419
+ this.shiftSliceHorizontal(result, width, height, y, sliceEnd, offset);
37420
+ }
37421
+ const noiseIntensity = .3 * intensity;
37422
+ for (let i = 0; i < data.length; i += 4) Math.random() < noiseIntensity && (result[i] = 255 * Math.random(), result[i + 1] = 255 * Math.random(), result[i + 2] = 255 * Math.random());
37423
+ return new ImageData(result, width, height);
37424
+ }
37425
+ shiftSliceHorizontal(data, width, height, startY, endY, offset) {
37426
+ const tempRow = new Uint8ClampedArray(4 * width);
37427
+ for (let y = startY; y < endY; y++) {
37428
+ const rowStart = y * width * 4;
37429
+ for (let x = 0; x < 4 * width; x++) tempRow[x] = data[rowStart + x];
37430
+ for (let x = 0; x < width; x++) {
37431
+ const targetIndex = rowStart + 4 * x,
37432
+ sourceIndex = 4 * ((x - offset + width) % width);
37433
+ data[targetIndex] = tempRow[sourceIndex], data[targetIndex + 1] = tempRow[sourceIndex + 1], data[targetIndex + 2] = tempRow[sourceIndex + 2], data[targetIndex + 3] = tempRow[sourceIndex + 3];
37434
+ }
37435
+ }
37436
+ }
37437
+ processDataCorruption(imageData, intensity) {
37438
+ const {
37439
+ data: data,
37440
+ width: width,
37441
+ height: height
37442
+ } = imageData,
37443
+ result = new Uint8ClampedArray(data),
37444
+ stripeCount = Math.floor(15 * intensity) + 5;
37445
+ for (let i = 0; i < stripeCount; i++) if (Math.random() < intensity) {
37446
+ const x = Math.floor(Math.random() * width),
37447
+ stripeWidth = Math.floor(5 * Math.random()) + 1,
37448
+ color = Math.random() < .5 ? 0 : 255;
37449
+ for (let y = 0; y < height; y++) for (let dx = 0; dx < stripeWidth && x + dx < width; dx++) {
37450
+ const index = 4 * (y * width + x + dx);
37451
+ result[index] = color, result[index + 1] = color, result[index + 2] = color;
37452
+ }
37453
+ }
37454
+ const corruptionCount = Math.floor(20 * intensity);
37455
+ for (let i = 0; i < corruptionCount; i++) {
37456
+ const blockX = Math.floor(Math.random() * width),
37457
+ blockY = Math.floor(Math.random() * height),
37458
+ blockW = Math.floor(20 * Math.random()) + 5,
37459
+ blockH = Math.floor(10 * Math.random()) + 2;
37460
+ this.corruptBlock(result, width, height, blockX, blockY, blockW, blockH);
37461
+ }
37462
+ return new ImageData(result, width, height);
37463
+ }
37464
+ corruptBlock(data, width, height, x, y, w, h) {
37465
+ for (let dy = 0; dy < h && y + dy < height; dy++) for (let dx = 0; dx < w && x + dx < width; dx++) {
37466
+ const index = 4 * ((y + dy) * width + (x + dx));
37467
+ Math.random() < .7 && (data[index] = 255 * Math.random(), data[index + 1] = 255 * Math.random(), data[index + 2] = 255 * Math.random());
37468
+ }
37469
+ }
37470
+ }
37471
+
37472
+ class GaussianBlur extends AStageAnimate {
37473
+ constructor(from, to, duration, easing, params) {
37474
+ var _a, _b;
37475
+ super(from, to, duration, easing, params), this.blurConfig = {
37476
+ blurRadius: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.blurRadius) || 8,
37477
+ useOptimizedBlur: void 0 === (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.useOptimizedBlur) || params.options.useOptimizedBlur
37478
+ };
37479
+ }
37480
+ applyCSSBlur(canvas, radius) {
37481
+ const c = vglobal.createCanvas({
37482
+ width: canvas.width,
37483
+ height: canvas.height,
37484
+ dpr: vglobal.devicePixelRatio
37485
+ }),
37486
+ ctx = c.getContext("2d");
37487
+ return ctx ? (ctx.filter = `blur(${radius}px)`, ctx.drawImage(canvas, 0, 0), ctx.filter = "none", c) : canvas;
37488
+ }
37489
+ applyDownsampleBlur(imageData, radius) {
37490
+ const {
37491
+ width: width,
37492
+ height: height
37493
+ } = imageData,
37494
+ downsample = Math.max(1, Math.floor(radius / 2)),
37495
+ smallWidth = Math.floor(width / downsample),
37496
+ smallHeight = Math.floor(height / downsample),
37497
+ tempCanvas = vglobal.createCanvas({
37498
+ width: smallWidth,
37499
+ height: smallHeight,
37500
+ dpr: 1
37501
+ }),
37502
+ tempCtx = tempCanvas.getContext("2d");
37503
+ if (!tempCtx) return imageData;
37504
+ const originalCanvas = vglobal.createCanvas({
37505
+ width: width,
37506
+ height: height,
37507
+ dpr: 1
37508
+ }),
37509
+ originalCtx = originalCanvas.getContext("2d");
37510
+ return originalCtx ? (originalCtx.putImageData(imageData, 0, 0), tempCtx.drawImage(originalCanvas, 0, 0, smallWidth, smallHeight), tempCtx.filter = `blur(${radius / downsample}px)`, tempCtx.drawImage(tempCanvas, 0, 0), tempCtx.filter = "none", originalCtx.clearRect(0, 0, width, height), originalCtx.drawImage(tempCanvas, 0, 0, width, height), originalCtx.getImageData(0, 0, width, height)) : imageData;
37511
+ }
37512
+ afterStageRender(stage, canvas) {
37513
+ if (this.blurConfig.blurRadius <= 0) return canvas;
37514
+ let result;
37515
+ if (this.blurConfig.useOptimizedBlur) result = this.applyCSSBlur(canvas, this.blurConfig.blurRadius);else {
37516
+ const c = vglobal.createCanvas({
37517
+ width: canvas.width,
37518
+ height: canvas.height,
37519
+ dpr: vglobal.devicePixelRatio
37520
+ }),
37521
+ ctx = c.getContext("2d");
37522
+ if (!ctx) return !1;
37523
+ ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.drawImage(canvas, 0, 0);
37524
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
37525
+ blurredImageData = this.applyDownsampleBlur(imageData, this.blurConfig.blurRadius);
37526
+ ctx.putImageData(blurredImageData, 0, 0), result = c;
37527
+ }
37528
+ const ctx = result.getContext("2d");
37529
+ return ctx && (ctx.globalCompositeOperation = "overlay", ctx.fillStyle = "rgba(255, 255, 255, 0.1)", ctx.fillRect(0, 0, result.width, result.height), ctx.globalCompositeOperation = "source-over"), result;
37530
+ }
37531
+ }
37532
+
37533
+ class Pixelation extends DisappearAnimateBase {
37534
+ constructor(from, to, duration, easing, params) {
37535
+ var _a, _b;
37536
+ super(from, to, duration, easing, params), this.pixelationConfig = {
37537
+ maxPixelSize: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.maxPixelSize) || 20,
37538
+ method: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.method) || "out"
37539
+ };
37540
+ }
37541
+ applyDownsamplePixelation(canvas, pixelSize) {
37542
+ if (pixelSize <= 1) return canvas;
37543
+ const {
37544
+ width: width,
37545
+ height: height
37546
+ } = canvas,
37547
+ smallWidth = Math.ceil(width / pixelSize),
37548
+ smallHeight = Math.ceil(height / pixelSize),
37549
+ smallCanvas = vglobal.createCanvas({
37550
+ width: smallWidth,
37551
+ height: smallHeight,
37552
+ dpr: 1
37553
+ }),
37554
+ smallCtx = smallCanvas.getContext("2d");
37555
+ if (!smallCtx) return canvas;
37556
+ const outputCanvas = vglobal.createCanvas({
37557
+ width: width,
37558
+ height: height,
37559
+ dpr: vglobal.devicePixelRatio
37560
+ }),
37561
+ outputCtx = outputCanvas.getContext("2d");
37562
+ return outputCtx ? (smallCtx.imageSmoothingEnabled = !1, outputCtx.imageSmoothingEnabled = !1, smallCtx.drawImage(canvas, 0, 0, smallWidth, smallHeight), outputCtx.drawImage(smallCanvas, 0, 0, width, height), outputCanvas) : canvas;
37563
+ }
37564
+ updateAnimationProgress() {
37565
+ if ("in" === this.pixelationConfig.method) {
37566
+ return this.pixelationConfig.maxPixelSize - this.currentAnimationRatio * (this.pixelationConfig.maxPixelSize - 1);
37567
+ }
37568
+ return 1 + this.currentAnimationRatio * (this.pixelationConfig.maxPixelSize - 1);
37569
+ }
37570
+ afterStageRender(stage, canvas) {
37571
+ const currentPixelSize = this.updateAnimationProgress();
37572
+ if (currentPixelSize <= 1) return canvas;
37573
+ return this.applyDownsamplePixelation(canvas, currentPixelSize);
37574
+ }
37575
+ }
37576
+
36237
37577
  const registerCustomAnimate = () => {
36238
- AnimateExecutor.registerBuiltInAnimate("increaseCount", IncreaseCount), AnimateExecutor.registerBuiltInAnimate("fromTo", FromTo), AnimateExecutor.registerBuiltInAnimate("scaleIn", ScaleIn), AnimateExecutor.registerBuiltInAnimate("scaleOut", ScaleOut), AnimateExecutor.registerBuiltInAnimate("growHeightIn", GrowHeightIn), AnimateExecutor.registerBuiltInAnimate("growHeightOut", GrowHeightOut), AnimateExecutor.registerBuiltInAnimate("growWidthIn", GrowWidthIn), AnimateExecutor.registerBuiltInAnimate("growWidthOut", GrowWidthOut), AnimateExecutor.registerBuiltInAnimate("growCenterIn", GrowCenterIn), AnimateExecutor.registerBuiltInAnimate("growCenterOut", GrowCenterOut), AnimateExecutor.registerBuiltInAnimate("clipIn", ClipIn), AnimateExecutor.registerBuiltInAnimate("clipOut", ClipOut), AnimateExecutor.registerBuiltInAnimate("fadeIn", FadeIn), AnimateExecutor.registerBuiltInAnimate("fadeOut", FadeOut), AnimateExecutor.registerBuiltInAnimate("growPointsIn", GrowPointsIn), AnimateExecutor.registerBuiltInAnimate("growPointsOut", GrowPointsOut), AnimateExecutor.registerBuiltInAnimate("growPointsXIn", GrowPointsXIn), AnimateExecutor.registerBuiltInAnimate("growPointsXOut", GrowPointsXOut), AnimateExecutor.registerBuiltInAnimate("growPointsYIn", GrowPointsYIn), AnimateExecutor.registerBuiltInAnimate("growPointsYOut", GrowPointsYOut), AnimateExecutor.registerBuiltInAnimate("growAngleIn", GrowAngleIn), AnimateExecutor.registerBuiltInAnimate("growAngleOut", GrowAngleOut), AnimateExecutor.registerBuiltInAnimate("growRadiusIn", GrowRadiusIn), AnimateExecutor.registerBuiltInAnimate("growRadiusOut", GrowRadiusOut), AnimateExecutor.registerBuiltInAnimate("moveIn", MoveIn), AnimateExecutor.registerBuiltInAnimate("moveOut", MoveOut), AnimateExecutor.registerBuiltInAnimate("rotateIn", RotateIn), AnimateExecutor.registerBuiltInAnimate("rotateOut", RotateOut), AnimateExecutor.registerBuiltInAnimate("update", Update), AnimateExecutor.registerBuiltInAnimate("state", State), AnimateExecutor.registerBuiltInAnimate("labelItemAppear", LabelItemAppear), AnimateExecutor.registerBuiltInAnimate("labelItemDisappear", LabelItemDisappear), AnimateExecutor.registerBuiltInAnimate("poptipAppear", PoptipAppear), AnimateExecutor.registerBuiltInAnimate("poptipDisappear", PoptipDisappear), AnimateExecutor.registerBuiltInAnimate("inputText", InputText), AnimateExecutor.registerBuiltInAnimate("inputRichText", InputRichText), AnimateExecutor.registerBuiltInAnimate("outputRichText", OutputRichText), AnimateExecutor.registerBuiltInAnimate("slideRichText", SlideRichText), AnimateExecutor.registerBuiltInAnimate("slideOutRichText", SlideOutRichText), AnimateExecutor.registerBuiltInAnimate("slideIn", SlideIn), AnimateExecutor.registerBuiltInAnimate("growIn", GrowIn), AnimateExecutor.registerBuiltInAnimate("spinIn", SpinIn), AnimateExecutor.registerBuiltInAnimate("moveScaleIn", MoveScaleIn), AnimateExecutor.registerBuiltInAnimate("moveRotateIn", MoveRotateIn), AnimateExecutor.registerBuiltInAnimate("strokeIn", StrokeIn), AnimateExecutor.registerBuiltInAnimate("slideOut", SlideOut), AnimateExecutor.registerBuiltInAnimate("growOut", GrowOut), AnimateExecutor.registerBuiltInAnimate("spinOut", SpinOut), AnimateExecutor.registerBuiltInAnimate("moveScaleOut", MoveScaleOut), AnimateExecutor.registerBuiltInAnimate("moveRotateOut", MoveRotateOut), AnimateExecutor.registerBuiltInAnimate("strokeOut", StrokeOut), AnimateExecutor.registerBuiltInAnimate("pulse", PulseAnimate), AnimateExecutor.registerBuiltInAnimate("MotionPath", MotionPath), AnimateExecutor.registerBuiltInAnimate("streamLight", StreamLight);
37578
+ AnimateExecutor.registerBuiltInAnimate("increaseCount", IncreaseCount), AnimateExecutor.registerBuiltInAnimate("fromTo", FromTo), AnimateExecutor.registerBuiltInAnimate("scaleIn", ScaleIn), AnimateExecutor.registerBuiltInAnimate("scaleOut", ScaleOut), AnimateExecutor.registerBuiltInAnimate("growHeightIn", GrowHeightIn), AnimateExecutor.registerBuiltInAnimate("growHeightOut", GrowHeightOut), AnimateExecutor.registerBuiltInAnimate("growWidthIn", GrowWidthIn), AnimateExecutor.registerBuiltInAnimate("growWidthOut", GrowWidthOut), AnimateExecutor.registerBuiltInAnimate("growCenterIn", GrowCenterIn), AnimateExecutor.registerBuiltInAnimate("growCenterOut", GrowCenterOut), AnimateExecutor.registerBuiltInAnimate("clipIn", ClipIn), AnimateExecutor.registerBuiltInAnimate("clipOut", ClipOut), AnimateExecutor.registerBuiltInAnimate("fadeIn", FadeIn), AnimateExecutor.registerBuiltInAnimate("fadeOut", FadeOut), AnimateExecutor.registerBuiltInAnimate("growPointsIn", GrowPointsIn), AnimateExecutor.registerBuiltInAnimate("growPointsOut", GrowPointsOut), AnimateExecutor.registerBuiltInAnimate("growPointsXIn", GrowPointsXIn), AnimateExecutor.registerBuiltInAnimate("growPointsXOut", GrowPointsXOut), AnimateExecutor.registerBuiltInAnimate("growPointsYIn", GrowPointsYIn), AnimateExecutor.registerBuiltInAnimate("growPointsYOut", GrowPointsYOut), AnimateExecutor.registerBuiltInAnimate("growAngleIn", GrowAngleIn), AnimateExecutor.registerBuiltInAnimate("growAngleOut", GrowAngleOut), AnimateExecutor.registerBuiltInAnimate("growRadiusIn", GrowRadiusIn), AnimateExecutor.registerBuiltInAnimate("growRadiusOut", GrowRadiusOut), AnimateExecutor.registerBuiltInAnimate("moveIn", MoveIn), AnimateExecutor.registerBuiltInAnimate("moveOut", MoveOut), AnimateExecutor.registerBuiltInAnimate("rotateIn", RotateIn), AnimateExecutor.registerBuiltInAnimate("rotateOut", RotateOut), AnimateExecutor.registerBuiltInAnimate("update", Update), AnimateExecutor.registerBuiltInAnimate("state", State), AnimateExecutor.registerBuiltInAnimate("labelItemAppear", LabelItemAppear), AnimateExecutor.registerBuiltInAnimate("labelItemDisappear", LabelItemDisappear), AnimateExecutor.registerBuiltInAnimate("poptipAppear", PoptipAppear), AnimateExecutor.registerBuiltInAnimate("poptipDisappear", PoptipDisappear), AnimateExecutor.registerBuiltInAnimate("inputText", InputText), AnimateExecutor.registerBuiltInAnimate("inputRichText", InputRichText), AnimateExecutor.registerBuiltInAnimate("outputRichText", OutputRichText), AnimateExecutor.registerBuiltInAnimate("slideRichText", SlideRichText), AnimateExecutor.registerBuiltInAnimate("slideOutRichText", SlideOutRichText), AnimateExecutor.registerBuiltInAnimate("slideIn", SlideIn), AnimateExecutor.registerBuiltInAnimate("growIn", GrowIn), AnimateExecutor.registerBuiltInAnimate("spinIn", SpinIn), AnimateExecutor.registerBuiltInAnimate("moveScaleIn", MoveScaleIn), AnimateExecutor.registerBuiltInAnimate("moveRotateIn", MoveRotateIn), AnimateExecutor.registerBuiltInAnimate("strokeIn", StrokeIn), AnimateExecutor.registerBuiltInAnimate("slideOut", SlideOut), AnimateExecutor.registerBuiltInAnimate("growOut", GrowOut), AnimateExecutor.registerBuiltInAnimate("spinOut", SpinOut), AnimateExecutor.registerBuiltInAnimate("moveScaleOut", MoveScaleOut), AnimateExecutor.registerBuiltInAnimate("moveRotateOut", MoveRotateOut), AnimateExecutor.registerBuiltInAnimate("strokeOut", StrokeOut), AnimateExecutor.registerBuiltInAnimate("pulse", PulseAnimate), AnimateExecutor.registerBuiltInAnimate("MotionPath", MotionPath), AnimateExecutor.registerBuiltInAnimate("streamLight", StreamLight), AnimateExecutor.registerBuiltInAnimate("dissolve", Dissolve), AnimateExecutor.registerBuiltInAnimate("grayscale", Grayscale), AnimateExecutor.registerBuiltInAnimate("distortion", Distortion), AnimateExecutor.registerBuiltInAnimate("particle", Particle), AnimateExecutor.registerBuiltInAnimate("glitch", Glitch), AnimateExecutor.registerBuiltInAnimate("gaussianBlur", GaussianBlur), AnimateExecutor.registerBuiltInAnimate("pixelation", Pixelation);
36239
37579
  };
36240
37580
 
36241
37581
  class AxisEnter extends AComponentAnimate {
@@ -39270,19 +40610,22 @@
39270
40610
  const {
39271
40611
  clampForce = !0,
39272
40612
  hideOnHit = !0,
40613
+ hideOnOverflow = !1,
39273
40614
  overlapPadding: overlapPadding,
39274
40615
  strategy: strategy
39275
40616
  } = option;
39276
- if (clampForce) for (let i = 0; i < result.length; i++) {
40617
+ if (clampForce || hideOnOverflow) for (let i = 0; i < result.length; i++) {
39277
40618
  const text = labels[i],
39278
40619
  {
39279
40620
  dx = 0,
39280
40621
  dy = 0
39281
40622
  } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
39282
- 0 === dx && 0 === dy || (text.setAttributes({
40623
+ 0 === dx && 0 === dy || (hideOnOverflow ? text.setAttributes({
40624
+ visible: !1
40625
+ }) : (text.setAttributes({
39283
40626
  x: text.attribute.x + dx,
39284
40627
  y: text.attribute.y + dy
39285
- }), text._isClamped = !0);
40628
+ }), text._isClamped = !0));
39286
40629
  }
39287
40630
  result = shiftY(result, Object.assign(Object.assign({
39288
40631
  maxY: bmpTool.height
@@ -39298,9 +40641,9 @@
39298
40641
  bounds = text.AABBBounds,
39299
40642
  range = boundToRange(bmpTool, bounds, !0);
39300
40643
  if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) bitmap.setRange(range);else {
39301
- if (clampForce) {
39302
- if (this._processClampForce(text, bmpTool, bitmap, overlapPadding)) continue;
39303
- }
40644
+ if (hideOnOverflow) {
40645
+ if (this._processHideOnOverflow(text, bmpTool)) continue;
40646
+ } else if (clampForce && this._processClampForce(text, bmpTool, bitmap, overlapPadding)) continue;
39304
40647
  hideOnHit ? text.setAttributes({
39305
40648
  visible: !1
39306
40649
  }) : bitmap.setRange(range);
@@ -39308,6 +40651,15 @@
39308
40651
  }
39309
40652
  return result;
39310
40653
  }
40654
+ _processHideOnOverflow(text, bmpTool) {
40655
+ const {
40656
+ dy = 0,
40657
+ dx = 0
40658
+ } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
40659
+ return 0 === dx && 0 === dy || (text.setAttributes({
40660
+ visible: !1
40661
+ }), !1);
40662
+ }
39311
40663
  _processClampForce(text, bmpTool, bitmap, overlapPadding = 0) {
39312
40664
  const {
39313
40665
  dy = 0,
@@ -39334,7 +40686,8 @@
39334
40686
  hideOnHit = !0,
39335
40687
  clampForce = !0,
39336
40688
  avoidMarks = [],
39337
- overlapPadding: overlapPadding
40689
+ overlapPadding: overlapPadding,
40690
+ hideOnOverflow = !1
39338
40691
  } = option,
39339
40692
  result = [],
39340
40693
  checkBounds = strategy.some(s => "bound" === s.type);
@@ -39361,15 +40714,16 @@
39361
40714
  }
39362
40715
  }
39363
40716
  let hasPlace = !1;
39364
- for (let j = 0; j < strategy.length; j++) if (hasPlace = place$2(bmpTool, bitmap, strategy[j], this.attribute, text, this._isCollectionBase ? this.getGraphicBounds(null, this._idToPoint.get(labels[i].attribute.id)) : this.getGraphicBounds(baseMark, labels[i].attribute), this.labeling), !1 !== hasPlace) {
39365
- text.setAttributes({
39366
- x: hasPlace.x,
39367
- y: hasPlace.y
39368
- }), result.push(text);
40717
+ for (let j = 0; j < strategy.length; j++) if (hasPlace = place$2(bmpTool, bitmap, strategy[j], this.attribute, text, this._isCollectionBase ? this.getGraphicBounds(null, this._idToPoint.get(labels[i].attribute.id)) : this.getGraphicBounds(baseMark, labels[i].attribute), this.labeling), !1 !== hasPlace && (text.setAttributes({
40718
+ x: hasPlace.x,
40719
+ y: hasPlace.y
40720
+ }), !hideOnOverflow || this._processHideOnOverflow(text, bmpTool))) {
40721
+ result.push(text);
39369
40722
  break;
39370
40723
  }
39371
- if (!hasPlace && clampForce) {
39372
- if (this._processClampForce(text, bmpTool, bitmap, overlapPadding)) {
40724
+ if (!hasPlace) {
40725
+ if (hideOnOverflow && !this._processHideOnOverflow(text, bmpTool)) continue;
40726
+ if (clampForce && this._processClampForce(text, bmpTool, bitmap, overlapPadding)) {
39373
40727
  result.push(text);
39374
40728
  continue;
39375
40729
  }
@@ -48190,6 +49544,9 @@
48190
49544
  static registerChartPlugin(key, plugin) {
48191
49545
  Factory._chartPlugin[key] = plugin;
48192
49546
  }
49547
+ static registerVChartPlugin(key, plugin) {
49548
+ Factory._vChartPlugin[key] = plugin;
49549
+ }
48193
49550
  static registerComponentPlugin(key, plugin) {
48194
49551
  Factory._componentPlugin[key] = plugin;
48195
49552
  }
@@ -48306,6 +49663,9 @@
48306
49663
  static getChartPlugins() {
48307
49664
  return Object.values(Factory._chartPlugin);
48308
49665
  }
49666
+ static getVChartPlugins() {
49667
+ return Object.values(Factory._vChartPlugin);
49668
+ }
48309
49669
  static getComponentPlugins() {
48310
49670
  return Object.values(Factory._componentPlugin);
48311
49671
  }
@@ -48341,6 +49701,7 @@
48341
49701
  Factory._animations = {};
48342
49702
  Factory._implements = {};
48343
49703
  Factory._chartPlugin = {};
49704
+ Factory._vChartPlugin = {};
48344
49705
  Factory._componentPlugin = {};
48345
49706
  Factory.transforms = {
48346
49707
  fields: fields,
@@ -49417,6 +50778,7 @@
49417
50778
  ChartEvent["afterRender"] = "afterRender";
49418
50779
  ChartEvent["afterLayout"] = "afterLayout";
49419
50780
  ChartEvent["afterMarkLayoutEnd"] = "afterMarkLayoutEnd";
50781
+ ChartEvent["afterWordcloudShapeDraw"] = "afterWordcloudShapeDraw";
49420
50782
  })(exports.ChartEvent || (exports.ChartEvent = {}));
49421
50783
  var Event_Source_Type;
49422
50784
  (function (Event_Source_Type) {
@@ -50404,7 +51766,7 @@
50404
51766
  });
50405
51767
  }
50406
51768
  _doRender(immediately) {
50407
- var _a, _b;
51769
+ var _a, _b, _c, _d;
50408
51770
  if (this._stage) {
50409
51771
  this._rootMarks.forEach(g => {
50410
51772
  traverseGroupMark(g, m => {
@@ -50417,11 +51779,12 @@
50417
51779
  }
50418
51780
  }, null, true);
50419
51781
  });
51782
+ (_b = (_a = this._option.performanceHook) === null || _a === void 0 ? void 0 : _a.beforeVRenderDraw) === null || _b === void 0 ? void 0 : _b.call(_a, this._compileChart.getOption().globalInstance);
50420
51783
  this._stage.disableDirtyBounds();
50421
51784
  this._stage.afterNextRender(this._handleAfterNextRender);
50422
51785
  if (immediately) {
50423
51786
  this._stage.render();
50424
- (_b = (_a = this._option.performanceHook) === null || _a === void 0 ? void 0 : _a.afterVRenderDraw) === null || _b === void 0 ? void 0 : _b.call(_a, this._compileChart.getOption().globalInstance);
51787
+ (_d = (_c = this._option.performanceHook) === null || _c === void 0 ? void 0 : _c.afterVRenderDraw) === null || _d === void 0 ? void 0 : _d.call(_c, this._compileChart.getOption().globalInstance);
50425
51788
  }
50426
51789
  }
50427
51790
  }
@@ -55490,6 +56853,22 @@
55490
56853
  Factory.registerInteractionTrigger(ElementSelect.type, ElementSelect);
55491
56854
  };
55492
56855
 
56856
+ class VChartPluginService extends BasePluginService {
56857
+ constructor(globalInstance) {
56858
+ super();
56859
+ this.globalInstance = globalInstance;
56860
+ }
56861
+ onInit() {
56862
+ this._plugins.forEach(plugin => {
56863
+ plugin.onInit && plugin.onInit(this);
56864
+ });
56865
+ }
56866
+ releaseAll() {
56867
+ super.releaseAll();
56868
+ this.globalInstance = null;
56869
+ }
56870
+ }
56871
+
55493
56872
  class VChart {
55494
56873
  static useRegisters(comps) {
55495
56874
  comps.forEach((fn) => {
@@ -55571,6 +56950,9 @@
55571
56950
  getSpecInfo() {
55572
56951
  return this._specInfo;
55573
56952
  }
56953
+ get event() {
56954
+ return this._event;
56955
+ }
55574
56956
  getDataSet() {
55575
56957
  return this._dataSet;
55576
56958
  }
@@ -56775,6 +58157,12 @@
56775
58157
  this._chartPlugin.load(pluginList.map(p => new p()));
56776
58158
  this._chartPluginApply('onInit', this._spec);
56777
58159
  }
58160
+ const vChartPluginList = Factory.getVChartPlugins();
58161
+ if (vChartPluginList.length > 0) {
58162
+ this._vChartPlugin = new VChartPluginService(this);
58163
+ this._vChartPlugin.load(vChartPluginList.map(p => new p()));
58164
+ this._vChartPlugin.onInit();
58165
+ }
56778
58166
  }
56779
58167
  _chartPluginApply(funcName, ...args) {
56780
58168
  if (!this._chartPlugin || !this._chartPlugin[funcName]) {
@@ -56927,7 +58315,7 @@
56927
58315
  });
56928
58316
  };
56929
58317
 
56930
- const version = "2.0.4-alpha.6";
58318
+ const version = "2.0.4-alpha.7";
56931
58319
 
56932
58320
  const addVChartProperty = (data, op) => {
56933
58321
  const context = op.beforeCall();
@@ -57676,7 +59064,7 @@
57676
59064
  traverseSpec(spec[index], transform, excludeKeys);
57677
59065
  });
57678
59066
  }
57679
- else if (isObject$2(spec)) {
59067
+ else if (isObject$2(spec) && typeof spec !== 'function') {
57680
59068
  for (const key in spec) {
57681
59069
  if (!excludeKeys.includes(key)) {
57682
59070
  spec[key] = transform(spec[key], key);
@@ -64861,7 +66249,7 @@
64861
66249
  this._event = new Event$1(option.eventDispatcher, option.mode);
64862
66250
  this._dataSet = option.dataSet;
64863
66251
  this._chartData = new ChartData(this._dataSet);
64864
- this._modelOption = Object.assign(Object.assign({}, option), { mode: this._option.mode, map: this._idMap, getChartLayoutRect: () => this._layoutRect, getChartViewRect: () => this._viewRect, getChart: () => this, globalScale: this._globalScale, onError: (_b = this._option) === null || _b === void 0 ? void 0 : _b.onError, disableTriggerEvent: ((_c = this._option) === null || _c === void 0 ? void 0 : _c.disableTriggerEvent) === true, getSeriesData: this._chartData.getSeriesData.bind(this._chartData) });
66252
+ this._modelOption = Object.assign(Object.assign({}, option), { mode: this._option.mode, map: this._idMap, getChartLayoutRect: () => this._layoutRect, getChartViewRect: () => this._viewRect, getChart: () => this, globalScale: this._globalScale, onError: (_b = this._option) === null || _b === void 0 ? void 0 : _b.onError, disableTriggerEvent: ((_c = this._option) === null || _c === void 0 ? void 0 : _c.disableTriggerEvent) === true, getSeriesData: this._chartData.getSeriesData.bind(this._chartData), dispatchEvent: (eType, params) => this._option.globalInstance.event.emit(eType, params) });
64865
66253
  if (this._setModelOption) {
64866
66254
  this._setModelOption();
64867
66255
  }
@@ -76478,6 +77866,26 @@
76478
77866
  isNil$1(this._maskShape.fontFamily)
76479
77867
  ? Object.assign({ fontFamily: this._option.getTheme('fontFamily') }, this._maskShape) : this._maskShape,
76480
77868
  onUpdateMaskCanvas: this.handleMaskCanvasUpdate,
77869
+ onLayoutFinished: () => {
77870
+ const afterWordcloudShapeDraw = () => {
77871
+ var _a, _b, _c, _d;
77872
+ this._option.globalInstance.getStage().hooks.afterRender.taps = this._option.globalInstance
77873
+ .getStage()
77874
+ .hooks.afterRender.taps.filter(tap => tap.fn !== afterWordcloudShapeDraw);
77875
+ (_b = (_a = this._option).dispatchEvent) === null || _b === void 0 ? void 0 : _b.call(_a, exports.ChartEvent.afterWordcloudShapeDraw, {
77876
+ instance: this._option.globalInstance
77877
+ });
77878
+ (_d = (_c = this._option.globalInstance
77879
+ .getChart()
77880
+ .getOption()
77881
+ .performanceHook) === null || _c === void 0 ? void 0 : _c.afterWordcloudShapeDraw) === null || _d === void 0 ? void 0 : _d.call(_c, this._option.globalInstance);
77882
+ };
77883
+ this._option.globalInstance.getStage().hooks.afterRender.taps.push({
77884
+ type: 'sync',
77885
+ name: 'afterWordcloudShapeDraw',
77886
+ fn: afterWordcloudShapeDraw
77887
+ });
77888
+ },
76481
77889
  dataIndexKey: DEFAULT_DATA_KEY,
76482
77890
  text: wordSpec.formatMethod
76483
77891
  ? (datum) => {
@@ -88175,6 +89583,8 @@
88175
89583
  var _a, _b;
88176
89584
  const series = super._getDefaultSeriesSpec(spec);
88177
89585
  series.area = spec.area;
89586
+ series.point = spec.point;
89587
+ series.line = spec.line;
88178
89588
  if (spec.direction === "horizontal") {
88179
89589
  series.xField = (_a = spec.xField) !== null && _a !== void 0 ? _a : [spec.minField, spec.maxField];
88180
89590
  }
@@ -91630,16 +93040,19 @@
91630
93040
  return active && hasChange;
91631
93041
  };
91632
93042
  this._handleChartDrag = (delta, e) => {
91633
- var _a;
93043
+ var _a, _b;
91634
93044
  if (!this._activeRoam || (this._dragAttr.filter && !this._dragAttr.filter(delta, e))) {
91635
93045
  return;
91636
93046
  }
93047
+ if ((_a = this._spec.roamDrag) === null || _a === void 0 ? void 0 : _a.autoVisible) {
93048
+ this.show();
93049
+ }
91637
93050
  const [dx, dy] = delta;
91638
93051
  let value = this._isHorizontal ? dx : dy;
91639
93052
  if (this._dragAttr.reverse) {
91640
93053
  value = -value;
91641
93054
  }
91642
- this._handleChartMove(value, (_a = this._dragAttr.rate) !== null && _a !== void 0 ? _a : 1);
93055
+ this._handleChartMove(value, (_b = this._dragAttr.rate) !== null && _b !== void 0 ? _b : 1);
91643
93056
  };
91644
93057
  this._handleChartMove = (value, rate) => {
91645
93058
  const totalValue = this._isHorizontal ? this.getLayoutRect().width : this.getLayoutRect().height;
@@ -92044,9 +93457,9 @@
92044
93457
  return allDomain.slice(Math.min(startIndex, endIndex), Math.max(startIndex, endIndex) + 1);
92045
93458
  }
92046
93459
  _initCommonEvent() {
92047
- var _a, _b, _c, _d, _e, _f, _g;
93460
+ var _a, _b, _c, _d, _e, _f, _g, _h;
92048
93461
  const delayType = (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.delayType) !== null && _b !== void 0 ? _b : 'throttle';
92049
- const delayTime = isValid$1((_c = this._spec) === null || _c === void 0 ? void 0 : _c.delayType) ? (_e = (_d = this._spec) === null || _d === void 0 ? void 0 : _d.delayTime) !== null && _e !== void 0 ? _e : 30 : 0;
93462
+ const delayTime = isValid$1((_c = this._spec) === null || _c === void 0 ? void 0 : _c.delayType) ? ((_e = (_d = this._spec) === null || _d === void 0 ? void 0 : _d.delayTime) !== null && _e !== void 0 ? _e : 30) : 0;
92050
93463
  const realTime = (_g = (_f = this._spec) === null || _f === void 0 ? void 0 : _f.realTime) !== null && _g !== void 0 ? _g : true;
92051
93464
  const option = { delayType, delayTime, realTime, allowComponentZoom: true };
92052
93465
  if (this._zoomAttr.enable) {
@@ -92058,6 +93471,13 @@
92058
93471
  if (this._dragAttr.enable) {
92059
93472
  this.initDragEventOfRegions(this._regions, null, this._handleChartDrag, option);
92060
93473
  }
93474
+ if ((_h = this._spec.roamDrag) === null || _h === void 0 ? void 0 : _h.autoVisible) {
93475
+ const dragEnd = 'panend';
93476
+ this._throttledHide = throttle(() => this.hide(), 300);
93477
+ this.event.on(dragEnd, () => {
93478
+ this._throttledHide();
93479
+ });
93480
+ }
92061
93481
  }
92062
93482
  updateLayoutAttribute() {
92063
93483
  if (this._visible) {
@@ -92178,6 +93598,9 @@
92178
93598
  _getNeedClearVRenderComponents() {
92179
93599
  return [this._component];
92180
93600
  }
93601
+ clear() {
93602
+ this._throttledHide = null;
93603
+ }
92181
93604
  }
92182
93605
  mixin(DataFilterBaseComponent, Zoomable);
92183
93606
 
@@ -96255,7 +97678,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
96255
97678
  this.coordinateType = 'cartesian';
96256
97679
  }
96257
97680
  _computePointsAttr() {
96258
- var _a;
97681
+ var _a, _b, _c;
96259
97682
  const spec = this._spec;
96260
97683
  const data = this._markerData;
96261
97684
  const relativeSeries = this._relativeSeries;
@@ -96265,7 +97688,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
96265
97688
  const autoRange = (_a = spec === null || spec === void 0 ? void 0 : spec.autoRange) !== null && _a !== void 0 ? _a : false;
96266
97689
  let point;
96267
97690
  if (isXYLayout) {
96268
- point = xyLayout(data, relativeSeries, relativeSeries, relativeSeries, autoRange)[0][0];
97691
+ point = (_c = (_b = xyLayout(data, relativeSeries, relativeSeries, relativeSeries, autoRange)) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c[0];
96269
97692
  }
96270
97693
  else if (isCoordinateLayout) {
96271
97694
  point = cartesianCoordinateLayout(data, relativeSeries, autoRange, spec.coordinatesOffset)[0];
@@ -98118,7 +99541,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
98118
99541
  this._container = null;
98119
99542
  }
98120
99543
  _updateTooltip(visible, params) {
98121
- var _a, _b, _c;
99544
+ var _a, _b;
98122
99545
  if (!visible || !this._rootDom) {
98123
99546
  this.setVisibility(visible);
98124
99547
  this._cacheCustomTooltipPosition = undefined;
@@ -98128,29 +99551,26 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
98128
99551
  if (!params.changePositionOnly) {
98129
99552
  this._tooltipActual = activeTooltipSpec;
98130
99553
  }
98131
- const currentVisible = this.getVisibility();
98132
99554
  const el = this._rootDom;
98133
99555
  if (el) {
98134
99556
  const { x = 0, y = 0 } = (_a = activeTooltipSpec.position) !== null && _a !== void 0 ? _a : {};
99557
+ let position = { x, y };
99558
+ const currentVisible = this.getVisibility();
98135
99559
  if (tooltipSpec.updateElement) {
98136
99560
  this._updatePosition((_b = this._cacheCustomTooltipPosition) !== null && _b !== void 0 ? _b : { x, y });
98137
99561
  tooltipSpec.updateElement(el, activeTooltipSpec, params);
98138
- const position = this._getActualTooltipPosition(activeTooltipSpec, params, {
99562
+ position = this._getActualTooltipPosition(activeTooltipSpec, params, {
98139
99563
  width: el.offsetWidth,
98140
99564
  height: el.offsetHeight
98141
99565
  });
98142
- this._updatePosition(position);
98143
99566
  this._cacheCustomTooltipPosition = position;
98144
99567
  }
98145
- else {
98146
- if (!currentVisible) {
98147
- this._rootDom.style.transitionDuration = '0ms';
98148
- }
98149
- else {
98150
- this._rootDom.style.transitionDuration = (_c = this._domStyle.panel.transitionDuration) !== null && _c !== void 0 ? _c : 'initial';
98151
- }
98152
- this._updatePosition({ x, y });
99568
+ if (!currentVisible && visible) {
99569
+ this._rootDom.style.transition = 'none';
99570
+ this._updatePosition(position, false);
99571
+ this._rootDom.getBoundingClientRect();
98153
99572
  }
99573
+ this._updatePosition(position);
98154
99574
  }
98155
99575
  this.setVisibility(visible);
98156
99576
  }
@@ -98328,9 +99748,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
98328
99748
  this._updateDomStyle('height', false);
98329
99749
  }
98330
99750
  }
98331
- _updatePosition({ x, y }) {
99751
+ _updatePosition({ x, y }, resetTransition = true) {
98332
99752
  if (this._rootDom) {
98333
99753
  this._rootDom.style.transform = `translate3d(${x}px, ${y}px, 0)`;
99754
+ if (resetTransition && this._rootDom.style.transition !== '') {
99755
+ this._rootDom.style.transition = '';
99756
+ Object.assign(this._rootDom.style, this._domStyle.panel);
99757
+ }
98334
99758
  }
98335
99759
  }
98336
99760
  }