@visactor/vchart 2.0.4-alpha.5 → 2.0.4

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 (114) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.es.js +1490 -83
  3. package/build/index.js +1490 -83
  4. package/build/index.min.js +2 -2
  5. package/build/tsconfig.tsbuildinfo +1 -1
  6. package/cjs/chart/range-area/range-area-transformer.js +2 -1
  7. package/cjs/chart/range-area/range-area-transformer.js.map +1 -1
  8. package/cjs/compile/compiler.js +4 -3
  9. package/cjs/compile/compiler.js.map +1 -1
  10. package/cjs/component/data-zoom/data-filter-base-component.d.ts +2 -0
  11. package/cjs/component/data-zoom/data-filter-base-component.js +15 -5
  12. package/cjs/component/data-zoom/data-filter-base-component.js.map +1 -1
  13. package/cjs/component/data-zoom/interface.d.ts +1 -0
  14. package/cjs/component/data-zoom/interface.js.map +1 -1
  15. package/cjs/component/marker/mark-point/cartesian-mark-point.js +2 -2
  16. package/cjs/component/marker/mark-point/cartesian-mark-point.js.map +1 -1
  17. package/cjs/constant/attribute.js +1 -2
  18. package/cjs/constant/label.js +2 -1
  19. package/cjs/constant/waterfall.js +1 -2
  20. package/cjs/constant/word-cloud.js +1 -1
  21. package/cjs/core/expression-function.js +2 -1
  22. package/cjs/core/factory.d.ts +4 -0
  23. package/cjs/core/factory.js +8 -2
  24. package/cjs/core/factory.js.map +1 -1
  25. package/cjs/core/index.d.ts +1 -1
  26. package/cjs/core/index.js +1 -1
  27. package/cjs/core/index.js.map +1 -1
  28. package/cjs/core/interface.d.ts +2 -0
  29. package/cjs/core/interface.js.map +1 -1
  30. package/cjs/core/vchart.d.ts +1 -0
  31. package/cjs/core/vchart.js +5 -2
  32. package/cjs/core/vchart.js.map +1 -1
  33. package/cjs/plugin/components/tooltip-handler/dom-tooltip-handler.d.ts +1 -1
  34. package/cjs/plugin/components/tooltip-handler/dom-tooltip-handler.js +17 -17
  35. package/cjs/plugin/components/tooltip-handler/dom-tooltip-handler.js.map +1 -1
  36. package/cjs/plugin/vchart/index.d.ts +2 -0
  37. package/cjs/plugin/vchart/index.js +21 -0
  38. package/cjs/plugin/vchart/index.js.map +1 -0
  39. package/cjs/plugin/vchart/interface.d.ts +16 -0
  40. package/cjs/plugin/vchart/interface.js +6 -0
  41. package/cjs/plugin/vchart/interface.js.map +1 -0
  42. package/cjs/plugin/vchart/plugin-service.d.ts +9 -0
  43. package/cjs/plugin/vchart/plugin-service.js +24 -0
  44. package/cjs/plugin/vchart/plugin-service.js.map +1 -0
  45. package/cjs/plugin/vchart/register.d.ts +2 -0
  46. package/cjs/plugin/vchart/register.js +12 -0
  47. package/cjs/plugin/vchart/register.js.map +1 -0
  48. package/cjs/plugin/vchart/rotate/index.d.ts +1 -0
  49. package/cjs/plugin/vchart/rotate/index.js +21 -0
  50. package/cjs/plugin/vchart/rotate/index.js.map +1 -0
  51. package/cjs/plugin/vchart/rotate/rotate.d.ts +18 -0
  52. package/cjs/plugin/vchart/rotate/rotate.js +67 -0
  53. package/cjs/plugin/vchart/rotate/rotate.js.map +1 -0
  54. package/cjs/series/word-cloud/base.js +4 -0
  55. package/cjs/series/word-cloud/base.js.map +1 -1
  56. package/cjs/typings/spec/common.d.ts +1 -0
  57. package/cjs/typings/spec/common.js.map +1 -1
  58. package/cjs/util/style.js +3 -2
  59. package/cjs/util/style.js.map +1 -1
  60. package/esm/chart/range-area/range-area-transformer.js +2 -1
  61. package/esm/chart/range-area/range-area-transformer.js.map +1 -1
  62. package/esm/compile/compiler.js +4 -3
  63. package/esm/compile/compiler.js.map +1 -1
  64. package/esm/component/data-zoom/data-filter-base-component.d.ts +2 -0
  65. package/esm/component/data-zoom/data-filter-base-component.js +16 -6
  66. package/esm/component/data-zoom/data-filter-base-component.js.map +1 -1
  67. package/esm/component/data-zoom/interface.d.ts +1 -0
  68. package/esm/component/data-zoom/interface.js.map +1 -1
  69. package/esm/component/marker/mark-point/cartesian-mark-point.js +2 -2
  70. package/esm/component/marker/mark-point/cartesian-mark-point.js.map +1 -1
  71. package/esm/constant/attribute.js +1 -2
  72. package/esm/constant/label.js +2 -1
  73. package/esm/constant/waterfall.js +1 -2
  74. package/esm/constant/word-cloud.js +1 -1
  75. package/esm/core/expression-function.js +2 -1
  76. package/esm/core/factory.d.ts +4 -0
  77. package/esm/core/factory.js +8 -1
  78. package/esm/core/factory.js.map +1 -1
  79. package/esm/core/index.d.ts +1 -1
  80. package/esm/core/index.js +1 -1
  81. package/esm/core/index.js.map +1 -1
  82. package/esm/core/interface.d.ts +2 -0
  83. package/esm/core/interface.js.map +1 -1
  84. package/esm/core/vchart.d.ts +1 -0
  85. package/esm/core/vchart.js +6 -1
  86. package/esm/core/vchart.js.map +1 -1
  87. package/esm/plugin/components/tooltip-handler/dom-tooltip-handler.d.ts +1 -1
  88. package/esm/plugin/components/tooltip-handler/dom-tooltip-handler.js +17 -17
  89. package/esm/plugin/components/tooltip-handler/dom-tooltip-handler.js.map +1 -1
  90. package/esm/plugin/vchart/index.d.ts +2 -0
  91. package/esm/plugin/vchart/index.js +4 -0
  92. package/esm/plugin/vchart/index.js.map +1 -0
  93. package/esm/plugin/vchart/interface.d.ts +16 -0
  94. package/esm/plugin/vchart/interface.js +2 -0
  95. package/esm/plugin/vchart/interface.js.map +1 -0
  96. package/esm/plugin/vchart/plugin-service.d.ts +9 -0
  97. package/esm/plugin/vchart/plugin-service.js +16 -0
  98. package/esm/plugin/vchart/plugin-service.js.map +1 -0
  99. package/esm/plugin/vchart/register.d.ts +2 -0
  100. package/esm/plugin/vchart/register.js +6 -0
  101. package/esm/plugin/vchart/register.js.map +1 -0
  102. package/esm/plugin/vchart/rotate/index.d.ts +1 -0
  103. package/esm/plugin/vchart/rotate/index.js +2 -0
  104. package/esm/plugin/vchart/rotate/index.js.map +1 -0
  105. package/esm/plugin/vchart/rotate/rotate.d.ts +18 -0
  106. package/esm/plugin/vchart/rotate/rotate.js +62 -0
  107. package/esm/plugin/vchart/rotate/rotate.js.map +1 -0
  108. package/esm/series/word-cloud/base.js +4 -0
  109. package/esm/series/word-cloud/base.js.map +1 -1
  110. package/esm/typings/spec/common.d.ts +1 -0
  111. package/esm/typings/spec/common.js.map +1 -1
  112. package/esm/util/style.js +3 -2
  113. package/esm/util/style.js.map +1 -1
  114. package/package.json +8 -8
package/build/index.es.js CHANGED
@@ -9493,7 +9493,8 @@ const DefaultRectAttribute = Object.assign(Object.assign({}, DefaultAttribute),
9493
9493
  y1: 0,
9494
9494
  strokeBoundsBuffer: 0,
9495
9495
  cornerRadius: 0,
9496
- cornerType: "round"
9496
+ cornerType: "round",
9497
+ drawStrokeWhenZeroWH: !1
9497
9498
  });
9498
9499
  Object.assign(Object.assign({}, DefaultAttribute), {
9499
9500
  width: 0,
@@ -9502,7 +9503,8 @@ Object.assign(Object.assign({}, DefaultAttribute), {
9502
9503
  y1: 0,
9503
9504
  cornerRadius: 0,
9504
9505
  length: 0,
9505
- cornerType: "round"
9506
+ cornerType: "round",
9507
+ drawStrokeWhenZeroWH: !1
9506
9508
  });
9507
9509
  const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
9508
9510
  symbolType: "circle",
@@ -9729,6 +9731,34 @@ class GradientParser {
9729
9731
  }
9730
9732
  return c;
9731
9733
  }
9734
+ static processColorStops(colorStops) {
9735
+ if (!colorStops || 0 === colorStops.length) return [];
9736
+ if (colorStops.some(item => item.length)) {
9737
+ const stops = colorStops.map(item => ({
9738
+ color: item.value,
9739
+ offset: item.length ? parseFloat(item.length.value) / 100 : -1
9740
+ }));
9741
+ stops[0].offset < 0 && (stops[0].offset = 0), stops[stops.length - 1].offset < 0 && (stops[stops.length - 1].offset = 1);
9742
+ for (let i = 1; i < stops.length - 1; i++) if (stops[i].offset < 0) {
9743
+ const prevWithOffsetIdx = i - 1;
9744
+ let nextWithOffsetIdx = i + 1;
9745
+ for (; nextWithOffsetIdx < stops.length && stops[nextWithOffsetIdx].offset < 0;) nextWithOffsetIdx++;
9746
+ const startOffset = stops[prevWithOffsetIdx].offset,
9747
+ endOffset = stops[nextWithOffsetIdx].offset,
9748
+ unspecCount = nextWithOffsetIdx - prevWithOffsetIdx;
9749
+ for (let j = 1; j < unspecCount; j++) stops[prevWithOffsetIdx + j].offset = startOffset + (endOffset - startOffset) * j / unspecCount;
9750
+ i = nextWithOffsetIdx - 1;
9751
+ }
9752
+ return stops;
9753
+ }
9754
+ return colorStops.map((item, index) => {
9755
+ const offset = colorStops.length > 1 ? index / (colorStops.length - 1) : 0;
9756
+ return {
9757
+ color: item.value,
9758
+ offset: offset
9759
+ };
9760
+ });
9761
+ }
9732
9762
  static ParseConic(datum) {
9733
9763
  const {
9734
9764
  orientation: orientation,
@@ -9742,10 +9772,7 @@ class GradientParser {
9742
9772
  y: .5,
9743
9773
  startAngle: sa,
9744
9774
  endAngle: sa + pi2,
9745
- stops: colorStops.map(item => ({
9746
- color: item.value,
9747
- offset: parseFloat(item.length.value) / 100
9748
- }))
9775
+ stops: GradientParser.processColorStops(colorStops)
9749
9776
  };
9750
9777
  }
9751
9778
  static ParseRadial(datum) {
@@ -9760,10 +9787,7 @@ class GradientParser {
9760
9787
  y1: .5,
9761
9788
  r0: 0,
9762
9789
  r1: 1,
9763
- stops: colorStops.map(item => ({
9764
- color: item.value,
9765
- offset: parseFloat(item.length.value) / 100
9766
- }))
9790
+ stops: GradientParser.processColorStops(colorStops)
9767
9791
  };
9768
9792
  }
9769
9793
  static ParseLinear(datum) {
@@ -9785,10 +9809,7 @@ class GradientParser {
9785
9809
  y0: y0,
9786
9810
  x1: x1,
9787
9811
  y1: y1,
9788
- stops: colorStops.map(item => ({
9789
- color: item.value,
9790
- offset: parseFloat(item.length.value) / 100
9791
- }))
9812
+ stops: GradientParser.processColorStops(colorStops)
9792
9813
  };
9793
9814
  }
9794
9815
  }
@@ -14175,7 +14196,7 @@ class Graphic extends Node {
14175
14196
  });
14176
14197
  }
14177
14198
  setAttributes(params, forceUpdateTag = !1, context) {
14178
- (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);
14199
+ 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));
14179
14200
  }
14180
14201
  _setAttributes(params, forceUpdateTag = !1, context) {
14181
14202
  const keys = Object.keys(params);
@@ -15000,8 +15021,8 @@ function rectFillVisible(opacity, fillOpacity, width, height, fill) {
15000
15021
  function strokeVisible(opacity, strokeOpacity) {
15001
15022
  return opacity * strokeOpacity > 0;
15002
15023
  }
15003
- function rectStrokeVisible(opacity, strokeOpacity, width, height) {
15004
- return opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
15024
+ function rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH) {
15025
+ return drawStrokeWhenZeroWH ? opacity * strokeOpacity > 0 : opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
15005
15026
  }
15006
15027
  function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
15007
15028
  const x10 = x1 - x0,
@@ -16371,14 +16392,10 @@ class Glyph extends Graphic {
16371
16392
  attrs && (Object.assign(stateAttrs, attrs.attributes), (null === (_a = attrs.subAttributes) || void 0 === _a ? void 0 : _a.length) && subAttrs.forEach((subAttrs, index) => {
16372
16393
  Object.assign(subAttrs, attrs.subAttributes[index]);
16373
16394
  }));
16374
- }), this.subGraphic.forEach((graphic, index) => {
16375
- graphic.updateNormalAttrs(subAttrs[index]), graphic.applyStateAttrs(subAttrs[index], states, hasAnimation);
16376
16395
  }), this.updateNormalAttrs(stateAttrs), this.currentStates = states, this.applyStateAttrs(stateAttrs, states, hasAnimation);
16377
16396
  }
16378
16397
  clearStates(hasAnimation) {
16379
- this.stopStateAnimates(), this.hasState() && this.normalAttrs ? (this.currentStates = [], this.subGraphic.forEach(graphic => {
16380
- graphic.applyStateAttrs(graphic.normalAttrs, this.currentStates, hasAnimation, !0), graphic.normalAttrs = null;
16381
- }), this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
16398
+ this.stopStateAnimates(), this.hasState() && this.normalAttrs ? (this.currentStates = [], this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
16382
16399
  }
16383
16400
  clone() {
16384
16401
  const glyph = new Glyph(Object.assign({}, this.attribute));
@@ -17137,7 +17154,7 @@ class RichText extends Graphic {
17137
17154
  case "right":
17138
17155
  deltaX = -aabbBounds.width();
17139
17156
  }
17140
- 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;
17157
+ 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;
17141
17158
  }
17142
17159
  needUpdateTags(keys) {
17143
17160
  return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
@@ -19637,7 +19654,8 @@ let DefaultCanvasRectRender = class extends BaseRender {
19637
19654
  y1: y1,
19638
19655
  x: originX = rectAttribute.x,
19639
19656
  y: originY = rectAttribute.y,
19640
- fillStrokeOrder = rectAttribute.fillStrokeOrder
19657
+ fillStrokeOrder = rectAttribute.fillStrokeOrder,
19658
+ drawStrokeWhenZeroWH = rectAttribute.drawStrokeWhenZeroWH
19641
19659
  } = rect.attribute;
19642
19660
  let {
19643
19661
  width: width,
@@ -19645,7 +19663,7 @@ let DefaultCanvasRectRender = class extends BaseRender {
19645
19663
  } = rect.attribute;
19646
19664
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
19647
19665
  const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
19648
- sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
19666
+ sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH),
19649
19667
  doFill = runFill(fill, background),
19650
19668
  doStroke = runStroke(stroke, lineWidth);
19651
19669
  if (!rect.valid || !visible) return;
@@ -21703,13 +21721,13 @@ class Stage extends Group$1 {
21703
21721
  this._skipRender > 1 && this.renderNextFrame(), this._skipRender = 0;
21704
21722
  } else this._skipRender = 1;
21705
21723
  }, this.beforeRender = stage => {
21706
- this._beforeRender && this._beforeRender(stage);
21724
+ this._beforeRenderList.forEach(cb => cb(stage));
21707
21725
  }, this.afterClearScreen = drawParams => {
21708
21726
  this._afterClearScreen && this._afterClearScreen(drawParams);
21709
21727
  }, this.afterClearRect = drawParams => {
21710
21728
  this._afterClearRect && this._afterClearRect(drawParams);
21711
21729
  }, this.afterRender = stage => {
21712
- this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
21730
+ this.renderCount++, this._afterRenderList.forEach(cb => cb(stage)), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
21713
21731
  }, this.afterTickCb = () => {
21714
21732
  this.tickedBeforeRender = !0, "rendering" !== this.state && this.renderNextFrame();
21715
21733
  }, this.params = params, this.theme = new Theme(), this.hooks = {
@@ -21717,7 +21735,7 @@ class Stage extends Group$1 {
21717
21735
  afterRender: new SyncHook(["stage"]),
21718
21736
  afterClearScreen: new SyncHook(["stage"]),
21719
21737
  afterClearRect: new SyncHook(["stage"])
21720
- }, 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({
21738
+ }, 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({
21721
21739
  width: params.width,
21722
21740
  height: params.height,
21723
21741
  viewBox: params.viewBox,
@@ -21728,7 +21746,7 @@ class Stage extends Group$1 {
21728
21746
  canvas: params.canvas
21729
21747
  }), 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, {
21730
21748
  main: !0
21731
- })), 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 = {
21749
+ })), 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 = {
21732
21750
  tickRenderMode: "effect"
21733
21751
  }), this.optmize(params.optimize), params.background && isString$1(this._background) && this._background.includes("/") && this.setAttributes({
21734
21752
  background: this._background
@@ -21843,10 +21861,16 @@ class Stage extends Group$1 {
21843
21861
  options.enableView3dTransform && this.enableView3dTransform();
21844
21862
  }
21845
21863
  setBeforeRender(cb) {
21846
- this._beforeRender = cb;
21864
+ this._beforeRenderList.push(cb);
21865
+ }
21866
+ removeBeforeRender(cb) {
21867
+ this._beforeRenderList = this._beforeRenderList.filter(c => c !== cb);
21847
21868
  }
21848
21869
  setAfterRender(cb) {
21849
- this._afterRender = cb;
21870
+ this._afterRenderList.push(cb);
21871
+ }
21872
+ removeAfterRender(cb) {
21873
+ this._afterRenderList = this._afterRenderList.filter(c => c !== cb);
21850
21874
  }
21851
21875
  afterNextRender(cb) {
21852
21876
  this._afterNextRenderCbs || (this._afterNextRenderCbs = []), this._afterNextRenderCbs.push(cb);
@@ -31713,6 +31737,7 @@ class Step {
31713
31737
  return this.getEndProps();
31714
31738
  }
31715
31739
  stop() {}
31740
+ release() {}
31716
31741
  }
31717
31742
  class WaitStep extends Step {
31718
31743
  constructor(type, props, duration, easing) {
@@ -31720,8 +31745,6 @@ class WaitStep extends Step {
31720
31745
  }
31721
31746
  onStart() {
31722
31747
  super.onStart();
31723
- }
31724
- onFirstRun() {
31725
31748
  const fromProps = this.getFromProps();
31726
31749
  this.target.setAttributes(fromProps);
31727
31750
  }
@@ -31930,7 +31953,9 @@ class Animate {
31930
31953
  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));
31931
31954
  }
31932
31955
  release() {
31933
- this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [];
31956
+ this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [], this.forEachStep(step => {
31957
+ step.release();
31958
+ });
31934
31959
  }
31935
31960
  getDuration() {
31936
31961
  return this._duration;
@@ -32004,6 +32029,10 @@ class Animate {
32004
32029
  getLoop() {
32005
32030
  return this._loopCount;
32006
32031
  }
32032
+ forEachStep(cb) {
32033
+ let step = this._firstStep;
32034
+ for (; step;) cb(step), step = step.next;
32035
+ }
32007
32036
  }
32008
32037
 
32009
32038
  const performanceRAF = new PerformanceRAF();
@@ -32283,6 +32312,9 @@ class AnimateExecutor {
32283
32312
  constructor(target) {
32284
32313
  this._animates = [], this._startCallbacks = [], this._endCallbacks = [], this._started = !1, this._activeCount = 0, this._target = target;
32285
32314
  }
32315
+ get started() {
32316
+ return this._started;
32317
+ }
32286
32318
  onStart(cb) {
32287
32319
  cb ? (this._startCallbacks.push(cb), this._started && this._activeCount > 0 && cb()) : this._startCallbacks.forEach(cb => {
32288
32320
  cb();
@@ -32423,14 +32455,14 @@ class AnimateExecutor {
32423
32455
  return delayAfterValue > 0 && (totalDelay += delayAfterValue), totalDelay > 0 && animate.wait(totalDelay), loop && loop > 0 && animate.loop(loop), bounce && animate.bounce(!0), animate;
32424
32456
  }
32425
32457
  _handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic) {
32426
- var _a, _b, _c, _d;
32458
+ var _a, _b, _c, _d, _e, _f;
32427
32459
  if (custom && customType) {
32428
32460
  const customParams = Object.assign({
32429
- width: graphic.stage.width,
32430
- height: graphic.stage.height,
32461
+ width: (null === (_a = graphic.stage) || void 0 === _a ? void 0 : _a.width) || 0,
32462
+ height: (null === (_b = graphic.stage) || void 0 === _b ? void 0 : _b.height) || 0,
32431
32463
  group: this._target.parent
32432
32464
  }, this.resolveValue(customParameters, graphic)),
32433
- 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;
32465
+ 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;
32434
32466
  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);
32435
32467
  } else "to" === type ? animate.to(props, duration, easing) : "from" === type && animate.from(props, duration, easing);
32436
32468
  }
@@ -32650,7 +32682,7 @@ class AnimationStateManager {
32650
32682
  reApplyState(state) {
32651
32683
  var _a;
32652
32684
  const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find(stateInfo => stateInfo.state === state);
32653
- if (stateInfo) {
32685
+ if (stateInfo && stateInfo.executor.started) {
32654
32686
  const stateList = this.stateList.slice();
32655
32687
  stateInfo.executor.stop(), this.stateList = stateList, stateInfo.executor.execute(stateInfo.animationConfig);
32656
32688
  }
@@ -32793,6 +32825,45 @@ class AComponentAnimate extends ACustomAnimate {
32793
32825
  this._animator && this._animator.stop();
32794
32826
  }
32795
32827
  }
32828
+ class AStageAnimate extends ACustomAnimate {
32829
+ constructor(customFrom, customTo, duration, easing, params) {
32830
+ super(customFrom, customTo, duration, easing, params), this.willCallBeforeStageRender = !0, this.willCallAfterStageRender = !0, this._beforeStageRender = () => {
32831
+ if (!this.willCallBeforeStageRender) return;
32832
+ this.willCallBeforeStageRender = !1;
32833
+ const stage = this.target.stage,
32834
+ canvas = stage.window.getContext().canvas.nativeCanvas,
32835
+ outputCanvas = this.beforeStageRender(stage, canvas);
32836
+ outputCanvas && this.renderToStage(stage, outputCanvas);
32837
+ }, this._afterStageRender = () => {
32838
+ if (!this.willCallAfterStageRender) return;
32839
+ this.willCallAfterStageRender = !1;
32840
+ const stage = this.target.stage,
32841
+ canvas = stage.window.getContext().canvas.nativeCanvas,
32842
+ outputCanvas = this.afterStageRender(stage, canvas);
32843
+ outputCanvas && this.renderToStage(stage, outputCanvas);
32844
+ }, this.props = {};
32845
+ }
32846
+ beforeStageRender(stage, canvas) {
32847
+ return !1;
32848
+ }
32849
+ afterStageRender(stage, canvas) {
32850
+ return !1;
32851
+ }
32852
+ onFirstRun() {
32853
+ super.onFirstRun(), this.target.stage.setBeforeRender(this._beforeStageRender), this.target.stage.setAfterRender(this._afterStageRender), this.target.stage.disableDirtyBounds();
32854
+ }
32855
+ stop() {
32856
+ super.stop(), this.target.stage.removeBeforeRender(this._beforeStageRender), this.target.stage.removeAfterRender(this._afterStageRender);
32857
+ }
32858
+ onUpdate(end, ratio, out) {
32859
+ super.onUpdate(end, ratio, out), this.willCallBeforeStageRender = !0, this.willCallAfterStageRender = !0;
32860
+ }
32861
+ renderToStage(stage, canvas) {
32862
+ const stageCanvas = stage.window.getContext().canvas.nativeCanvas,
32863
+ ctx = stageCanvas.getContext("2d");
32864
+ return !!ctx && (ctx.clearRect(0, 0, stageCanvas.width, stageCanvas.height), ctx.drawImage(canvas, 0, 0), stageCanvas);
32865
+ }
32866
+ }
32796
32867
 
32797
32868
  class ComponentAnimator {
32798
32869
  constructor(component) {
@@ -33694,7 +33765,7 @@ class GrowAngleBase extends ACustomAnimate {
33694
33765
  }
33695
33766
  class GrowAngleIn extends GrowAngleBase {
33696
33767
  onBind() {
33697
- var _a, _b;
33768
+ var _a, _b, _c;
33698
33769
  super.onBind();
33699
33770
  const {
33700
33771
  from: from,
@@ -33703,7 +33774,7 @@ class GrowAngleIn extends GrowAngleBase {
33703
33774
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
33704
33775
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
33705
33776
  const finalAttribute = this.target.getFinalAttribute();
33706
- finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs), this.determineUpdateFunction();
33777
+ finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs), this.determineUpdateFunction();
33707
33778
  }
33708
33779
  }
33709
33780
  class GrowAngleOut extends GrowAngleBase {
@@ -34311,7 +34382,7 @@ class GrowPointsBase extends ACustomAnimate {
34311
34382
  }
34312
34383
  class GrowRadiusIn extends GrowPointsBase {
34313
34384
  onBind() {
34314
- var _a, _b;
34385
+ var _a, _b, _c;
34315
34386
  super.onBind();
34316
34387
  const {
34317
34388
  from: from,
@@ -34320,7 +34391,7 @@ class GrowRadiusIn extends GrowPointsBase {
34320
34391
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
34321
34392
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
34322
34393
  const finalAttribute = this.target.getFinalAttribute();
34323
- finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
34394
+ finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
34324
34395
  }
34325
34396
  }
34326
34397
  class GrowRadiusOut extends GrowPointsBase {
@@ -34435,7 +34506,7 @@ class GrowWidthIn extends ACustomAnimate {
34435
34506
  super(from, to, duration, easing, params);
34436
34507
  }
34437
34508
  onBind() {
34438
- var _a, _b;
34509
+ var _a, _b, _c;
34439
34510
  super.onBind();
34440
34511
  const {
34441
34512
  from: from,
@@ -34444,7 +34515,7 @@ class GrowWidthIn extends ACustomAnimate {
34444
34515
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
34445
34516
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
34446
34517
  const finalAttribute = this.target.getFinalAttribute();
34447
- finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
34518
+ finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
34448
34519
  }
34449
34520
  onEnd(cb) {
34450
34521
  super.onEnd(cb);
@@ -36228,8 +36299,1277 @@ class StreamLight extends ACustomAnimate {
36228
36299
  }
36229
36300
  }
36230
36301
 
36302
+ class DisappearAnimateBase extends AStageAnimate {
36303
+ constructor(from, to, duration, easing, params) {
36304
+ super(from, to, duration, easing, params), this.webglCanvas = null, this.gl = null, this.program = null, this.currentAnimationRatio = 0, this.animationTime = 0;
36305
+ }
36306
+ onUpdate(end, ratio, out) {
36307
+ super.onUpdate(end, ratio, out), this.currentAnimationRatio = ratio, this.animationTime = ratio * Math.PI * 2;
36308
+ }
36309
+ getAnimationTime() {
36310
+ return this.currentAnimationRatio > 0 ? this.animationTime : Date.now() / 1e3;
36311
+ }
36312
+ getDurationFromParent() {
36313
+ return this.duration || 1e3;
36314
+ }
36315
+ initWebGL(canvas) {
36316
+ try {
36317
+ if (this.webglCanvas = vglobal.createCanvas({
36318
+ width: canvas.width,
36319
+ height: canvas.height,
36320
+ dpr: vglobal.devicePixelRatio
36321
+ }), !this.webglCanvas) return console.warn("WebGL canvas creation failed"), !1;
36322
+ this.webglCanvas.style.width = canvas.style.width || `${canvas.width}px`, this.webglCanvas.style.height = canvas.style.height || `${canvas.height}px`;
36323
+ let glContext = null;
36324
+ try {
36325
+ glContext = this.webglCanvas.getContext("webgl"), glContext || (glContext = this.webglCanvas.getContext("experimental-webgl"));
36326
+ } catch (e) {
36327
+ console.warn("Failed to get WebGL context:", e);
36328
+ }
36329
+ if (this.gl = glContext, !this.gl) return console.warn("WebGL not supported"), !1;
36330
+ const shaders = this.getShaderSources();
36331
+ return this.program = this.createShaderProgram(shaders.vertex, shaders.fragment), null !== this.program;
36332
+ } catch (error) {
36333
+ return console.warn("Failed to initialize WebGL:", error), !1;
36334
+ }
36335
+ }
36336
+ createShaderProgram(vertexSource, fragmentSource) {
36337
+ if (!this.gl) return null;
36338
+ const vertexShader = this.createShader(this.gl.VERTEX_SHADER, vertexSource),
36339
+ fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, fragmentSource);
36340
+ if (!vertexShader || !fragmentShader) return null;
36341
+ const program = this.gl.createProgram();
36342
+ 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;
36343
+ }
36344
+ createShader(type, source) {
36345
+ if (!this.gl) return null;
36346
+ const shader = this.gl.createShader(type);
36347
+ 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;
36348
+ }
36349
+ setupWebGLState(canvas) {
36350
+ 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));
36351
+ }
36352
+ createFullScreenQuad() {
36353
+ if (!this.gl) return null;
36354
+ const vertices = new Float32Array([-1, -1, 0, 1, 1, -1, 1, 1, -1, 1, 0, 0, 1, 1, 1, 0]),
36355
+ vertexBuffer = this.gl.createBuffer();
36356
+ return this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertexBuffer), this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW), vertexBuffer;
36357
+ }
36358
+ createTextureFromCanvas(canvas) {
36359
+ if (!this.gl) return null;
36360
+ const texture = this.gl.createTexture();
36361
+ 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;
36362
+ }
36363
+ setupVertexAttributes() {
36364
+ if (!this.gl || !this.program) return;
36365
+ const positionLocation = this.gl.getAttribLocation(this.program, "a_position"),
36366
+ texCoordLocation = this.gl.getAttribLocation(this.program, "a_texCoord");
36367
+ 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);
36368
+ }
36369
+ createOutputCanvas(canvas) {
36370
+ const outputCanvas = vglobal.createCanvas({
36371
+ width: canvas.width,
36372
+ height: canvas.height,
36373
+ dpr: vglobal.devicePixelRatio
36374
+ }),
36375
+ ctx = outputCanvas.getContext("2d");
36376
+ return ctx ? (ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.drawImage(canvas, 0, 0), {
36377
+ canvas: outputCanvas,
36378
+ ctx: ctx
36379
+ }) : null;
36380
+ }
36381
+ getShaderSources() {
36382
+ return null;
36383
+ }
36384
+ applyWebGLEffect(canvas) {
36385
+ return null;
36386
+ }
36387
+ applyCanvas2DEffect(canvas) {
36388
+ return null;
36389
+ }
36390
+ supportsWebGL() {
36391
+ return null !== this.getShaderSources();
36392
+ }
36393
+ supportsCanvas2D() {
36394
+ return this.applyCanvas2DEffect !== DisappearAnimateBase.prototype.applyCanvas2DEffect;
36395
+ }
36396
+ release() {
36397
+ 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;
36398
+ }
36399
+ afterStageRender(stage, canvas) {
36400
+ let result = null;
36401
+ if (this.supportsWebGL() && (this.gl || this.initWebGL(canvas) || console.warn("WebGL初始化失败,尝试Canvas 2D回退"), this.gl)) {
36402
+ if (result = this.applyWebGLEffect(canvas), result) return result;
36403
+ console.warn("WebGL特效执行失败,尝试Canvas 2D回退");
36404
+ }
36405
+ if (this.supportsCanvas2D()) {
36406
+ if (result = this.applyCanvas2DEffect(canvas), result) return result;
36407
+ console.warn("Canvas 2D特效执行失败");
36408
+ }
36409
+ return this.supportsWebGL() || this.supportsCanvas2D() || console.error(`特效类 ${this.constructor.name} 未实现任何渲染方法。请实现 applyWebGLEffect 或 applyCanvas2DEffect 方法。`), canvas;
36410
+ }
36411
+ }
36412
+
36413
+ class Canvas2DEffectBase extends DisappearAnimateBase {
36414
+ constructor(from, to, duration, easing, params) {
36415
+ super(from, to, duration, easing, params);
36416
+ }
36417
+ getShaderSources() {
36418
+ return null;
36419
+ }
36420
+ applyWebGLEffect(canvas) {
36421
+ return null;
36422
+ }
36423
+ }
36424
+ class HybridEffectBase extends DisappearAnimateBase {
36425
+ constructor(from, to, duration, easing, params) {
36426
+ super(from, to, duration, easing, params);
36427
+ }
36428
+ getShaderSources() {
36429
+ return null;
36430
+ }
36431
+ applyWebGLEffect(canvas) {
36432
+ return null;
36433
+ }
36434
+ applyCanvas2DEffect(canvas) {
36435
+ return null;
36436
+ }
36437
+ supportsWebGL() {
36438
+ return this.getShaderSources !== HybridEffectBase.prototype.getShaderSources && null !== this.getShaderSources();
36439
+ }
36440
+ supportsCanvas2D() {
36441
+ return this.applyCanvas2DEffect !== HybridEffectBase.prototype.applyCanvas2DEffect;
36442
+ }
36443
+ afterStageRender(stage, canvas) {
36444
+ var _a, _b;
36445
+ let result = null;
36446
+ if (!1 !== (null === (_b = null === (_a = this.params) || void 0 === _a ? void 0 : _a.options) || void 0 === _b ? void 0 : _b.useWebGL)) {
36447
+ if (this.supportsWebGL() && (this.gl || this.initWebGL(canvas) || console.warn("WebGL初始化失败,尝试Canvas 2D回退"), this.gl)) {
36448
+ if (result = this.applyWebGLEffect(canvas), result) return result;
36449
+ console.warn("WebGL特效执行失败,尝试Canvas 2D回退");
36450
+ }
36451
+ if (this.supportsCanvas2D()) {
36452
+ if (result = this.applyCanvas2DEffect(canvas), result) return result;
36453
+ console.warn("Canvas 2D特效执行失败");
36454
+ }
36455
+ } else if (this.supportsCanvas2D()) {
36456
+ if (result = this.applyCanvas2DEffect(canvas), result) return result;
36457
+ console.warn("Canvas 2D特效执行失败");
36458
+ } else console.warn(`${this.constructor.name}: useWebGL=false 但未实现Canvas 2D方法`);
36459
+ return this.supportsWebGL() || this.supportsCanvas2D() || console.error(`特效类 ${this.constructor.name} 未实现任何渲染方法。请实现 applyWebGLEffect 或 applyCanvas2DEffect 方法。`), canvas;
36460
+ }
36461
+ }
36462
+
36463
+ class ImageProcessUtils {
36464
+ static createTempCanvas(width, height, dpr) {
36465
+ return vglobal.createCanvas({
36466
+ width: width,
36467
+ height: height,
36468
+ dpr: dpr || vglobal.devicePixelRatio
36469
+ });
36470
+ }
36471
+ static cloneImageData(imageData) {
36472
+ const clonedData = new Uint8ClampedArray(imageData.data);
36473
+ return new ImageData(clonedData, imageData.width, imageData.height);
36474
+ }
36475
+ static lerp(start, end, t) {
36476
+ return start * (1 - t) + end * t;
36477
+ }
36478
+ static smoothstep(edge0, edge1, x) {
36479
+ const t = Math.max(0, Math.min(1, (x - edge0) / (edge1 - edge0)));
36480
+ return t * t * (3 - 2 * t);
36481
+ }
36482
+ static distance(x1, y1, x2, y2) {
36483
+ const dx = x2 - x1,
36484
+ dy = y2 - y1;
36485
+ return Math.sqrt(dx * dx + dy * dy);
36486
+ }
36487
+ static normalizeAngle(angle) {
36488
+ return (angle + Math.PI) / (2 * Math.PI);
36489
+ }
36490
+ static pixelNoise(x, y, pixelSize) {
36491
+ if (pixelSize <= 0) return 0;
36492
+ const gridX = Math.floor(x / pixelSize) * pixelSize,
36493
+ gridY = Math.floor(y / pixelSize) * pixelSize,
36494
+ n = 43758.5453 * Math.sin(12.9898 * gridX + 78.233 * gridY);
36495
+ return n - Math.floor(n);
36496
+ }
36497
+ static generateNoiseTexture(width, height) {
36498
+ const data = new Uint8Array(width * height);
36499
+ for (let i = 0; i < data.length; i++) data[i] = Math.floor(256 * Math.random());
36500
+ return data;
36501
+ }
36502
+ static applyCSSFilter(canvas, filter) {
36503
+ const outputCanvas = this.createTempCanvas(canvas.width, canvas.height),
36504
+ ctx = outputCanvas.getContext("2d");
36505
+ return ctx ? (ctx.filter = filter, ctx.drawImage(canvas, 0, 0), ctx.filter = "none", outputCanvas) : canvas;
36506
+ }
36507
+ static extractChannel(imageData, channelIndex) {
36508
+ const {
36509
+ data: data,
36510
+ width: width,
36511
+ height: height
36512
+ } = imageData,
36513
+ channelData = new Uint8ClampedArray(data.length);
36514
+ 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]);
36515
+ return new ImageData(channelData, width, height);
36516
+ }
36517
+ static blendImageData(imageData1, imageData2, ratio) {
36518
+ const {
36519
+ data: data1,
36520
+ width: width,
36521
+ height: height
36522
+ } = imageData1,
36523
+ {
36524
+ data: data2
36525
+ } = imageData2,
36526
+ result = new Uint8ClampedArray(data1.length);
36527
+ 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));
36528
+ return new ImageData(result, width, height);
36529
+ }
36530
+ static getLuminance(r, g, b) {
36531
+ return .299 * r + .587 * g + .114 * b;
36532
+ }
36533
+ static applySepiaToPixel(r, g, b) {
36534
+ 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)];
36535
+ }
36536
+ static calculateDynamicStrength(baseStrength, animationTime) {
36537
+ return baseStrength * (animationTime / (2 * Math.PI));
36538
+ }
36539
+ }
36540
+ class ShaderLibrary {}
36541
+ 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 ";
36542
+
36543
+ class Dissolve extends HybridEffectBase {
36544
+ constructor(from, to, duration, easing, params) {
36545
+ var _a, _b, _c, _d;
36546
+ super(from, to, duration, easing, params), this.noiseData = null;
36547
+ const rawNoiseScale = null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.noiseScale,
36548
+ clampedNoiseScale = void 0 !== rawNoiseScale ? Math.max(0, Math.floor(rawNoiseScale)) : 8;
36549
+ this.dissolveConfig = {
36550
+ dissolveType: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.dissolveType) || "outward",
36551
+ useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL,
36552
+ noiseScale: clampedNoiseScale,
36553
+ fadeEdge: void 0 === (null === (_d = null == params ? void 0 : params.options) || void 0 === _d ? void 0 : _d.fadeEdge) || params.options.fadeEdge
36554
+ };
36555
+ }
36556
+ getShaderSources() {
36557
+ return {
36558
+ vertex: ShaderLibrary.STANDARD_VERTEX_SHADER,
36559
+ 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 `
36560
+ };
36561
+ }
36562
+ applyWebGLEffect(canvas) {
36563
+ if (!this.gl || !this.program || !this.webglCanvas) return canvas;
36564
+ this.setupWebGLState(canvas);
36565
+ const texture = this.createTextureFromCanvas(canvas);
36566
+ if (!texture) return canvas;
36567
+ this.noiseData || (this.noiseData = ImageProcessUtils.generateNoiseTexture(256, 256));
36568
+ const noiseTexture = this.gl.createTexture();
36569
+ 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);
36570
+ const vertexBuffer = this.createFullScreenQuad();
36571
+ 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;
36572
+ }
36573
+ setUniforms() {
36574
+ if (!this.gl || !this.program || !this.webglCanvas) return;
36575
+ const textureLocation = this.gl.getUniformLocation(this.program, "u_texture"),
36576
+ noiseTextureLocation = this.gl.getUniformLocation(this.program, "u_noiseTexture"),
36577
+ timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
36578
+ dissolveTypeLocation = this.gl.getUniformLocation(this.program, "u_dissolveType"),
36579
+ resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution"),
36580
+ noiseScaleLocation = this.gl.getUniformLocation(this.program, "u_noiseScale"),
36581
+ fadeEdgeLocation = this.gl.getUniformLocation(this.program, "u_fadeEdge");
36582
+ 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);
36583
+ this.gl.uniform1i(dissolveTypeLocation, {
36584
+ outward: 0,
36585
+ inward: 1,
36586
+ radial: 2,
36587
+ leftToRight: 3,
36588
+ rightToLeft: 4,
36589
+ topToBottom: 5,
36590
+ bottomToTop: 6
36591
+ }[this.dissolveConfig.dissolveType] || 0);
36592
+ }
36593
+ applyCanvas2DEffect(canvas) {
36594
+ const outputCanvas = this.createOutputCanvas(canvas);
36595
+ if (!outputCanvas) return canvas;
36596
+ const {
36597
+ canvas: outputCanvasElement,
36598
+ ctx: ctx
36599
+ } = outputCanvas,
36600
+ imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
36601
+ progress = this.currentAnimationRatio;
36602
+ let dissolvedImageData;
36603
+ switch (this.dissolveConfig.dissolveType) {
36604
+ case "outward":
36605
+ dissolvedImageData = this.applyOutwardDissolve(imageData, progress);
36606
+ break;
36607
+ case "inward":
36608
+ dissolvedImageData = this.applyInwardDissolve(imageData, progress);
36609
+ break;
36610
+ case "radial":
36611
+ dissolvedImageData = this.applyRadialDissolve(imageData, progress);
36612
+ break;
36613
+ case "leftToRight":
36614
+ dissolvedImageData = this.applyLeftToRightDissolve(imageData, progress);
36615
+ break;
36616
+ case "rightToLeft":
36617
+ dissolvedImageData = this.applyRightToLeftDissolve(imageData, progress);
36618
+ break;
36619
+ case "topToBottom":
36620
+ dissolvedImageData = this.applyTopToBottomDissolve(imageData, progress);
36621
+ break;
36622
+ case "bottomToTop":
36623
+ dissolvedImageData = this.applyBottomToTopDissolve(imageData, progress);
36624
+ break;
36625
+ default:
36626
+ dissolvedImageData = imageData;
36627
+ }
36628
+ return ctx.putImageData(dissolvedImageData, 0, 0), outputCanvasElement;
36629
+ }
36630
+ applyOutwardDissolve(imageData, progress) {
36631
+ const {
36632
+ data: data,
36633
+ width: width,
36634
+ height: height
36635
+ } = imageData,
36636
+ result = new Uint8ClampedArray(data.length);
36637
+ result.set(data);
36638
+ const centerX = width / 2,
36639
+ centerY = height / 2,
36640
+ maxDist = Math.sqrt(centerX * centerX + centerY * centerY),
36641
+ pixelSize = this.dissolveConfig.noiseScale;
36642
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36643
+ const dx = x - centerX,
36644
+ dy = y - centerY,
36645
+ normalizedDist = Math.sqrt(dx * dx + dy * dy) / maxDist;
36646
+ let dissolveThreshold = 1.2 - 1.4 * progress,
36647
+ alpha = 1;
36648
+ if (pixelSize > 0) {
36649
+ dissolveThreshold += .4 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedDist > dissolveThreshold ? 0 : 1;
36650
+ } else if (this.dissolveConfig.fadeEdge) {
36651
+ const fadeStart = dissolveThreshold - .15;
36652
+ alpha = normalizedDist < fadeStart ? 1 : normalizedDist > dissolveThreshold ? 0 : 1 - (normalizedDist - fadeStart) / (dissolveThreshold - fadeStart);
36653
+ } else alpha = normalizedDist > dissolveThreshold ? 0 : 1;
36654
+ const index = 4 * (y * width + x);
36655
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36656
+ }
36657
+ return new ImageData(result, width, height);
36658
+ }
36659
+ applyInwardDissolve(imageData, progress) {
36660
+ const {
36661
+ data: data,
36662
+ width: width,
36663
+ height: height
36664
+ } = imageData,
36665
+ result = new Uint8ClampedArray(data.length);
36666
+ result.set(data);
36667
+ const centerX = width / 2,
36668
+ centerY = height / 2,
36669
+ maxDist = Math.sqrt(centerX * centerX + centerY * centerY),
36670
+ pixelSize = this.dissolveConfig.noiseScale;
36671
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36672
+ const dx = x - centerX,
36673
+ dy = y - centerY,
36674
+ normalizedDist = Math.sqrt(dx * dx + dy * dy) / maxDist;
36675
+ let dissolveThreshold = 1.4 * progress,
36676
+ alpha = 1;
36677
+ if (pixelSize > 0) {
36678
+ dissolveThreshold += .4 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedDist < dissolveThreshold ? 0 : 1;
36679
+ } else if (this.dissolveConfig.fadeEdge) {
36680
+ const fadeEnd = dissolveThreshold + .15;
36681
+ alpha = normalizedDist < dissolveThreshold ? 0 : normalizedDist > fadeEnd ? 1 : (normalizedDist - dissolveThreshold) / (fadeEnd - dissolveThreshold);
36682
+ } else alpha = normalizedDist < dissolveThreshold ? 0 : 1;
36683
+ const index = 4 * (y * width + x);
36684
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36685
+ }
36686
+ return new ImageData(result, width, height);
36687
+ }
36688
+ applyRadialDissolve(imageData, progress) {
36689
+ const {
36690
+ data: data,
36691
+ width: width,
36692
+ height: height
36693
+ } = imageData,
36694
+ result = new Uint8ClampedArray(data.length);
36695
+ result.set(data);
36696
+ const centerX = width / 2,
36697
+ centerY = height / 2,
36698
+ pixelSize = this.dissolveConfig.noiseScale;
36699
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36700
+ const dx = x - centerX,
36701
+ dy = y - centerY,
36702
+ normalizedAngle = (Math.atan2(dy, dx) + Math.PI) / (2 * Math.PI);
36703
+ let dissolveThreshold = 1.2 * progress,
36704
+ alpha = 1;
36705
+ if (pixelSize > 0) {
36706
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedAngle < dissolveThreshold ? 0 : 1;
36707
+ } else if (this.dissolveConfig.fadeEdge) {
36708
+ const fadeEnd = dissolveThreshold + .08;
36709
+ alpha = normalizedAngle < dissolveThreshold ? 0 : normalizedAngle > fadeEnd ? 1 : (normalizedAngle - dissolveThreshold) / (fadeEnd - dissolveThreshold);
36710
+ } else alpha = normalizedAngle < dissolveThreshold ? 0 : 1;
36711
+ const index = 4 * (y * width + x);
36712
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36713
+ }
36714
+ return new ImageData(result, width, height);
36715
+ }
36716
+ applyLeftToRightDissolve(imageData, progress) {
36717
+ const {
36718
+ data: data,
36719
+ width: width,
36720
+ height: height
36721
+ } = imageData,
36722
+ result = new Uint8ClampedArray(data.length);
36723
+ result.set(data);
36724
+ const pixelSize = this.dissolveConfig.noiseScale;
36725
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36726
+ const normalizedX = x / width;
36727
+ let dissolveThreshold = 1.2 * progress,
36728
+ alpha = 1;
36729
+ if (pixelSize > 0) {
36730
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedX < dissolveThreshold ? 0 : 1;
36731
+ } else if (this.dissolveConfig.fadeEdge) {
36732
+ const fadeEnd = dissolveThreshold + .08;
36733
+ alpha = normalizedX < dissolveThreshold ? 0 : normalizedX > fadeEnd ? 1 : (normalizedX - dissolveThreshold) / (fadeEnd - dissolveThreshold);
36734
+ } else alpha = normalizedX < dissolveThreshold ? 0 : 1;
36735
+ const index = 4 * (y * width + x);
36736
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36737
+ }
36738
+ return new ImageData(result, width, height);
36739
+ }
36740
+ applyRightToLeftDissolve(imageData, progress) {
36741
+ const {
36742
+ data: data,
36743
+ width: width,
36744
+ height: height
36745
+ } = imageData,
36746
+ result = new Uint8ClampedArray(data.length);
36747
+ result.set(data);
36748
+ const pixelSize = this.dissolveConfig.noiseScale;
36749
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36750
+ const normalizedX = x / width;
36751
+ let dissolveThreshold = 1 - 1.2 * progress,
36752
+ alpha = 1;
36753
+ if (pixelSize > 0) {
36754
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedX > dissolveThreshold ? 0 : 1;
36755
+ } else if (this.dissolveConfig.fadeEdge) {
36756
+ const fadeStart = dissolveThreshold - .08;
36757
+ alpha = normalizedX < fadeStart ? 1 : normalizedX > dissolveThreshold ? 0 : 1 - (normalizedX - fadeStart) / (dissolveThreshold - fadeStart);
36758
+ } else alpha = normalizedX > dissolveThreshold ? 0 : 1;
36759
+ const index = 4 * (y * width + x);
36760
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36761
+ }
36762
+ return new ImageData(result, width, height);
36763
+ }
36764
+ applyTopToBottomDissolve(imageData, progress) {
36765
+ const {
36766
+ data: data,
36767
+ width: width,
36768
+ height: height
36769
+ } = imageData,
36770
+ result = new Uint8ClampedArray(data.length);
36771
+ result.set(data);
36772
+ const pixelSize = this.dissolveConfig.noiseScale;
36773
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36774
+ const normalizedY = y / height;
36775
+ let dissolveThreshold = 1.2 * progress,
36776
+ alpha = 1;
36777
+ if (pixelSize > 0) {
36778
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedY < dissolveThreshold ? 0 : 1;
36779
+ } else if (this.dissolveConfig.fadeEdge) {
36780
+ const fadeEnd = dissolveThreshold + .08;
36781
+ alpha = normalizedY < dissolveThreshold ? 0 : normalizedY > fadeEnd ? 1 : (normalizedY - dissolveThreshold) / (fadeEnd - dissolveThreshold);
36782
+ } else alpha = normalizedY < dissolveThreshold ? 0 : 1;
36783
+ const index = 4 * (y * width + x);
36784
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36785
+ }
36786
+ return new ImageData(result, width, height);
36787
+ }
36788
+ applyBottomToTopDissolve(imageData, progress) {
36789
+ const {
36790
+ data: data,
36791
+ width: width,
36792
+ height: height
36793
+ } = imageData,
36794
+ result = new Uint8ClampedArray(data.length);
36795
+ result.set(data);
36796
+ const pixelSize = this.dissolveConfig.noiseScale;
36797
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
36798
+ const normalizedY = y / height;
36799
+ let dissolveThreshold = 1 - 1.2 * progress,
36800
+ alpha = 1;
36801
+ if (pixelSize > 0) {
36802
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedY > dissolveThreshold ? 0 : 1;
36803
+ } else if (this.dissolveConfig.fadeEdge) {
36804
+ const fadeStart = dissolveThreshold - .08;
36805
+ alpha = normalizedY < fadeStart ? 1 : normalizedY > dissolveThreshold ? 0 : 1 - (normalizedY - fadeStart) / (dissolveThreshold - fadeStart);
36806
+ } else alpha = normalizedY > dissolveThreshold ? 0 : 1;
36807
+ const index = 4 * (y * width + x);
36808
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
36809
+ }
36810
+ return new ImageData(result, width, height);
36811
+ }
36812
+ }
36813
+
36814
+ class Grayscale extends HybridEffectBase {
36815
+ constructor(from, to, duration, easing, params) {
36816
+ var _a, _b, _c;
36817
+ super(from, to, duration, easing, params);
36818
+ const rawStrength = void 0 !== (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.strength) ? params.options.strength : 1,
36819
+ clampedStrength = Math.max(0, Math.min(1, rawStrength));
36820
+ this.colorConfig = {
36821
+ effectType: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.effectType) || "grayscale",
36822
+ strength: clampedStrength,
36823
+ useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL
36824
+ };
36825
+ }
36826
+ getShaderSources() {
36827
+ return {
36828
+ vertex: ShaderLibrary.STANDARD_VERTEX_SHADER,
36829
+ 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 `
36830
+ };
36831
+ }
36832
+ applyWebGLEffect(canvas) {
36833
+ if (!this.gl || !this.program || !this.webglCanvas) return null;
36834
+ this.setupWebGLState(canvas);
36835
+ const texture = this.createTextureFromCanvas(canvas);
36836
+ if (!texture) return null;
36837
+ const vertexBuffer = this.createFullScreenQuad();
36838
+ if (!vertexBuffer) return this.gl.deleteTexture(texture), null;
36839
+ try {
36840
+ return this.gl.useProgram(this.program), this.setupVertexAttributes(), this.setColorUniforms(), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4), this.webglCanvas;
36841
+ } finally {
36842
+ this.gl.deleteTexture(texture), this.gl.deleteBuffer(vertexBuffer);
36843
+ }
36844
+ }
36845
+ setColorUniforms() {
36846
+ if (!this.gl || !this.program) return;
36847
+ const currentTime = this.getAnimationTime(),
36848
+ timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
36849
+ strengthLocation = this.gl.getUniformLocation(this.program, "u_strength"),
36850
+ effectTypeLocation = this.gl.getUniformLocation(this.program, "u_effectType"),
36851
+ resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution");
36852
+ this.gl.uniform1f(timeLocation, currentTime), this.gl.uniform1f(strengthLocation, this.colorConfig.strength), this.gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height);
36853
+ this.gl.uniform1i(effectTypeLocation, {
36854
+ grayscale: 0,
36855
+ sepia: 1
36856
+ }[this.colorConfig.effectType] || 0);
36857
+ }
36858
+ applyCanvas2DEffect(canvas) {
36859
+ if (this.colorConfig.strength <= 0) {
36860
+ const outputCanvas = this.createOutputCanvas(canvas);
36861
+ return outputCanvas ? outputCanvas.canvas : null;
36862
+ }
36863
+ if (this.canUseCSSFilter()) return this.applyCSSFilter(canvas);
36864
+ const outputCanvas = this.createOutputCanvas(canvas);
36865
+ if (!outputCanvas) return null;
36866
+ const {
36867
+ ctx: ctx
36868
+ } = outputCanvas;
36869
+ try {
36870
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
36871
+ currentTime = this.getAnimationTime();
36872
+ let processedImageData;
36873
+ switch (this.colorConfig.effectType) {
36874
+ case "grayscale":
36875
+ default:
36876
+ processedImageData = this.applyGrayscaleEffect(imageData, this.colorConfig.strength, currentTime);
36877
+ break;
36878
+ case "sepia":
36879
+ processedImageData = this.applySepiaEffect(imageData, this.colorConfig.strength, currentTime);
36880
+ }
36881
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(processedImageData, 0, 0), outputCanvas.canvas;
36882
+ } catch (error) {
36883
+ return console.warn("Canvas 2D color effect failed:", error), null;
36884
+ }
36885
+ }
36886
+ canUseCSSFilter() {
36887
+ var _a;
36888
+ return !!window.useFilterAPI && "undefined" != typeof CSS && (null === (_a = CSS.supports) || void 0 === _a ? void 0 : _a.call(CSS, "filter", "grayscale(1)"));
36889
+ }
36890
+ applyCSSFilter(canvas) {
36891
+ try {
36892
+ const outputCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height),
36893
+ ctx = outputCanvas.getContext("2d");
36894
+ if (!ctx) return null;
36895
+ const currentTime = this.getAnimationTime(),
36896
+ dynamicStrength = ImageProcessUtils.calculateDynamicStrength(this.colorConfig.strength, currentTime);
36897
+ let filterValue = "";
36898
+ 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;
36899
+ } catch (error) {
36900
+ return console.warn("CSS Filter API failed, falling back to pixel processing:", error), null;
36901
+ }
36902
+ }
36903
+ applyGrayscaleEffect(imageData, strength, time) {
36904
+ const {
36905
+ data: data,
36906
+ width: width,
36907
+ height: height
36908
+ } = imageData,
36909
+ result = new Uint8ClampedArray(data.length),
36910
+ dynamicStrength = ImageProcessUtils.calculateDynamicStrength(strength, time);
36911
+ for (let i = 0; i < data.length; i += 4) {
36912
+ const r = data[i],
36913
+ g = data[i + 1],
36914
+ b = data[i + 2],
36915
+ a = data[i + 3],
36916
+ gray = ImageProcessUtils.getLuminance(r, g, b);
36917
+ 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;
36918
+ }
36919
+ return new ImageData(result, width, height);
36920
+ }
36921
+ applySepiaEffect(imageData, strength, time) {
36922
+ const {
36923
+ data: data,
36924
+ width: width,
36925
+ height: height
36926
+ } = imageData,
36927
+ result = new Uint8ClampedArray(data.length),
36928
+ dynamicStrength = ImageProcessUtils.calculateDynamicStrength(strength, time);
36929
+ for (let i = 0; i < data.length; i += 4) {
36930
+ const r = data[i],
36931
+ g = data[i + 1],
36932
+ b = data[i + 2],
36933
+ a = data[i + 3],
36934
+ [sepiaR, sepiaG, sepiaB] = ImageProcessUtils.applySepiaToPixel(r, g, b);
36935
+ 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;
36936
+ }
36937
+ return new ImageData(result, width, height);
36938
+ }
36939
+ afterStageRender(stage, canvas) {
36940
+ if (this.canUseCSSFilter() && this.colorConfig.strength > 0) {
36941
+ const cssResult = this.applyCSSFilter(canvas);
36942
+ if (cssResult) return cssResult;
36943
+ }
36944
+ return super.afterStageRender(stage, canvas);
36945
+ }
36946
+ }
36947
+
36948
+ class Distortion extends HybridEffectBase {
36949
+ constructor(from, to, duration, easing, params) {
36950
+ var _a, _b, _c;
36951
+ super(from, to, duration, easing, params), this.distortionConfig = {
36952
+ distortionType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.distortionType) || "wave",
36953
+ strength: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.strength) || .3,
36954
+ useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL
36955
+ };
36956
+ }
36957
+ getShaderSources() {
36958
+ return {
36959
+ 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 ",
36960
+ 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 "
36961
+ };
36962
+ }
36963
+ applyWebGLEffect(canvas) {
36964
+ if (!this.gl || !this.program || !this.webglCanvas) return null;
36965
+ this.setupWebGLState(canvas);
36966
+ const texture = this.createTextureFromCanvas(canvas);
36967
+ if (!texture) return null;
36968
+ const vertexBuffer = this.createFullScreenQuad();
36969
+ if (!vertexBuffer) return this.gl.deleteTexture(texture), null;
36970
+ try {
36971
+ return this.gl.useProgram(this.program), this.setupVertexAttributes(), this.setDistortionUniforms(), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4), this.webglCanvas;
36972
+ } finally {
36973
+ this.gl.deleteTexture(texture), this.gl.deleteBuffer(vertexBuffer);
36974
+ }
36975
+ }
36976
+ setDistortionUniforms() {
36977
+ if (!this.gl || !this.program) return;
36978
+ const currentTime = this.getAnimationTime(),
36979
+ timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
36980
+ strengthLocation = this.gl.getUniformLocation(this.program, "u_strength"),
36981
+ distortionTypeLocation = this.gl.getUniformLocation(this.program, "u_distortionType"),
36982
+ resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution");
36983
+ this.gl.uniform1f(timeLocation, currentTime), this.gl.uniform1f(strengthLocation, this.distortionConfig.strength), this.gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height);
36984
+ this.gl.uniform1i(distortionTypeLocation, {
36985
+ wave: 0,
36986
+ ripple: 1,
36987
+ swirl: 2
36988
+ }[this.distortionConfig.distortionType] || 0);
36989
+ }
36990
+ applyCanvas2DEffect(canvas) {
36991
+ const outputCanvas = this.createOutputCanvas(canvas);
36992
+ if (!outputCanvas) return null;
36993
+ const {
36994
+ ctx: ctx
36995
+ } = outputCanvas;
36996
+ try {
36997
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
36998
+ currentTime = this.getAnimationTime();
36999
+ let distortedImageData;
37000
+ switch (this.distortionConfig.distortionType) {
37001
+ case "wave":
37002
+ distortedImageData = this.applyWaveDistortion(imageData, this.distortionConfig.strength, currentTime);
37003
+ break;
37004
+ case "ripple":
37005
+ distortedImageData = this.applyRippleDistortion(imageData, this.distortionConfig.strength, currentTime);
37006
+ break;
37007
+ case "swirl":
37008
+ distortedImageData = this.applySwirlDistortion(imageData, this.distortionConfig.strength, currentTime);
37009
+ break;
37010
+ default:
37011
+ distortedImageData = imageData;
37012
+ }
37013
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(distortedImageData, 0, 0), outputCanvas.canvas;
37014
+ } catch (error) {
37015
+ return console.warn("Canvas 2D distortion effect failed:", error), null;
37016
+ }
37017
+ }
37018
+ applyWaveDistortion(imageData, strength, time) {
37019
+ const {
37020
+ data: data,
37021
+ width: width,
37022
+ height: height
37023
+ } = imageData,
37024
+ result = new Uint8ClampedArray(data.length);
37025
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
37026
+ const waveX = Math.sin(.1 * y + 3 * time) * strength * 20,
37027
+ waveY = Math.sin(.1 * x + 2 * time) * strength * 20,
37028
+ sourceX = Math.round(x - waveX),
37029
+ sourceY = Math.round(y - waveY),
37030
+ targetIndex = 4 * (y * width + x);
37031
+ if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
37032
+ const sourceIndex = 4 * (sourceY * width + sourceX);
37033
+ result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
37034
+ } else result[targetIndex + 3] = 0;
37035
+ }
37036
+ return new ImageData(result, width, height);
37037
+ }
37038
+ applyRippleDistortion(imageData, strength, time) {
37039
+ const {
37040
+ data: data,
37041
+ width: width,
37042
+ height: height
37043
+ } = imageData,
37044
+ result = new Uint8ClampedArray(data.length),
37045
+ centerX = width / 2,
37046
+ centerY = height / 2;
37047
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
37048
+ const dx = x - centerX,
37049
+ dy = y - centerY,
37050
+ distance = Math.sqrt(dx * dx + dy * dy),
37051
+ ripple = Math.sin(.2 * distance - 5 * time) * strength * 10,
37052
+ angle = Math.atan2(dy, dx),
37053
+ sourceX = Math.round(x - Math.cos(angle) * ripple),
37054
+ sourceY = Math.round(y - Math.sin(angle) * ripple),
37055
+ targetIndex = 4 * (y * width + x);
37056
+ if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
37057
+ const sourceIndex = 4 * (sourceY * width + sourceX);
37058
+ result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
37059
+ } else result[targetIndex + 3] = 0;
37060
+ }
37061
+ return new ImageData(result, width, height);
37062
+ }
37063
+ applySwirlDistortion(imageData, strength, time) {
37064
+ const {
37065
+ data: data,
37066
+ width: width,
37067
+ height: height
37068
+ } = imageData,
37069
+ result = new Uint8ClampedArray(data.length),
37070
+ centerX = width / 2,
37071
+ centerY = height / 2;
37072
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
37073
+ const dx = x - centerX,
37074
+ dy = y - centerY,
37075
+ distance = Math.sqrt(dx * dx + dy * dy),
37076
+ finalAngle = Math.atan2(dy, dx) + distance * strength * time * .02,
37077
+ sourceX = Math.round(centerX + distance * Math.cos(finalAngle)),
37078
+ sourceY = Math.round(centerY + distance * Math.sin(finalAngle)),
37079
+ targetIndex = 4 * (y * width + x);
37080
+ if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
37081
+ const sourceIndex = 4 * (sourceY * width + sourceX);
37082
+ result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
37083
+ } else result[targetIndex + 3] = 0;
37084
+ }
37085
+ return new ImageData(result, width, height);
37086
+ }
37087
+ afterStageRender(stage, canvas) {
37088
+ return this.distortionConfig.strength <= 0 ? canvas : super.afterStageRender(stage, canvas);
37089
+ }
37090
+ }
37091
+
37092
+ class Particle extends HybridEffectBase {
37093
+ constructor(from, to, duration, easing, params) {
37094
+ var _a, _b, _c, _d, _e;
37095
+ super(from, to, duration, easing, params), this.particles = [], this.positionBuffer = null, this.colorBuffer = null, this.particleConfig = {
37096
+ effectType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.effectType) || "gravity",
37097
+ count: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.count) || 4e3,
37098
+ size: (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.size) || 20,
37099
+ strength: (null === (_d = null == params ? void 0 : params.options) || void 0 === _d ? void 0 : _d.strength) || 1.5,
37100
+ useWebGL: void 0 === (null === (_e = null == params ? void 0 : params.options) || void 0 === _e ? void 0 : _e.useWebGL) || params.options.useWebGL
37101
+ };
37102
+ }
37103
+ getShaderSources() {
37104
+ return {
37105
+ 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 ",
37106
+ 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 "
37107
+ };
37108
+ }
37109
+ applyWebGLEffect(canvas) {
37110
+ if (!this.gl || !this.program || !this.webglCanvas) return null;
37111
+ this.setupWebGLState(canvas), 0 === this.particles.length && this.extractParticles(canvas), this.updateParticles(canvas);
37112
+ const gl = this.gl;
37113
+ return gl.enable(gl.BLEND), gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA), gl.useProgram(this.program), this.prepareAndDrawParticles(gl), this.webglCanvas;
37114
+ }
37115
+ applyCanvas2DEffect(canvas) {
37116
+ const output = this.createOutputCanvas(canvas);
37117
+ if (!output) return null;
37118
+ const {
37119
+ canvas: outputCanvas,
37120
+ ctx: ctx
37121
+ } = output,
37122
+ progress = this.currentAnimationRatio;
37123
+ switch (this.particleConfig.effectType) {
37124
+ case "explode":
37125
+ this.applyCanvas2DExplode(ctx, canvas, progress);
37126
+ break;
37127
+ case "gravity":
37128
+ this.applyCanvas2DGravity(ctx, canvas, progress);
37129
+ break;
37130
+ case "vortex":
37131
+ this.applyCanvas2DVortex(ctx, canvas, progress);
37132
+ break;
37133
+ default:
37134
+ ctx.globalAlpha = Math.max(0, 1 - progress), ctx.drawImage(canvas, 0, 0);
37135
+ }
37136
+ return outputCanvas;
37137
+ }
37138
+ extractParticles(canvas) {
37139
+ const tempCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height, 1),
37140
+ tempCtx = tempCanvas.getContext("2d");
37141
+ if (!tempCtx) return;
37142
+ tempCtx.drawImage(canvas, 0, 0, tempCanvas.width, tempCanvas.height);
37143
+ const data = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height).data;
37144
+ this.particles = [];
37145
+ const step = Math.max(1, Math.floor(Math.sqrt(tempCanvas.width * tempCanvas.height / (1.5 * this.particleConfig.count))));
37146
+ for (let y = 0; y < tempCanvas.height; y += step) for (let x = 0; x < tempCanvas.width; x += step) {
37147
+ const index = 4 * (y * tempCanvas.width + x),
37148
+ r = data[index],
37149
+ g = data[index + 1],
37150
+ b = data[index + 2],
37151
+ a = data[index + 3];
37152
+ if (a > 5) {
37153
+ const realX = x / tempCanvas.width * canvas.width,
37154
+ realY = y / tempCanvas.height * canvas.height,
37155
+ particle = {
37156
+ x: realX,
37157
+ y: realY,
37158
+ originX: realX,
37159
+ originY: realY,
37160
+ vx: 0,
37161
+ vy: 0,
37162
+ r: r / 255,
37163
+ g: g / 255,
37164
+ b: b / 255,
37165
+ a: Math.max(.6, a / 255),
37166
+ life: 1,
37167
+ size: this.particleConfig.size * (1 + .5 * Math.random())
37168
+ };
37169
+ this.particles.push(particle);
37170
+ }
37171
+ }
37172
+ }
37173
+ updateParticles(canvas) {
37174
+ const centerX = canvas.width / 2,
37175
+ centerY = canvas.height / 2,
37176
+ progress = this.currentAnimationRatio,
37177
+ duration = this.getDurationFromParent(),
37178
+ isShortAnimation = duration < 2e3,
37179
+ timeMultiplier = isShortAnimation ? Math.max(1.5, 3e3 / duration) : 1,
37180
+ intensityBoost = isShortAnimation ? Math.min(2, 2e3 / duration) : 1;
37181
+ this.particles.forEach(particle => {
37182
+ const dx = particle.x - centerX,
37183
+ dy = particle.y - centerY,
37184
+ distance = Math.sqrt(dx * dx + dy * dy),
37185
+ angle = Math.atan2(dy, dx);
37186
+ this.applyParticleForces(particle, angle, distance, progress, intensityBoost, canvas), this.updateParticleProperties(particle, progress, isShortAnimation, timeMultiplier, intensityBoost);
37187
+ });
37188
+ }
37189
+ applyParticleForces(particle, angle, distance, progress, intensityBoost, canvas) {
37190
+ const time = this.getAnimationTime();
37191
+ switch (this.particleConfig.effectType) {
37192
+ case "explode":
37193
+ const explodeIntensity = progress * this.particleConfig.strength * intensityBoost * 5;
37194
+ particle.vx += Math.cos(angle) * explodeIntensity, particle.vy += Math.sin(angle) * explodeIntensity;
37195
+ break;
37196
+ case "gravity":
37197
+ this.applyGravityEffect(particle, progress, intensityBoost, canvas, time);
37198
+ break;
37199
+ case "vortex":
37200
+ this.applyVortexEffect(particle, progress, intensityBoost, canvas, angle, distance);
37201
+ }
37202
+ }
37203
+ applyGravityEffect(particle, progress, intensityBoost, canvas, time) {
37204
+ const gravityThreshold = (particle.originX + .7 * particle.originY) / (canvas.width + canvas.height) * .8;
37205
+ if (progress > gravityThreshold) {
37206
+ const gravityProgress = (progress - gravityThreshold) / (1 - gravityThreshold),
37207
+ gravityForce = this.particleConfig.strength * gravityProgress * gravityProgress * 12 * intensityBoost;
37208
+ particle.vy += gravityForce;
37209
+ const turbulence = Math.sin(3 * time + .02 * particle.originX) * Math.cos(2 * time + .015 * particle.originY);
37210
+ particle.vx += turbulence * this.particleConfig.strength * 2 * intensityBoost;
37211
+ }
37212
+ }
37213
+ applyVortexEffect(particle, progress, intensityBoost, canvas, angle, distance) {
37214
+ const centerX = canvas.width / 2,
37215
+ centerY = canvas.height / 2,
37216
+ spiralAngle = angle + progress * Math.PI * .8,
37217
+ targetRadius = distance + progress * Math.max(canvas.width, canvas.height) * .7 * 1.8,
37218
+ targetX = centerX + Math.cos(spiralAngle) * targetRadius,
37219
+ targetY = centerY + Math.sin(spiralAngle) * targetRadius,
37220
+ baseForce = progress * this.particleConfig.strength * .08 * intensityBoost;
37221
+ particle.vx += (targetX - particle.x) * baseForce, particle.vy += (targetY - particle.y) * baseForce;
37222
+ }
37223
+ updateParticleProperties(particle, progress, isShortAnimation, timeMultiplier, intensityBoost) {
37224
+ const dragCoeff = isShortAnimation ? .99 : .98;
37225
+ if (particle.vx *= dragCoeff, particle.vy *= dragCoeff, particle.x += particle.vx, particle.y += particle.vy, isShortAnimation) {
37226
+ const lifeDecayRate = Math.max(.1, .5 / timeMultiplier);
37227
+ 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));
37228
+ } 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));
37229
+ }
37230
+ prepareAndDrawParticles(gl) {
37231
+ const positions = new Float32Array(2 * this.particles.length),
37232
+ colors = new Float32Array(4 * this.particles.length),
37233
+ sizes = new Float32Array(this.particles.length);
37234
+ this.particles.forEach((particle, i) => {
37235
+ 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);
37236
+ }), this.updateParticleBuffers(gl, positions, colors, sizes), this.setParticleUniforms(gl), gl.drawArrays(gl.POINTS, 0, this.particles.length), this.cleanupTempBuffers(gl);
37237
+ }
37238
+ updateParticleBuffers(gl, positions, colors, sizes) {
37239
+ this.positionBuffer || (this.positionBuffer = gl.createBuffer()), gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer), gl.bufferData(gl.ARRAY_BUFFER, positions, gl.DYNAMIC_DRAW);
37240
+ const positionLocation = gl.getAttribLocation(this.program, "a_position");
37241
+ 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);
37242
+ const colorLocation = gl.getAttribLocation(this.program, "a_color");
37243
+ gl.enableVertexAttribArray(colorLocation), gl.vertexAttribPointer(colorLocation, 4, gl.FLOAT, !1, 0, 0);
37244
+ const sizeBuffer = gl.createBuffer();
37245
+ gl.bindBuffer(gl.ARRAY_BUFFER, sizeBuffer), gl.bufferData(gl.ARRAY_BUFFER, sizes, gl.DYNAMIC_DRAW);
37246
+ const sizeLocation = gl.getAttribLocation(this.program, "a_size");
37247
+ gl.enableVertexAttribArray(sizeLocation), gl.vertexAttribPointer(sizeLocation, 1, gl.FLOAT, !1, 0, 0), this._tempSizeBuffer = sizeBuffer;
37248
+ }
37249
+ setParticleUniforms(gl) {
37250
+ const resolutionLocation = gl.getUniformLocation(this.program, "u_resolution"),
37251
+ timeLocation = gl.getUniformLocation(this.program, "u_time"),
37252
+ forceStrengthLocation = gl.getUniformLocation(this.program, "u_forceStrength"),
37253
+ effectTypeLocation = gl.getUniformLocation(this.program, "u_effectType");
37254
+ gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height), gl.uniform1f(timeLocation, this.getAnimationTime()), gl.uniform1f(forceStrengthLocation, this.particleConfig.strength);
37255
+ gl.uniform1i(effectTypeLocation, {
37256
+ explode: 0,
37257
+ vortex: 1,
37258
+ gravity: 2
37259
+ }[this.particleConfig.effectType] || 0);
37260
+ }
37261
+ cleanupTempBuffers(gl) {
37262
+ const tempSizeBuffer = this._tempSizeBuffer;
37263
+ tempSizeBuffer && (gl.deleteBuffer(tempSizeBuffer), delete this._tempSizeBuffer);
37264
+ }
37265
+ applyCanvas2DExplode(ctx, canvas, progress) {
37266
+ const centerX = canvas.width / 2,
37267
+ centerY = canvas.height / 2;
37268
+ ctx.save(), ctx.globalAlpha = Math.max(0, 1 - progress), ctx.translate(centerX, centerY);
37269
+ const scale = 1 + .5 * progress;
37270
+ ctx.scale(scale, scale), ctx.translate(-centerX, -centerY), ctx.drawImage(canvas, 0, 0), ctx.restore();
37271
+ }
37272
+ applyCanvas2DGravity(ctx, canvas, progress) {
37273
+ ctx.save(), ctx.globalAlpha = Math.max(0, 1 - progress);
37274
+ const offsetY = progress * canvas.height * .3;
37275
+ ctx.drawImage(canvas, 0, offsetY), ctx.restore();
37276
+ }
37277
+ applyCanvas2DVortex(ctx, canvas, progress) {
37278
+ const centerX = canvas.width / 2,
37279
+ centerY = canvas.height / 2;
37280
+ 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();
37281
+ }
37282
+ }
37283
+
37284
+ class Glitch extends Canvas2DEffectBase {
37285
+ constructor(from, to, duration, easing, params) {
37286
+ var _a, _b;
37287
+ super(from, to, duration, easing, params), this.glitchConfig = {
37288
+ effectType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.effectType) || "rgb-shift",
37289
+ intensity: void 0 !== (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.intensity) ? params.options.intensity : .5
37290
+ };
37291
+ }
37292
+ applyCanvas2DEffect(canvas) {
37293
+ if (this.glitchConfig.intensity <= 0) {
37294
+ const outputCanvas = this.createOutputCanvas(canvas);
37295
+ return outputCanvas ? outputCanvas.canvas : null;
37296
+ }
37297
+ try {
37298
+ switch (this.glitchConfig.effectType) {
37299
+ case "rgb-shift":
37300
+ default:
37301
+ return this.applyRGBShiftGlitch(canvas);
37302
+ case "digital-distortion":
37303
+ return this.applyDigitalDistortionGlitch(canvas);
37304
+ case "scan-lines":
37305
+ return this.applyScanLineGlitch(canvas);
37306
+ case "data-corruption":
37307
+ return this.applyDataCorruptionGlitch(canvas);
37308
+ }
37309
+ } catch (error) {
37310
+ return console.warn("Glitch effect failed:", error), null;
37311
+ }
37312
+ }
37313
+ applyRGBShiftGlitch(canvas) {
37314
+ const outputCanvas = this.createOutputCanvas(canvas);
37315
+ if (!outputCanvas) return null;
37316
+ const {
37317
+ ctx: ctx
37318
+ } = outputCanvas;
37319
+ try {
37320
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
37321
+ const dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
37322
+ maxOffset = Math.floor(20 * dynamicIntensity),
37323
+ redOffset = this.generateRandomOffset(maxOffset),
37324
+ greenOffset = this.generateRandomOffset(maxOffset, .3),
37325
+ blueOffset = this.generateRandomOffset(-maxOffset),
37326
+ tempCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height),
37327
+ tempCtx = tempCanvas.getContext("2d");
37328
+ tempCtx.drawImage(canvas, 0, 0);
37329
+ const originalImageData = tempCtx.getImageData(0, 0, canvas.width, canvas.height),
37330
+ redChannelData = ImageProcessUtils.extractChannel(originalImageData, 0),
37331
+ greenChannelData = ImageProcessUtils.extractChannel(originalImageData, 1),
37332
+ blueChannelData = ImageProcessUtils.extractChannel(originalImageData, 2);
37333
+ 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;
37334
+ } catch (error) {
37335
+ return console.warn("RGB shift glitch failed:", error), null;
37336
+ }
37337
+ }
37338
+ applyDigitalDistortionGlitch(canvas) {
37339
+ const outputCanvas = this.createOutputCanvas(canvas);
37340
+ if (!outputCanvas) return null;
37341
+ const {
37342
+ ctx: ctx
37343
+ } = outputCanvas;
37344
+ try {
37345
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
37346
+ dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
37347
+ distortedImageData = this.processDigitalDistortion(imageData, dynamicIntensity);
37348
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(distortedImageData, 0, 0), outputCanvas.canvas;
37349
+ } catch (error) {
37350
+ return console.warn("Digital distortion glitch failed:", error), null;
37351
+ }
37352
+ }
37353
+ applyScanLineGlitch(canvas) {
37354
+ const outputCanvas = this.createOutputCanvas(canvas);
37355
+ if (!outputCanvas) return null;
37356
+ const {
37357
+ ctx: ctx
37358
+ } = outputCanvas;
37359
+ try {
37360
+ const dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
37361
+ lineSpacing = Math.max(2, Math.floor(10 - 8 * dynamicIntensity));
37362
+ ctx.globalCompositeOperation = "multiply";
37363
+ for (let y = 0; y < canvas.height; y += lineSpacing) if (Math.random() < dynamicIntensity) {
37364
+ const opacity = .1 + .4 * dynamicIntensity;
37365
+ ctx.fillStyle = `rgba(0, 0, 0, ${opacity})`, ctx.fillRect(0, y, canvas.width, 1);
37366
+ }
37367
+ ctx.globalCompositeOperation = "screen";
37368
+ const brightLineCount = Math.floor(20 * dynamicIntensity);
37369
+ for (let i = 0; i < brightLineCount; i++) {
37370
+ const y = Math.random() * canvas.height,
37371
+ opacity = .3 * dynamicIntensity;
37372
+ ctx.fillStyle = `rgba(255, 255, 255, ${opacity})`, ctx.fillRect(0, Math.floor(y), canvas.width, 1);
37373
+ }
37374
+ return ctx.globalCompositeOperation = "source-over", outputCanvas.canvas;
37375
+ } catch (error) {
37376
+ return console.warn("Scan line glitch failed:", error), null;
37377
+ }
37378
+ }
37379
+ applyDataCorruptionGlitch(canvas) {
37380
+ const outputCanvas = this.createOutputCanvas(canvas);
37381
+ if (!outputCanvas) return null;
37382
+ const {
37383
+ ctx: ctx
37384
+ } = outputCanvas;
37385
+ try {
37386
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
37387
+ dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
37388
+ corruptedImageData = this.processDataCorruption(imageData, dynamicIntensity);
37389
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(corruptedImageData, 0, 0), outputCanvas.canvas;
37390
+ } catch (error) {
37391
+ return console.warn("Data corruption glitch failed:", error), null;
37392
+ }
37393
+ }
37394
+ generateRandomOffset(maxOffset, scale = 1) {
37395
+ return {
37396
+ x: (Math.random() - .5) * maxOffset,
37397
+ y: (Math.random() - .5) * maxOffset * scale
37398
+ };
37399
+ }
37400
+ processDigitalDistortion(imageData, intensity) {
37401
+ const {
37402
+ data: data,
37403
+ width: width,
37404
+ height: height
37405
+ } = imageData,
37406
+ result = new Uint8ClampedArray(data),
37407
+ sliceCount = Math.floor(20 * intensity) + 5,
37408
+ sliceHeight = Math.floor(height / sliceCount);
37409
+ for (let i = 0; i < sliceCount; i++) if (Math.random() < intensity) {
37410
+ const y = i * sliceHeight,
37411
+ sliceEnd = Math.min(y + sliceHeight, height),
37412
+ offset = Math.floor((Math.random() - .5) * width * intensity * .1);
37413
+ this.shiftSliceHorizontal(result, width, height, y, sliceEnd, offset);
37414
+ }
37415
+ const noiseIntensity = .3 * intensity;
37416
+ 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());
37417
+ return new ImageData(result, width, height);
37418
+ }
37419
+ shiftSliceHorizontal(data, width, height, startY, endY, offset) {
37420
+ const tempRow = new Uint8ClampedArray(4 * width);
37421
+ for (let y = startY; y < endY; y++) {
37422
+ const rowStart = y * width * 4;
37423
+ for (let x = 0; x < 4 * width; x++) tempRow[x] = data[rowStart + x];
37424
+ for (let x = 0; x < width; x++) {
37425
+ const targetIndex = rowStart + 4 * x,
37426
+ sourceIndex = 4 * ((x - offset + width) % width);
37427
+ data[targetIndex] = tempRow[sourceIndex], data[targetIndex + 1] = tempRow[sourceIndex + 1], data[targetIndex + 2] = tempRow[sourceIndex + 2], data[targetIndex + 3] = tempRow[sourceIndex + 3];
37428
+ }
37429
+ }
37430
+ }
37431
+ processDataCorruption(imageData, intensity) {
37432
+ const {
37433
+ data: data,
37434
+ width: width,
37435
+ height: height
37436
+ } = imageData,
37437
+ result = new Uint8ClampedArray(data),
37438
+ stripeCount = Math.floor(15 * intensity) + 5;
37439
+ for (let i = 0; i < stripeCount; i++) if (Math.random() < intensity) {
37440
+ const x = Math.floor(Math.random() * width),
37441
+ stripeWidth = Math.floor(5 * Math.random()) + 1,
37442
+ color = Math.random() < .5 ? 0 : 255;
37443
+ for (let y = 0; y < height; y++) for (let dx = 0; dx < stripeWidth && x + dx < width; dx++) {
37444
+ const index = 4 * (y * width + x + dx);
37445
+ result[index] = color, result[index + 1] = color, result[index + 2] = color;
37446
+ }
37447
+ }
37448
+ const corruptionCount = Math.floor(20 * intensity);
37449
+ for (let i = 0; i < corruptionCount; i++) {
37450
+ const blockX = Math.floor(Math.random() * width),
37451
+ blockY = Math.floor(Math.random() * height),
37452
+ blockW = Math.floor(20 * Math.random()) + 5,
37453
+ blockH = Math.floor(10 * Math.random()) + 2;
37454
+ this.corruptBlock(result, width, height, blockX, blockY, blockW, blockH);
37455
+ }
37456
+ return new ImageData(result, width, height);
37457
+ }
37458
+ corruptBlock(data, width, height, x, y, w, h) {
37459
+ for (let dy = 0; dy < h && y + dy < height; dy++) for (let dx = 0; dx < w && x + dx < width; dx++) {
37460
+ const index = 4 * ((y + dy) * width + (x + dx));
37461
+ Math.random() < .7 && (data[index] = 255 * Math.random(), data[index + 1] = 255 * Math.random(), data[index + 2] = 255 * Math.random());
37462
+ }
37463
+ }
37464
+ }
37465
+
37466
+ class GaussianBlur extends AStageAnimate {
37467
+ constructor(from, to, duration, easing, params) {
37468
+ var _a, _b;
37469
+ super(from, to, duration, easing, params), this.blurConfig = {
37470
+ blurRadius: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.blurRadius) || 8,
37471
+ useOptimizedBlur: void 0 === (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.useOptimizedBlur) || params.options.useOptimizedBlur
37472
+ };
37473
+ }
37474
+ applyCSSBlur(canvas, radius) {
37475
+ const c = vglobal.createCanvas({
37476
+ width: canvas.width,
37477
+ height: canvas.height,
37478
+ dpr: vglobal.devicePixelRatio
37479
+ }),
37480
+ ctx = c.getContext("2d");
37481
+ return ctx ? (ctx.filter = `blur(${radius}px)`, ctx.drawImage(canvas, 0, 0), ctx.filter = "none", c) : canvas;
37482
+ }
37483
+ applyDownsampleBlur(imageData, radius) {
37484
+ const {
37485
+ width: width,
37486
+ height: height
37487
+ } = imageData,
37488
+ downsample = Math.max(1, Math.floor(radius / 2)),
37489
+ smallWidth = Math.floor(width / downsample),
37490
+ smallHeight = Math.floor(height / downsample),
37491
+ tempCanvas = vglobal.createCanvas({
37492
+ width: smallWidth,
37493
+ height: smallHeight,
37494
+ dpr: 1
37495
+ }),
37496
+ tempCtx = tempCanvas.getContext("2d");
37497
+ if (!tempCtx) return imageData;
37498
+ const originalCanvas = vglobal.createCanvas({
37499
+ width: width,
37500
+ height: height,
37501
+ dpr: 1
37502
+ }),
37503
+ originalCtx = originalCanvas.getContext("2d");
37504
+ 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;
37505
+ }
37506
+ afterStageRender(stage, canvas) {
37507
+ if (this.blurConfig.blurRadius <= 0) return canvas;
37508
+ let result;
37509
+ if (this.blurConfig.useOptimizedBlur) result = this.applyCSSBlur(canvas, this.blurConfig.blurRadius);else {
37510
+ const c = vglobal.createCanvas({
37511
+ width: canvas.width,
37512
+ height: canvas.height,
37513
+ dpr: vglobal.devicePixelRatio
37514
+ }),
37515
+ ctx = c.getContext("2d");
37516
+ if (!ctx) return !1;
37517
+ ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.drawImage(canvas, 0, 0);
37518
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
37519
+ blurredImageData = this.applyDownsampleBlur(imageData, this.blurConfig.blurRadius);
37520
+ ctx.putImageData(blurredImageData, 0, 0), result = c;
37521
+ }
37522
+ const ctx = result.getContext("2d");
37523
+ 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;
37524
+ }
37525
+ }
37526
+
37527
+ class Pixelation extends DisappearAnimateBase {
37528
+ constructor(from, to, duration, easing, params) {
37529
+ var _a, _b;
37530
+ super(from, to, duration, easing, params), this.pixelationConfig = {
37531
+ maxPixelSize: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.maxPixelSize) || 20,
37532
+ method: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.method) || "out"
37533
+ };
37534
+ }
37535
+ applyDownsamplePixelation(canvas, pixelSize) {
37536
+ if (pixelSize <= 1) return canvas;
37537
+ const {
37538
+ width: width,
37539
+ height: height
37540
+ } = canvas,
37541
+ smallWidth = Math.ceil(width / pixelSize),
37542
+ smallHeight = Math.ceil(height / pixelSize),
37543
+ smallCanvas = vglobal.createCanvas({
37544
+ width: smallWidth,
37545
+ height: smallHeight,
37546
+ dpr: 1
37547
+ }),
37548
+ smallCtx = smallCanvas.getContext("2d");
37549
+ if (!smallCtx) return canvas;
37550
+ const outputCanvas = vglobal.createCanvas({
37551
+ width: width,
37552
+ height: height,
37553
+ dpr: vglobal.devicePixelRatio
37554
+ }),
37555
+ outputCtx = outputCanvas.getContext("2d");
37556
+ return outputCtx ? (smallCtx.imageSmoothingEnabled = !1, outputCtx.imageSmoothingEnabled = !1, smallCtx.drawImage(canvas, 0, 0, smallWidth, smallHeight), outputCtx.drawImage(smallCanvas, 0, 0, width, height), outputCanvas) : canvas;
37557
+ }
37558
+ updateAnimationProgress() {
37559
+ if ("in" === this.pixelationConfig.method) {
37560
+ return this.pixelationConfig.maxPixelSize - this.currentAnimationRatio * (this.pixelationConfig.maxPixelSize - 1);
37561
+ }
37562
+ return 1 + this.currentAnimationRatio * (this.pixelationConfig.maxPixelSize - 1);
37563
+ }
37564
+ afterStageRender(stage, canvas) {
37565
+ const currentPixelSize = this.updateAnimationProgress();
37566
+ if (currentPixelSize <= 1) return canvas;
37567
+ return this.applyDownsamplePixelation(canvas, currentPixelSize);
37568
+ }
37569
+ }
37570
+
36231
37571
  const registerCustomAnimate = () => {
36232
- 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);
37572
+ 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);
36233
37573
  };
36234
37574
 
36235
37575
  class AxisEnter extends AComponentAnimate {
@@ -39264,19 +40604,22 @@ class LabelBase extends AnimateComponent {
39264
40604
  const {
39265
40605
  clampForce = !0,
39266
40606
  hideOnHit = !0,
40607
+ hideOnOverflow = !1,
39267
40608
  overlapPadding: overlapPadding,
39268
40609
  strategy: strategy
39269
40610
  } = option;
39270
- if (clampForce) for (let i = 0; i < result.length; i++) {
40611
+ if (clampForce || hideOnOverflow) for (let i = 0; i < result.length; i++) {
39271
40612
  const text = labels[i],
39272
40613
  {
39273
40614
  dx = 0,
39274
40615
  dy = 0
39275
40616
  } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
39276
- 0 === dx && 0 === dy || (text.setAttributes({
40617
+ 0 === dx && 0 === dy || (hideOnOverflow ? text.setAttributes({
40618
+ visible: !1
40619
+ }) : (text.setAttributes({
39277
40620
  x: text.attribute.x + dx,
39278
40621
  y: text.attribute.y + dy
39279
- }), text._isClamped = !0);
40622
+ }), text._isClamped = !0));
39280
40623
  }
39281
40624
  result = shiftY(result, Object.assign(Object.assign({
39282
40625
  maxY: bmpTool.height
@@ -39292,9 +40635,9 @@ class LabelBase extends AnimateComponent {
39292
40635
  bounds = text.AABBBounds,
39293
40636
  range = boundToRange(bmpTool, bounds, !0);
39294
40637
  if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) bitmap.setRange(range);else {
39295
- if (clampForce) {
39296
- if (this._processClampForce(text, bmpTool, bitmap, overlapPadding)) continue;
39297
- }
40638
+ if (hideOnOverflow) {
40639
+ if (this._processHideOnOverflow(text, bmpTool)) continue;
40640
+ } else if (clampForce && this._processClampForce(text, bmpTool, bitmap, overlapPadding)) continue;
39298
40641
  hideOnHit ? text.setAttributes({
39299
40642
  visible: !1
39300
40643
  }) : bitmap.setRange(range);
@@ -39302,6 +40645,15 @@ class LabelBase extends AnimateComponent {
39302
40645
  }
39303
40646
  return result;
39304
40647
  }
40648
+ _processHideOnOverflow(text, bmpTool) {
40649
+ const {
40650
+ dy = 0,
40651
+ dx = 0
40652
+ } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
40653
+ return 0 === dx && 0 === dy || (text.setAttributes({
40654
+ visible: !1
40655
+ }), !1);
40656
+ }
39305
40657
  _processClampForce(text, bmpTool, bitmap, overlapPadding = 0) {
39306
40658
  const {
39307
40659
  dy = 0,
@@ -39328,7 +40680,8 @@ class LabelBase extends AnimateComponent {
39328
40680
  hideOnHit = !0,
39329
40681
  clampForce = !0,
39330
40682
  avoidMarks = [],
39331
- overlapPadding: overlapPadding
40683
+ overlapPadding: overlapPadding,
40684
+ hideOnOverflow = !1
39332
40685
  } = option,
39333
40686
  result = [],
39334
40687
  checkBounds = strategy.some(s => "bound" === s.type);
@@ -39355,15 +40708,16 @@ class LabelBase extends AnimateComponent {
39355
40708
  }
39356
40709
  }
39357
40710
  let hasPlace = !1;
39358
- 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) {
39359
- text.setAttributes({
39360
- x: hasPlace.x,
39361
- y: hasPlace.y
39362
- }), result.push(text);
40711
+ 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({
40712
+ x: hasPlace.x,
40713
+ y: hasPlace.y
40714
+ }), !hideOnOverflow || this._processHideOnOverflow(text, bmpTool))) {
40715
+ result.push(text);
39363
40716
  break;
39364
40717
  }
39365
- if (!hasPlace && clampForce) {
39366
- if (this._processClampForce(text, bmpTool, bitmap, overlapPadding)) {
40718
+ if (!hasPlace) {
40719
+ if (hideOnOverflow && !this._processHideOnOverflow(text, bmpTool)) continue;
40720
+ if (clampForce && this._processClampForce(text, bmpTool, bitmap, overlapPadding)) {
39367
40721
  result.push(text);
39368
40722
  continue;
39369
40723
  }
@@ -48184,6 +49538,9 @@ class Factory {
48184
49538
  static registerChartPlugin(key, plugin) {
48185
49539
  Factory._chartPlugin[key] = plugin;
48186
49540
  }
49541
+ static registerVChartPlugin(key, plugin) {
49542
+ Factory._vChartPlugin[key] = plugin;
49543
+ }
48187
49544
  static registerComponentPlugin(key, plugin) {
48188
49545
  Factory._componentPlugin[key] = plugin;
48189
49546
  }
@@ -48300,6 +49657,9 @@ class Factory {
48300
49657
  static getChartPlugins() {
48301
49658
  return Object.values(Factory._chartPlugin);
48302
49659
  }
49660
+ static getVChartPlugins() {
49661
+ return Object.values(Factory._vChartPlugin);
49662
+ }
48303
49663
  static getComponentPlugins() {
48304
49664
  return Object.values(Factory._componentPlugin);
48305
49665
  }
@@ -48335,6 +49695,7 @@ Factory._regions = {};
48335
49695
  Factory._animations = {};
48336
49696
  Factory._implements = {};
48337
49697
  Factory._chartPlugin = {};
49698
+ Factory._vChartPlugin = {};
48338
49699
  Factory._componentPlugin = {};
48339
49700
  Factory.transforms = {
48340
49701
  fields: fields,
@@ -49136,7 +50497,7 @@ function transformIndicatorStyle(style, datum) {
49136
50497
  }
49137
50498
  function transformToGraphic(style) {
49138
50499
  if (style === null || style === void 0 ? void 0 : style.angle) {
49139
- style.angle = degreeToRadian(style.angle);
50500
+ return Object.assign(Object.assign({}, style), { angle: degreeToRadian(style.angle) });
49140
50501
  }
49141
50502
  return style;
49142
50503
  }
@@ -50398,7 +51759,7 @@ class Compiler {
50398
51759
  });
50399
51760
  }
50400
51761
  _doRender(immediately) {
50401
- var _a, _b;
51762
+ var _a, _b, _c, _d;
50402
51763
  if (this._stage) {
50403
51764
  this._rootMarks.forEach(g => {
50404
51765
  traverseGroupMark(g, m => {
@@ -50411,11 +51772,12 @@ class Compiler {
50411
51772
  }
50412
51773
  }, null, true);
50413
51774
  });
51775
+ (_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);
50414
51776
  this._stage.disableDirtyBounds();
50415
51777
  this._stage.afterNextRender(this._handleAfterNextRender);
50416
51778
  if (immediately) {
50417
51779
  this._stage.render();
50418
- (_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);
51780
+ (_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);
50419
51781
  }
50420
51782
  }
50421
51783
  }
@@ -55484,6 +56846,22 @@ const registerElementSelect = () => {
55484
56846
  Factory.registerInteractionTrigger(ElementSelect.type, ElementSelect);
55485
56847
  };
55486
56848
 
56849
+ class VChartPluginService extends BasePluginService {
56850
+ constructor(globalInstance) {
56851
+ super();
56852
+ this.globalInstance = globalInstance;
56853
+ }
56854
+ onInit() {
56855
+ this._plugins.forEach(plugin => {
56856
+ plugin.onInit && plugin.onInit(this);
56857
+ });
56858
+ }
56859
+ releaseAll() {
56860
+ super.releaseAll();
56861
+ this.globalInstance = null;
56862
+ }
56863
+ }
56864
+
55487
56865
  class VChart {
55488
56866
  static useRegisters(comps) {
55489
56867
  comps.forEach((fn) => {
@@ -56769,6 +58147,12 @@ class VChart {
56769
58147
  this._chartPlugin.load(pluginList.map(p => new p()));
56770
58148
  this._chartPluginApply('onInit', this._spec);
56771
58149
  }
58150
+ const vChartPluginList = Factory.getVChartPlugins();
58151
+ if (vChartPluginList.length > 0) {
58152
+ this._vChartPlugin = new VChartPluginService(this);
58153
+ this._vChartPlugin.load(vChartPluginList.map(p => new p()));
58154
+ this._vChartPlugin.onInit();
58155
+ }
56772
58156
  }
56773
58157
  _chartPluginApply(funcName, ...args) {
56774
58158
  if (!this._chartPlugin || !this._chartPlugin[funcName]) {
@@ -56921,7 +58305,7 @@ const lookup = (data, opt) => {
56921
58305
  });
56922
58306
  };
56923
58307
 
56924
- const version = "2.0.4-alpha.5";
58308
+ const version = "2.0.4";
56925
58309
 
56926
58310
  const addVChartProperty = (data, op) => {
56927
58311
  const context = op.beforeCall();
@@ -76472,6 +77856,13 @@ class BaseWordCloudSeries extends BaseSeries {
76472
77856
  isNil$1(this._maskShape.fontFamily)
76473
77857
  ? Object.assign({ fontFamily: this._option.getTheme('fontFamily') }, this._maskShape) : this._maskShape,
76474
77858
  onUpdateMaskCanvas: this.handleMaskCanvasUpdate,
77859
+ onLayoutFinished: () => {
77860
+ var _a, _b;
77861
+ return (_b = (_a = this._option.globalInstance
77862
+ .getChart()
77863
+ .getOption()
77864
+ .performanceHook) === null || _a === void 0 ? void 0 : _a.afterWordcloudShapeDraw) === null || _b === void 0 ? void 0 : _b.call(_a, this._option.globalInstance);
77865
+ },
76475
77866
  dataIndexKey: DEFAULT_DATA_KEY,
76476
77867
  text: wordSpec.formatMethod
76477
77868
  ? (datum) => {
@@ -88169,6 +89560,8 @@ class RangeAreaChartSpecTransformer extends CartesianChartSpecTransformer {
88169
89560
  var _a, _b;
88170
89561
  const series = super._getDefaultSeriesSpec(spec);
88171
89562
  series.area = spec.area;
89563
+ series.point = spec.point;
89564
+ series.line = spec.line;
88172
89565
  if (spec.direction === "horizontal") {
88173
89566
  series.xField = (_a = spec.xField) !== null && _a !== void 0 ? _a : [spec.minField, spec.maxField];
88174
89567
  }
@@ -91624,16 +93017,19 @@ class DataFilterBaseComponent extends BaseComponent {
91624
93017
  return active && hasChange;
91625
93018
  };
91626
93019
  this._handleChartDrag = (delta, e) => {
91627
- var _a;
93020
+ var _a, _b;
91628
93021
  if (!this._activeRoam || (this._dragAttr.filter && !this._dragAttr.filter(delta, e))) {
91629
93022
  return;
91630
93023
  }
93024
+ if ((_a = this._spec.roamDrag) === null || _a === void 0 ? void 0 : _a.autoVisible) {
93025
+ this.show();
93026
+ }
91631
93027
  const [dx, dy] = delta;
91632
93028
  let value = this._isHorizontal ? dx : dy;
91633
93029
  if (this._dragAttr.reverse) {
91634
93030
  value = -value;
91635
93031
  }
91636
- this._handleChartMove(value, (_a = this._dragAttr.rate) !== null && _a !== void 0 ? _a : 1);
93032
+ this._handleChartMove(value, (_b = this._dragAttr.rate) !== null && _b !== void 0 ? _b : 1);
91637
93033
  };
91638
93034
  this._handleChartMove = (value, rate) => {
91639
93035
  const totalValue = this._isHorizontal ? this.getLayoutRect().width : this.getLayoutRect().height;
@@ -92038,9 +93434,9 @@ class DataFilterBaseComponent extends BaseComponent {
92038
93434
  return allDomain.slice(Math.min(startIndex, endIndex), Math.max(startIndex, endIndex) + 1);
92039
93435
  }
92040
93436
  _initCommonEvent() {
92041
- var _a, _b, _c, _d, _e, _f, _g;
93437
+ var _a, _b, _c, _d, _e, _f, _g, _h;
92042
93438
  const delayType = (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.delayType) !== null && _b !== void 0 ? _b : 'throttle';
92043
- 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;
93439
+ 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;
92044
93440
  const realTime = (_g = (_f = this._spec) === null || _f === void 0 ? void 0 : _f.realTime) !== null && _g !== void 0 ? _g : true;
92045
93441
  const option = { delayType, delayTime, realTime, allowComponentZoom: true };
92046
93442
  if (this._zoomAttr.enable) {
@@ -92052,6 +93448,13 @@ class DataFilterBaseComponent extends BaseComponent {
92052
93448
  if (this._dragAttr.enable) {
92053
93449
  this.initDragEventOfRegions(this._regions, null, this._handleChartDrag, option);
92054
93450
  }
93451
+ if ((_h = this._spec.roamDrag) === null || _h === void 0 ? void 0 : _h.autoVisible) {
93452
+ const dragEnd = 'panend';
93453
+ this._throttledHide = throttle(() => this.hide(), 300);
93454
+ this.event.on(dragEnd, () => {
93455
+ this._throttledHide();
93456
+ });
93457
+ }
92055
93458
  }
92056
93459
  updateLayoutAttribute() {
92057
93460
  if (this._visible) {
@@ -92172,6 +93575,9 @@ class DataFilterBaseComponent extends BaseComponent {
92172
93575
  _getNeedClearVRenderComponents() {
92173
93576
  return [this._component];
92174
93577
  }
93578
+ clear() {
93579
+ this._throttledHide = null;
93580
+ }
92175
93581
  }
92176
93582
  mixin(DataFilterBaseComponent, Zoomable);
92177
93583
 
@@ -96249,7 +97655,7 @@ class CartesianMarkPoint extends BaseMarkPoint {
96249
97655
  this.coordinateType = 'cartesian';
96250
97656
  }
96251
97657
  _computePointsAttr() {
96252
- var _a;
97658
+ var _a, _b, _c;
96253
97659
  const spec = this._spec;
96254
97660
  const data = this._markerData;
96255
97661
  const relativeSeries = this._relativeSeries;
@@ -96259,7 +97665,7 @@ class CartesianMarkPoint extends BaseMarkPoint {
96259
97665
  const autoRange = (_a = spec === null || spec === void 0 ? void 0 : spec.autoRange) !== null && _a !== void 0 ? _a : false;
96260
97666
  let point;
96261
97667
  if (isXYLayout) {
96262
- point = xyLayout(data, relativeSeries, relativeSeries, relativeSeries, autoRange)[0][0];
97668
+ 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];
96263
97669
  }
96264
97670
  else if (isCoordinateLayout) {
96265
97671
  point = cartesianCoordinateLayout(data, relativeSeries, autoRange, spec.coordinatesOffset)[0];
@@ -98112,7 +99518,7 @@ class DomTooltipHandler extends BaseTooltipHandler {
98112
99518
  this._container = null;
98113
99519
  }
98114
99520
  _updateTooltip(visible, params) {
98115
- var _a, _b, _c;
99521
+ var _a, _b;
98116
99522
  if (!visible || !this._rootDom) {
98117
99523
  this.setVisibility(visible);
98118
99524
  this._cacheCustomTooltipPosition = undefined;
@@ -98122,29 +99528,26 @@ class DomTooltipHandler extends BaseTooltipHandler {
98122
99528
  if (!params.changePositionOnly) {
98123
99529
  this._tooltipActual = activeTooltipSpec;
98124
99530
  }
98125
- const currentVisible = this.getVisibility();
98126
99531
  const el = this._rootDom;
98127
99532
  if (el) {
98128
99533
  const { x = 0, y = 0 } = (_a = activeTooltipSpec.position) !== null && _a !== void 0 ? _a : {};
99534
+ let position = { x, y };
99535
+ const currentVisible = this.getVisibility();
98129
99536
  if (tooltipSpec.updateElement) {
98130
99537
  this._updatePosition((_b = this._cacheCustomTooltipPosition) !== null && _b !== void 0 ? _b : { x, y });
98131
99538
  tooltipSpec.updateElement(el, activeTooltipSpec, params);
98132
- const position = this._getActualTooltipPosition(activeTooltipSpec, params, {
99539
+ position = this._getActualTooltipPosition(activeTooltipSpec, params, {
98133
99540
  width: el.offsetWidth,
98134
99541
  height: el.offsetHeight
98135
99542
  });
98136
- this._updatePosition(position);
98137
99543
  this._cacheCustomTooltipPosition = position;
98138
99544
  }
98139
- else {
98140
- if (!currentVisible) {
98141
- this._rootDom.style.transitionDuration = '0ms';
98142
- }
98143
- else {
98144
- this._rootDom.style.transitionDuration = (_c = this._domStyle.panel.transitionDuration) !== null && _c !== void 0 ? _c : 'initial';
98145
- }
98146
- this._updatePosition({ x, y });
99545
+ if (!currentVisible && visible) {
99546
+ this._rootDom.style.transition = 'none';
99547
+ this._updatePosition(position, false);
99548
+ this._rootDom.getBoundingClientRect();
98147
99549
  }
99550
+ this._updatePosition(position);
98148
99551
  }
98149
99552
  this.setVisibility(visible);
98150
99553
  }
@@ -98322,9 +99725,13 @@ class DomTooltipHandler extends BaseTooltipHandler {
98322
99725
  this._updateDomStyle('height', false);
98323
99726
  }
98324
99727
  }
98325
- _updatePosition({ x, y }) {
99728
+ _updatePosition({ x, y }, resetTransition = true) {
98326
99729
  if (this._rootDom) {
98327
99730
  this._rootDom.style.transform = `translate3d(${x}px, ${y}px, 0)`;
99731
+ if (resetTransition && this._rootDom.style.transition !== '') {
99732
+ this._rootDom.style.transition = '';
99733
+ Object.assign(this._rootDom.style, this._domStyle.panel);
99734
+ }
98328
99735
  }
98329
99736
  }
98330
99737
  }