@visactor/vtable-calendar 1.19.10-alpha.0 → 1.19.10-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -588,15 +588,7 @@
588
588
  const VGlobal = Symbol.for("VGlobal");
589
589
  const DEFAULT_TEXT_FONT_FAMILY$2 = "PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol";
590
590
 
591
- const container = new Container$1();
592
-
593
- const RenderService = Symbol.for("RenderService");
594
-
595
- class Application {
596
- get renderService() {
597
- return this._renderService || (this._renderService = container.get(RenderService)), this._renderService;
598
- }
599
- }
591
+ class Application {}
600
592
  const application = new Application();
601
593
 
602
594
  let idx = 0;
@@ -4643,8 +4635,7 @@
4643
4635
  y1: 0,
4644
4636
  strokeBoundsBuffer: 0,
4645
4637
  cornerRadius: 0,
4646
- cornerType: "round",
4647
- drawStrokeWhenZeroWH: !1
4638
+ cornerType: "round"
4648
4639
  });
4649
4640
  Object.assign(Object.assign({}, DefaultAttribute), {
4650
4641
  width: 0,
@@ -4653,8 +4644,7 @@
4653
4644
  y1: 0,
4654
4645
  cornerRadius: 0,
4655
4646
  length: 0,
4656
- cornerType: "round",
4657
- drawStrokeWhenZeroWH: !1
4647
+ cornerType: "round"
4658
4648
  });
4659
4649
  const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
4660
4650
  symbolType: "circle",
@@ -4881,34 +4871,6 @@
4881
4871
  }
4882
4872
  return c;
4883
4873
  }
4884
- static processColorStops(colorStops) {
4885
- if (!colorStops || 0 === colorStops.length) return [];
4886
- if (colorStops.some(item => item.length)) {
4887
- const stops = colorStops.map(item => ({
4888
- color: item.value,
4889
- offset: item.length ? parseFloat(item.length.value) / 100 : -1
4890
- }));
4891
- stops[0].offset < 0 && (stops[0].offset = 0), stops[stops.length - 1].offset < 0 && (stops[stops.length - 1].offset = 1);
4892
- for (let i = 1; i < stops.length - 1; i++) if (stops[i].offset < 0) {
4893
- const prevWithOffsetIdx = i - 1;
4894
- let nextWithOffsetIdx = i + 1;
4895
- for (; nextWithOffsetIdx < stops.length && stops[nextWithOffsetIdx].offset < 0;) nextWithOffsetIdx++;
4896
- const startOffset = stops[prevWithOffsetIdx].offset,
4897
- endOffset = stops[nextWithOffsetIdx].offset,
4898
- unspecCount = nextWithOffsetIdx - prevWithOffsetIdx;
4899
- for (let j = 1; j < unspecCount; j++) stops[prevWithOffsetIdx + j].offset = startOffset + (endOffset - startOffset) * j / unspecCount;
4900
- i = nextWithOffsetIdx - 1;
4901
- }
4902
- return stops;
4903
- }
4904
- return colorStops.map((item, index) => {
4905
- const offset = colorStops.length > 1 ? index / (colorStops.length - 1) : 0;
4906
- return {
4907
- color: item.value,
4908
- offset: offset
4909
- };
4910
- });
4911
- }
4912
4874
  static ParseConic(datum) {
4913
4875
  const {
4914
4876
  orientation: orientation,
@@ -4922,7 +4884,10 @@
4922
4884
  y: .5,
4923
4885
  startAngle: sa,
4924
4886
  endAngle: sa + pi2,
4925
- stops: GradientParser.processColorStops(colorStops)
4887
+ stops: colorStops.map(item => ({
4888
+ color: item.value,
4889
+ offset: parseFloat(item.length.value) / 100
4890
+ }))
4926
4891
  };
4927
4892
  }
4928
4893
  static ParseRadial(datum) {
@@ -4937,7 +4902,10 @@
4937
4902
  y1: .5,
4938
4903
  r0: 0,
4939
4904
  r1: 1,
4940
- stops: GradientParser.processColorStops(colorStops)
4905
+ stops: colorStops.map(item => ({
4906
+ color: item.value,
4907
+ offset: parseFloat(item.length.value) / 100
4908
+ }))
4941
4909
  };
4942
4910
  }
4943
4911
  static ParseLinear(datum) {
@@ -4959,7 +4927,10 @@
4959
4927
  y0: y0,
4960
4928
  x1: x1,
4961
4929
  y1: y1,
4962
- stops: GradientParser.processColorStops(colorStops)
4930
+ stops: colorStops.map(item => ({
4931
+ color: item.value,
4932
+ offset: parseFloat(item.length.value) / 100
4933
+ }))
4963
4934
  };
4964
4935
  }
4965
4936
  }
@@ -5155,9 +5126,6 @@
5155
5126
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5156
5127
  };
5157
5128
  let ATextMeasure = class {
5158
- constructor() {
5159
- this.id = "ATextMeasure";
5160
- }
5161
5129
  configure(service, env) {
5162
5130
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
5163
5131
  }
@@ -5550,13 +5518,11 @@
5550
5518
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5551
5519
  };
5552
5520
  const TextMeasureContribution = Symbol.for("TextMeasureContribution");
5553
- let DefaultTextMeasureContribution = class extends ATextMeasure {
5554
- constructor() {
5555
- super(...arguments), this.id = "DefaultTextMeasureContribution";
5556
- }
5557
- };
5521
+ let DefaultTextMeasureContribution = class extends ATextMeasure {};
5558
5522
  DefaultTextMeasureContribution = __decorate$15([injectable()], DefaultTextMeasureContribution);
5559
5523
 
5524
+ const container = new Container$1();
5525
+
5560
5526
  const CanvasFactory = Symbol.for("CanvasFactory");
5561
5527
  const Context2dFactory = Symbol.for("Context2dFactory");
5562
5528
 
@@ -6133,17 +6099,13 @@
6133
6099
  return this.tryInitCanvas(), this._context;
6134
6100
  }
6135
6101
  constructor(contributions) {
6136
- this.contributions = contributions, this.configured = !1, this.global = application.global, this._textMeasureMap = new Map(), this.global.hooks.onSetEnv.tap("graphic-util", (lastEnv, env, global) => {
6102
+ this.contributions = contributions, this.configured = !1, this.global = application.global, this.global.hooks.onSetEnv.tap("graphic-util", (lastEnv, env, global) => {
6137
6103
  this.configured = !1, this.configure(global, env);
6138
6104
  });
6139
6105
  }
6140
6106
  get textMeasure() {
6141
6107
  return this._textMeasure || this.configure(this.global, this.global.env), this._textMeasure;
6142
6108
  }
6143
- getTextMeasureInstance(textMeasureId) {
6144
- if (!textMeasureId) return this.textMeasure;
6145
- return this._textMeasureMap.get(textMeasureId) || this.textMeasure;
6146
- }
6147
6109
  configure(global, env) {
6148
6110
  this.configured || (this.contributions.getContributions().forEach(contribution => {
6149
6111
  contribution.configure(this, env);
@@ -6156,7 +6118,7 @@
6156
6118
  }
6157
6119
  }
6158
6120
  bindTextMeasure(tm) {
6159
- this._textMeasure && "DefaultTextMeasureContribution" !== tm.id || (this._textMeasure = tm), this._textMeasureMap.has(tm.id) || this._textMeasureMap.set(tm.id, tm);
6121
+ this._textMeasure = tm;
6160
6122
  }
6161
6123
  measureText(text, tc, method = "native") {
6162
6124
  var _a;
@@ -9336,7 +9298,7 @@
9336
9298
  });
9337
9299
  }
9338
9300
  setAttributes(params, forceUpdateTag = !1, context) {
9339
- 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));
9301
+ (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);
9340
9302
  }
9341
9303
  _setAttributes(params, forceUpdateTag = !1, context) {
9342
9304
  const keys = Object.keys(params);
@@ -10161,8 +10123,8 @@
10161
10123
  function strokeVisible(opacity, strokeOpacity) {
10162
10124
  return opacity * strokeOpacity > 0;
10163
10125
  }
10164
- function rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH) {
10165
- return drawStrokeWhenZeroWH ? opacity * strokeOpacity > 0 : opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
10126
+ function rectStrokeVisible(opacity, strokeOpacity, width, height) {
10127
+ return opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
10166
10128
  }
10167
10129
  function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
10168
10130
  const x10 = x1 - x0,
@@ -10753,7 +10715,7 @@
10753
10715
  this.cache.layoutData.lines.forEach(item => {
10754
10716
  mergedText += item.str;
10755
10717
  });
10756
- return (Array.isArray(text) ? text.join("") : text).toString() !== mergedText;
10718
+ return (Array.isArray(text) ? text.join("") : text) !== mergedText;
10757
10719
  }
10758
10720
  return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
10759
10721
  }
@@ -10852,7 +10814,7 @@
10852
10814
  return fontSize ? .1 * fontSize : 0;
10853
10815
  }
10854
10816
  updateHorizontalMultilineAABBBounds(text) {
10855
- var _a, _b;
10817
+ var _a;
10856
10818
  const textTheme = this.getGraphicTheme(),
10857
10819
  attribute = this.attribute,
10858
10820
  {
@@ -10879,7 +10841,7 @@
10879
10841
  const bbox = this.cache.layoutData.bbox;
10880
10842
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
10881
10843
  }
10882
- const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_b = this.stage) || void 0 === _b ? void 0 : _b.textMeasureId)),
10844
+ const textMeasure = application.graphicUtil.textMeasure,
10883
10845
  layoutData = new CanvasTextLayout(fontFamily, {
10884
10846
  fontSize: fontSize,
10885
10847
  fontWeight: fontWeight,
@@ -10897,7 +10859,7 @@
10897
10859
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
10898
10860
  }
10899
10861
  updateWrapAABBBounds(text) {
10900
- var _a, _b, _c, _d;
10862
+ var _a, _b, _c;
10901
10863
  const textTheme = this.getGraphicTheme(),
10902
10864
  {
10903
10865
  fontFamily = textTheme.fontFamily,
@@ -10923,7 +10885,7 @@
10923
10885
  const bbox = this.cache.layoutData.bbox;
10924
10886
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
10925
10887
  }
10926
- const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_b = this.stage) || void 0 === _b ? void 0 : _b.textMeasureId)),
10888
+ const textMeasure = application.graphicUtil.textMeasure,
10927
10889
  textOptions = {
10928
10890
  fontSize: fontSize,
10929
10891
  fontWeight: fontWeight,
@@ -10955,7 +10917,7 @@
10955
10917
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
10956
10918
  if (ellipsis) {
10957
10919
  const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
10958
- clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
10920
+ clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
10959
10921
  } else clip.str = "", clip.width = 0;
10960
10922
  needCut = !1;
10961
10923
  }
@@ -11018,9 +10980,9 @@
11018
10980
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
11019
10981
  }
11020
10982
  updateVerticalMultilineAABBBounds(text) {
11021
- var _a, _b, _c;
10983
+ var _a, _b;
11022
10984
  const textTheme = this.getGraphicTheme(),
11023
- textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_a = this.stage) || void 0 === _a ? void 0 : _a.textMeasureId));
10985
+ textMeasure = application.graphicUtil.textMeasure;
11024
10986
  let width;
11025
10987
  const attribute = this.attribute,
11026
10988
  {
@@ -11041,7 +11003,7 @@
11041
11003
  } = attribute;
11042
11004
  if (!verticalMode) {
11043
11005
  const t = textAlign;
11044
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
11006
+ textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
11045
11007
  }
11046
11008
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
11047
11009
  this.cache.verticalList.forEach(item => {
@@ -11155,7 +11117,7 @@
11155
11117
  return isArray$9(text) ? !text.every(t => null == t || "" === t) : null != text && "" !== text;
11156
11118
  }
11157
11119
  updateMultilineAABBBounds(text) {
11158
- var _a, _b, _c, _d, _e;
11120
+ var _a, _b, _c, _d;
11159
11121
  const textTheme = this.getGraphicTheme(),
11160
11122
  {
11161
11123
  fontFamily = textTheme.fontFamily,
@@ -11179,7 +11141,7 @@
11179
11141
  const bbox = this.cache.layoutData.bbox;
11180
11142
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
11181
11143
  }
11182
- const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_c = this.stage) || void 0 === _c ? void 0 : _c.textMeasureId)),
11144
+ const textMeasure = application.graphicUtil.textMeasure,
11183
11145
  layoutObj = new CanvasTextLayout(fontFamily, {
11184
11146
  fontSize: fontSize,
11185
11147
  fontWeight: fontWeight,
@@ -11208,7 +11170,7 @@
11208
11170
  if ("" !== str && "" === clip.str) {
11209
11171
  if (ellipsis) {
11210
11172
  const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
11211
- clip.str = null !== (_d = clipEllipsis.str) && void 0 !== _d ? _d : "", clip.width = null !== (_e = clipEllipsis.width) && void 0 !== _e ? _e : 0;
11173
+ clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
11212
11174
  } else clip.str = "", clip.width = 0;
11213
11175
  needCut = !1;
11214
11176
  }
@@ -12312,7 +12274,7 @@
12312
12274
  case "right":
12313
12275
  deltaX = -aabbBounds.width();
12314
12276
  }
12315
- 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;
12277
+ 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;
12316
12278
  }
12317
12279
  needUpdateTags(keys) {
12318
12280
  return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
@@ -13979,7 +13941,7 @@
13979
13941
  doFill && (fillCb ? fillCb(context, arc.attribute, arcAttribute) : fVisible && (context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.fill()));
13980
13942
  }
13981
13943
  _runStroke(arc, context, x, y, arcAttribute, doStroke, isFullStroke, sVisible, strokeCb) {
13982
- doStroke && isFullStroke && (strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
13944
+ doStroke && isFullStroke && (strokeCb || sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
13983
13945
  }
13984
13946
  draw(arc, renderService, drawContext, params) {
13985
13947
  const arcAttribute = getTheme(arc, null == params ? void 0 : params.theme).arc;
@@ -14711,8 +14673,7 @@
14711
14673
  y1: y1,
14712
14674
  x: originX = rectAttribute.x,
14713
14675
  y: originY = rectAttribute.y,
14714
- fillStrokeOrder = rectAttribute.fillStrokeOrder,
14715
- drawStrokeWhenZeroWH = rectAttribute.drawStrokeWhenZeroWH
14676
+ fillStrokeOrder = rectAttribute.fillStrokeOrder
14716
14677
  } = rect.attribute;
14717
14678
  let {
14718
14679
  width: width,
@@ -14720,7 +14681,7 @@
14720
14681
  } = rect.attribute;
14721
14682
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
14722
14683
  const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
14723
- sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH),
14684
+ sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
14724
14685
  doFill = runFill(fill, background),
14725
14686
  doStroke = runStroke(stroke, lineWidth);
14726
14687
  if (!rect.valid || !visible) return;
@@ -15638,6 +15599,7 @@
15638
15599
  decorator(target, key, paramIndex);
15639
15600
  };
15640
15601
  };
15602
+ const RenderService = Symbol.for("RenderService");
15641
15603
  let DefaultRenderService = class {
15642
15604
  constructor(drawContribution) {
15643
15605
  this.drawContribution = drawContribution;
@@ -16526,6 +16488,8 @@
16526
16488
  application.transformUtil = transformUtil;
16527
16489
  const graphicService = container.get(GraphicService);
16528
16490
  application.graphicService = graphicService;
16491
+ const renderService = container.get(RenderService);
16492
+ application.renderService = renderService;
16529
16493
  const layerService = container.get(LayerService);
16530
16494
  application.layerService = layerService;
16531
16495
 
@@ -16778,13 +16742,13 @@
16778
16742
  this._skipRender > 1 && this.renderNextFrame(), this._skipRender = 0;
16779
16743
  } else this._skipRender = 1;
16780
16744
  }, this.beforeRender = stage => {
16781
- this._beforeRenderList.forEach(cb => cb(stage));
16745
+ this._beforeRender && this._beforeRender(stage);
16782
16746
  }, this.afterClearScreen = drawParams => {
16783
16747
  this._afterClearScreen && this._afterClearScreen(drawParams);
16784
16748
  }, this.afterClearRect = drawParams => {
16785
16749
  this._afterClearRect && this._afterClearRect(drawParams);
16786
16750
  }, this.afterRender = stage => {
16787
- this.renderCount++, this._afterRenderList.forEach(cb => cb(stage)), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
16751
+ this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
16788
16752
  }, this.afterTickCb = () => {
16789
16753
  this.tickedBeforeRender = !0, "rendering" !== this.state && this.renderNextFrame();
16790
16754
  }, this.params = params, this.theme = new Theme(), this.hooks = {
@@ -16792,7 +16756,7 @@
16792
16756
  afterRender: new SyncHook(["stage"]),
16793
16757
  afterClearScreen: new SyncHook(["stage"]),
16794
16758
  afterClearRect: new SyncHook(["stage"])
16795
- }, 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({
16759
+ }, 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({
16796
16760
  width: params.width,
16797
16761
  height: params.height,
16798
16762
  viewBox: params.viewBox,
@@ -16803,7 +16767,7 @@
16803
16767
  canvas: params.canvas
16804
16768
  }), 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, {
16805
16769
  main: !0
16806
- })), 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 = {
16770
+ })), 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 = {
16807
16771
  tickRenderMode: "effect"
16808
16772
  }), this.optmize(params.optimize), params.background && isString$6(this._background) && this._background.includes("/") && this.setAttributes({
16809
16773
  background: this._background
@@ -16918,16 +16882,10 @@
16918
16882
  options.enableView3dTransform && this.enableView3dTransform();
16919
16883
  }
16920
16884
  setBeforeRender(cb) {
16921
- this._beforeRenderList.push(cb);
16922
- }
16923
- removeBeforeRender(cb) {
16924
- this._beforeRenderList = this._beforeRenderList.filter(c => c !== cb);
16885
+ this._beforeRender = cb;
16925
16886
  }
16926
16887
  setAfterRender(cb) {
16927
- this._afterRenderList.push(cb);
16928
- }
16929
- removeAfterRender(cb) {
16930
- this._afterRenderList = this._afterRenderList.filter(c => c !== cb);
16888
+ this._afterRender = cb;
16931
16889
  }
16932
16890
  afterNextRender(cb) {
16933
16891
  this._afterNextRenderCbs || (this._afterNextRenderCbs = []), this._afterNextRenderCbs.push(cb);
@@ -23625,7 +23583,6 @@
23625
23583
  return this.getEndProps();
23626
23584
  }
23627
23585
  stop() {}
23628
- release() {}
23629
23586
  }
23630
23587
  class WaitStep extends Step {
23631
23588
  constructor(type, props, duration, easing) {
@@ -23633,6 +23590,8 @@
23633
23590
  }
23634
23591
  onStart() {
23635
23592
  super.onStart();
23593
+ }
23594
+ onFirstRun() {
23636
23595
  const fromProps = this.getFromProps();
23637
23596
  this.target.setAttributes(fromProps);
23638
23597
  }
@@ -23841,9 +23800,7 @@
23841
23800
  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));
23842
23801
  }
23843
23802
  release() {
23844
- this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [], this.forEachStep(step => {
23845
- step.release();
23846
- });
23803
+ this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [];
23847
23804
  }
23848
23805
  getDuration() {
23849
23806
  return this._duration;
@@ -23917,10 +23874,6 @@
23917
23874
  getLoop() {
23918
23875
  return this._loopCount;
23919
23876
  }
23920
- forEachStep(cb) {
23921
- let step = this._firstStep;
23922
- for (; step;) cb(step), step = step.next;
23923
- }
23924
23877
  }
23925
23878
 
23926
23879
  const performanceRAF = new PerformanceRAF();
@@ -24153,9 +24106,6 @@
24153
24106
  constructor(target) {
24154
24107
  this._animates = [], this._startCallbacks = [], this._endCallbacks = [], this._started = !1, this._activeCount = 0, this._target = target;
24155
24108
  }
24156
- get started() {
24157
- return this._started;
24158
- }
24159
24109
  onStart(cb) {
24160
24110
  cb ? (this._startCallbacks.push(cb), this._started && this._activeCount > 0 && cb()) : this._startCallbacks.forEach(cb => {
24161
24111
  cb();
@@ -24296,14 +24246,14 @@
24296
24246
  return delayAfterValue > 0 && (totalDelay += delayAfterValue), totalDelay > 0 && animate.wait(totalDelay), loop && loop > 0 && animate.loop(loop), bounce && animate.bounce(!0), animate;
24297
24247
  }
24298
24248
  _handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic) {
24299
- var _a, _b, _c, _d, _e, _f;
24249
+ var _a, _b, _c, _d;
24300
24250
  if (custom && customType) {
24301
24251
  const customParams = Object.assign({
24302
- width: (null === (_a = graphic.stage) || void 0 === _a ? void 0 : _a.width) || 0,
24303
- height: (null === (_b = graphic.stage) || void 0 === _b ? void 0 : _b.height) || 0,
24252
+ width: graphic.stage.width,
24253
+ height: graphic.stage.height,
24304
24254
  group: this._target.parent
24305
24255
  }, this.resolveValue(customParameters, graphic)),
24306
- objOptions = isFunction$7(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;
24256
+ objOptions = isFunction$7(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;
24307
24257
  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);
24308
24258
  } else "to" === type ? animate.to(props, duration, easing) : "from" === type && animate.from(props, duration, easing);
24309
24259
  }
@@ -24523,7 +24473,7 @@
24523
24473
  reApplyState(state) {
24524
24474
  var _a;
24525
24475
  const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find(stateInfo => stateInfo.state === state);
24526
- if (stateInfo && stateInfo.executor.started) {
24476
+ if (stateInfo) {
24527
24477
  const stateList = this.stateList.slice();
24528
24478
  stateInfo.executor.stop(), this.stateList = stateList, stateInfo.executor.execute(stateInfo.animationConfig);
24529
24479
  }
@@ -24666,45 +24616,6 @@
24666
24616
  this._animator && this._animator.stop();
24667
24617
  }
24668
24618
  }
24669
- class AStageAnimate extends ACustomAnimate {
24670
- constructor(customFrom, customTo, duration, easing, params) {
24671
- super(customFrom, customTo, duration, easing, params), this.willCallBeforeStageRender = !0, this.willCallAfterStageRender = !0, this._beforeStageRender = () => {
24672
- if (!this.willCallBeforeStageRender) return;
24673
- this.willCallBeforeStageRender = !1;
24674
- const stage = this.target.stage,
24675
- canvas = stage.window.getContext().canvas.nativeCanvas,
24676
- outputCanvas = this.beforeStageRender(stage, canvas);
24677
- outputCanvas && this.renderToStage(stage, outputCanvas);
24678
- }, this._afterStageRender = () => {
24679
- if (!this.willCallAfterStageRender) return;
24680
- this.willCallAfterStageRender = !1;
24681
- const stage = this.target.stage,
24682
- canvas = stage.window.getContext().canvas.nativeCanvas,
24683
- outputCanvas = this.afterStageRender(stage, canvas);
24684
- outputCanvas && this.renderToStage(stage, outputCanvas);
24685
- }, this.props = {};
24686
- }
24687
- beforeStageRender(stage, canvas) {
24688
- return !1;
24689
- }
24690
- afterStageRender(stage, canvas) {
24691
- return !1;
24692
- }
24693
- onFirstRun() {
24694
- super.onFirstRun(), this.target.stage.setBeforeRender(this._beforeStageRender), this.target.stage.setAfterRender(this._afterStageRender), this.target.stage.disableDirtyBounds();
24695
- }
24696
- stop() {
24697
- super.stop(), this.target.stage.removeBeforeRender(this._beforeStageRender), this.target.stage.removeAfterRender(this._afterStageRender);
24698
- }
24699
- onUpdate(end, ratio, out) {
24700
- super.onUpdate(end, ratio, out), this.willCallBeforeStageRender = !0, this.willCallAfterStageRender = !0;
24701
- }
24702
- renderToStage(stage, canvas) {
24703
- const stageCanvas = stage.window.getContext().canvas.nativeCanvas,
24704
- ctx = stageCanvas.getContext("2d");
24705
- return !!ctx && (ctx.clearRect(0, 0, stageCanvas.width, stageCanvas.height), ctx.drawImage(canvas, 0, 0), stageCanvas);
24706
- }
24707
- }
24708
24619
 
24709
24620
  class ComponentAnimator {
24710
24621
  constructor(component) {
@@ -25087,7 +24998,7 @@
25087
24998
  }
25088
24999
  class GrowAngleIn extends GrowAngleBase {
25089
25000
  onBind() {
25090
- var _a, _b, _c;
25001
+ var _a, _b;
25091
25002
  super.onBind();
25092
25003
  const {
25093
25004
  from: from,
@@ -25096,7 +25007,7 @@
25096
25007
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
25097
25008
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
25098
25009
  const finalAttribute = this.target.getFinalAttribute();
25099
- finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs), this.determineUpdateFunction();
25010
+ finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs), this.determineUpdateFunction();
25100
25011
  }
25101
25012
  }
25102
25013
  class GrowAngleOut extends GrowAngleBase {
@@ -25704,7 +25615,7 @@
25704
25615
  }
25705
25616
  class GrowRadiusIn extends GrowPointsBase {
25706
25617
  onBind() {
25707
- var _a, _b, _c;
25618
+ var _a, _b;
25708
25619
  super.onBind();
25709
25620
  const {
25710
25621
  from: from,
@@ -25713,7 +25624,7 @@
25713
25624
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
25714
25625
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
25715
25626
  const finalAttribute = this.target.getFinalAttribute();
25716
- finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
25627
+ finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
25717
25628
  }
25718
25629
  }
25719
25630
  class GrowRadiusOut extends GrowPointsBase {
@@ -25828,7 +25739,7 @@
25828
25739
  super(from, to, duration, easing, params);
25829
25740
  }
25830
25741
  onBind() {
25831
- var _a, _b, _c;
25742
+ var _a, _b;
25832
25743
  super.onBind();
25833
25744
  const {
25834
25745
  from: from,
@@ -25837,7 +25748,7 @@
25837
25748
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
25838
25749
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
25839
25750
  const finalAttribute = this.target.getFinalAttribute();
25840
- finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
25751
+ finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
25841
25752
  }
25842
25753
  onEnd(cb) {
25843
25754
  super.onEnd(cb);
@@ -27621,1271 +27532,8 @@
27621
27532
  }
27622
27533
  }
27623
27534
 
27624
- class DisappearAnimateBase extends AStageAnimate {
27625
- constructor(from, to, duration, easing, params) {
27626
- super(from, to, duration, easing, params), this.webglCanvas = null, this.gl = null, this.program = null, this.currentAnimationRatio = 0, this.animationTime = 0;
27627
- }
27628
- onUpdate(end, ratio, out) {
27629
- super.onUpdate(end, ratio, out), this.currentAnimationRatio = ratio, this.animationTime = ratio * Math.PI * 2;
27630
- }
27631
- getAnimationTime() {
27632
- return this.currentAnimationRatio > 0 ? this.animationTime : Date.now() / 1e3;
27633
- }
27634
- getDurationFromParent() {
27635
- return this.duration || 1e3;
27636
- }
27637
- initWebGL(canvas) {
27638
- try {
27639
- if (this.webglCanvas = vglobal.createCanvas({
27640
- width: canvas.width,
27641
- height: canvas.height,
27642
- dpr: vglobal.devicePixelRatio
27643
- }), !this.webglCanvas) return (void 0), !1;
27644
- this.webglCanvas.style.width = canvas.style.width || `${canvas.width}px`, this.webglCanvas.style.height = canvas.style.height || `${canvas.height}px`;
27645
- let glContext = null;
27646
- try {
27647
- glContext = this.webglCanvas.getContext("webgl"), glContext || (glContext = this.webglCanvas.getContext("experimental-webgl"));
27648
- } catch (e) {
27649
- }
27650
- if (this.gl = glContext, !this.gl) return (void 0), !1;
27651
- const shaders = this.getShaderSources();
27652
- return this.program = this.createShaderProgram(shaders.vertex, shaders.fragment), null !== this.program;
27653
- } catch (error) {
27654
- return !1;
27655
- }
27656
- }
27657
- createShaderProgram(vertexSource, fragmentSource) {
27658
- if (!this.gl) return null;
27659
- const vertexShader = this.createShader(this.gl.VERTEX_SHADER, vertexSource),
27660
- fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, fragmentSource);
27661
- if (!vertexShader || !fragmentShader) return null;
27662
- const program = this.gl.createProgram();
27663
- 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 : (null)) : null;
27664
- }
27665
- createShader(type, source) {
27666
- if (!this.gl) return null;
27667
- const shader = this.gl.createShader(type);
27668
- return shader ? (this.gl.shaderSource(shader, source), this.gl.compileShader(shader), this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS) ? shader : (this.gl.deleteShader(shader), null)) : null;
27669
- }
27670
- setupWebGLState(canvas) {
27671
- 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));
27672
- }
27673
- createFullScreenQuad() {
27674
- if (!this.gl) return null;
27675
- const vertices = new Float32Array([-1, -1, 0, 1, 1, -1, 1, 1, -1, 1, 0, 0, 1, 1, 1, 0]),
27676
- vertexBuffer = this.gl.createBuffer();
27677
- return this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertexBuffer), this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW), vertexBuffer;
27678
- }
27679
- createTextureFromCanvas(canvas) {
27680
- if (!this.gl) return null;
27681
- const texture = this.gl.createTexture();
27682
- 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;
27683
- }
27684
- setupVertexAttributes() {
27685
- if (!this.gl || !this.program) return;
27686
- const positionLocation = this.gl.getAttribLocation(this.program, "a_position"),
27687
- texCoordLocation = this.gl.getAttribLocation(this.program, "a_texCoord");
27688
- 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);
27689
- }
27690
- createOutputCanvas(canvas) {
27691
- const outputCanvas = vglobal.createCanvas({
27692
- width: canvas.width,
27693
- height: canvas.height,
27694
- dpr: vglobal.devicePixelRatio
27695
- }),
27696
- ctx = outputCanvas.getContext("2d");
27697
- return ctx ? (ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.drawImage(canvas, 0, 0), {
27698
- canvas: outputCanvas,
27699
- ctx: ctx
27700
- }) : null;
27701
- }
27702
- getShaderSources() {
27703
- return null;
27704
- }
27705
- applyWebGLEffect(canvas) {
27706
- return null;
27707
- }
27708
- applyCanvas2DEffect(canvas) {
27709
- return null;
27710
- }
27711
- supportsWebGL() {
27712
- return null !== this.getShaderSources();
27713
- }
27714
- supportsCanvas2D() {
27715
- return this.applyCanvas2DEffect !== DisappearAnimateBase.prototype.applyCanvas2DEffect;
27716
- }
27717
- release() {
27718
- 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;
27719
- }
27720
- afterStageRender(stage, canvas) {
27721
- let result = null;
27722
- if (this.supportsWebGL() && (this.gl || this.initWebGL(canvas) || (void 0), this.gl)) {
27723
- if (result = this.applyWebGLEffect(canvas), result) return result;
27724
- }
27725
- if (this.supportsCanvas2D()) {
27726
- if (result = this.applyCanvas2DEffect(canvas), result) return result;
27727
- }
27728
- return this.supportsWebGL() || this.supportsCanvas2D() || (void 0), canvas;
27729
- }
27730
- }
27731
-
27732
- class Canvas2DEffectBase extends DisappearAnimateBase {
27733
- constructor(from, to, duration, easing, params) {
27734
- super(from, to, duration, easing, params);
27735
- }
27736
- getShaderSources() {
27737
- return null;
27738
- }
27739
- applyWebGLEffect(canvas) {
27740
- return null;
27741
- }
27742
- }
27743
- class HybridEffectBase extends DisappearAnimateBase {
27744
- constructor(from, to, duration, easing, params) {
27745
- super(from, to, duration, easing, params);
27746
- }
27747
- getShaderSources() {
27748
- return null;
27749
- }
27750
- applyWebGLEffect(canvas) {
27751
- return null;
27752
- }
27753
- applyCanvas2DEffect(canvas) {
27754
- return null;
27755
- }
27756
- supportsWebGL() {
27757
- return this.getShaderSources !== HybridEffectBase.prototype.getShaderSources && null !== this.getShaderSources();
27758
- }
27759
- supportsCanvas2D() {
27760
- return this.applyCanvas2DEffect !== HybridEffectBase.prototype.applyCanvas2DEffect;
27761
- }
27762
- afterStageRender(stage, canvas) {
27763
- var _a, _b;
27764
- let result = null;
27765
- if (!1 !== (null === (_b = null === (_a = this.params) || void 0 === _a ? void 0 : _a.options) || void 0 === _b ? void 0 : _b.useWebGL)) {
27766
- if (this.supportsWebGL() && (this.gl || this.initWebGL(canvas) || (void 0), this.gl)) {
27767
- if (result = this.applyWebGLEffect(canvas), result) return result;
27768
- }
27769
- if (this.supportsCanvas2D()) {
27770
- if (result = this.applyCanvas2DEffect(canvas), result) return result;
27771
- }
27772
- } else if (this.supportsCanvas2D()) {
27773
- if (result = this.applyCanvas2DEffect(canvas), result) return result;
27774
- } else ;
27775
- return this.supportsWebGL() || this.supportsCanvas2D() || (void 0), canvas;
27776
- }
27777
- }
27778
-
27779
- class ImageProcessUtils {
27780
- static createTempCanvas(width, height, dpr) {
27781
- return vglobal.createCanvas({
27782
- width: width,
27783
- height: height,
27784
- dpr: dpr || vglobal.devicePixelRatio
27785
- });
27786
- }
27787
- static cloneImageData(imageData) {
27788
- const clonedData = new Uint8ClampedArray(imageData.data);
27789
- return new ImageData(clonedData, imageData.width, imageData.height);
27790
- }
27791
- static lerp(start, end, t) {
27792
- return start * (1 - t) + end * t;
27793
- }
27794
- static smoothstep(edge0, edge1, x) {
27795
- const t = Math.max(0, Math.min(1, (x - edge0) / (edge1 - edge0)));
27796
- return t * t * (3 - 2 * t);
27797
- }
27798
- static distance(x1, y1, x2, y2) {
27799
- const dx = x2 - x1,
27800
- dy = y2 - y1;
27801
- return Math.sqrt(dx * dx + dy * dy);
27802
- }
27803
- static normalizeAngle(angle) {
27804
- return (angle + Math.PI) / (2 * Math.PI);
27805
- }
27806
- static pixelNoise(x, y, pixelSize) {
27807
- if (pixelSize <= 0) return 0;
27808
- const gridX = Math.floor(x / pixelSize) * pixelSize,
27809
- gridY = Math.floor(y / pixelSize) * pixelSize,
27810
- n = 43758.5453 * Math.sin(12.9898 * gridX + 78.233 * gridY);
27811
- return n - Math.floor(n);
27812
- }
27813
- static generateNoiseTexture(width, height) {
27814
- const data = new Uint8Array(width * height);
27815
- for (let i = 0; i < data.length; i++) data[i] = Math.floor(256 * Math.random());
27816
- return data;
27817
- }
27818
- static applyCSSFilter(canvas, filter) {
27819
- const outputCanvas = this.createTempCanvas(canvas.width, canvas.height),
27820
- ctx = outputCanvas.getContext("2d");
27821
- return ctx ? (ctx.filter = filter, ctx.drawImage(canvas, 0, 0), ctx.filter = "none", outputCanvas) : canvas;
27822
- }
27823
- static extractChannel(imageData, channelIndex) {
27824
- const {
27825
- data: data,
27826
- width: width,
27827
- height: height
27828
- } = imageData,
27829
- channelData = new Uint8ClampedArray(data.length);
27830
- 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]);
27831
- return new ImageData(channelData, width, height);
27832
- }
27833
- static blendImageData(imageData1, imageData2, ratio) {
27834
- const {
27835
- data: data1,
27836
- width: width,
27837
- height: height
27838
- } = imageData1,
27839
- {
27840
- data: data2
27841
- } = imageData2,
27842
- result = new Uint8ClampedArray(data1.length);
27843
- 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));
27844
- return new ImageData(result, width, height);
27845
- }
27846
- static getLuminance(r, g, b) {
27847
- return .299 * r + .587 * g + .114 * b;
27848
- }
27849
- static applySepiaToPixel(r, g, b) {
27850
- 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)];
27851
- }
27852
- static calculateDynamicStrength(baseStrength, animationTime) {
27853
- return baseStrength * (animationTime / (2 * Math.PI));
27854
- }
27855
- }
27856
- class ShaderLibrary {}
27857
- 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 ";
27858
-
27859
- class Dissolve extends HybridEffectBase {
27860
- constructor(from, to, duration, easing, params) {
27861
- var _a, _b, _c, _d;
27862
- super(from, to, duration, easing, params), this.noiseData = null;
27863
- const rawNoiseScale = null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.noiseScale,
27864
- clampedNoiseScale = void 0 !== rawNoiseScale ? Math.max(0, Math.floor(rawNoiseScale)) : 8;
27865
- this.dissolveConfig = {
27866
- dissolveType: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.dissolveType) || "outward",
27867
- useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL,
27868
- noiseScale: clampedNoiseScale,
27869
- fadeEdge: void 0 === (null === (_d = null == params ? void 0 : params.options) || void 0 === _d ? void 0 : _d.fadeEdge) || params.options.fadeEdge
27870
- };
27871
- }
27872
- getShaderSources() {
27873
- return {
27874
- vertex: ShaderLibrary.STANDARD_VERTEX_SHADER,
27875
- 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 `
27876
- };
27877
- }
27878
- applyWebGLEffect(canvas) {
27879
- if (!this.gl || !this.program || !this.webglCanvas) return canvas;
27880
- this.setupWebGLState(canvas);
27881
- const texture = this.createTextureFromCanvas(canvas);
27882
- if (!texture) return canvas;
27883
- this.noiseData || (this.noiseData = ImageProcessUtils.generateNoiseTexture(256, 256));
27884
- const noiseTexture = this.gl.createTexture();
27885
- 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);
27886
- const vertexBuffer = this.createFullScreenQuad();
27887
- 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;
27888
- }
27889
- setUniforms() {
27890
- if (!this.gl || !this.program || !this.webglCanvas) return;
27891
- const textureLocation = this.gl.getUniformLocation(this.program, "u_texture"),
27892
- noiseTextureLocation = this.gl.getUniformLocation(this.program, "u_noiseTexture"),
27893
- timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
27894
- dissolveTypeLocation = this.gl.getUniformLocation(this.program, "u_dissolveType"),
27895
- resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution"),
27896
- noiseScaleLocation = this.gl.getUniformLocation(this.program, "u_noiseScale"),
27897
- fadeEdgeLocation = this.gl.getUniformLocation(this.program, "u_fadeEdge");
27898
- 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);
27899
- this.gl.uniform1i(dissolveTypeLocation, {
27900
- outward: 0,
27901
- inward: 1,
27902
- radial: 2,
27903
- leftToRight: 3,
27904
- rightToLeft: 4,
27905
- topToBottom: 5,
27906
- bottomToTop: 6
27907
- }[this.dissolveConfig.dissolveType] || 0);
27908
- }
27909
- applyCanvas2DEffect(canvas) {
27910
- const outputCanvas = this.createOutputCanvas(canvas);
27911
- if (!outputCanvas) return canvas;
27912
- const {
27913
- canvas: outputCanvasElement,
27914
- ctx: ctx
27915
- } = outputCanvas,
27916
- imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
27917
- progress = this.currentAnimationRatio;
27918
- let dissolvedImageData;
27919
- switch (this.dissolveConfig.dissolveType) {
27920
- case "outward":
27921
- dissolvedImageData = this.applyOutwardDissolve(imageData, progress);
27922
- break;
27923
- case "inward":
27924
- dissolvedImageData = this.applyInwardDissolve(imageData, progress);
27925
- break;
27926
- case "radial":
27927
- dissolvedImageData = this.applyRadialDissolve(imageData, progress);
27928
- break;
27929
- case "leftToRight":
27930
- dissolvedImageData = this.applyLeftToRightDissolve(imageData, progress);
27931
- break;
27932
- case "rightToLeft":
27933
- dissolvedImageData = this.applyRightToLeftDissolve(imageData, progress);
27934
- break;
27935
- case "topToBottom":
27936
- dissolvedImageData = this.applyTopToBottomDissolve(imageData, progress);
27937
- break;
27938
- case "bottomToTop":
27939
- dissolvedImageData = this.applyBottomToTopDissolve(imageData, progress);
27940
- break;
27941
- default:
27942
- dissolvedImageData = imageData;
27943
- }
27944
- return ctx.putImageData(dissolvedImageData, 0, 0), outputCanvasElement;
27945
- }
27946
- applyOutwardDissolve(imageData, progress) {
27947
- const {
27948
- data: data,
27949
- width: width,
27950
- height: height
27951
- } = imageData,
27952
- result = new Uint8ClampedArray(data.length);
27953
- result.set(data);
27954
- const centerX = width / 2,
27955
- centerY = height / 2,
27956
- maxDist = Math.sqrt(centerX * centerX + centerY * centerY),
27957
- pixelSize = this.dissolveConfig.noiseScale;
27958
- for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
27959
- const dx = x - centerX,
27960
- dy = y - centerY,
27961
- normalizedDist = Math.sqrt(dx * dx + dy * dy) / maxDist;
27962
- let dissolveThreshold = 1.2 - 1.4 * progress,
27963
- alpha = 1;
27964
- if (pixelSize > 0) {
27965
- dissolveThreshold += .4 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedDist > dissolveThreshold ? 0 : 1;
27966
- } else if (this.dissolveConfig.fadeEdge) {
27967
- const fadeStart = dissolveThreshold - .15;
27968
- alpha = normalizedDist < fadeStart ? 1 : normalizedDist > dissolveThreshold ? 0 : 1 - (normalizedDist - fadeStart) / (dissolveThreshold - fadeStart);
27969
- } else alpha = normalizedDist > dissolveThreshold ? 0 : 1;
27970
- const index = 4 * (y * width + x);
27971
- result[index + 3] = Math.floor(result[index + 3] * alpha);
27972
- }
27973
- return new ImageData(result, width, height);
27974
- }
27975
- applyInwardDissolve(imageData, progress) {
27976
- const {
27977
- data: data,
27978
- width: width,
27979
- height: height
27980
- } = imageData,
27981
- result = new Uint8ClampedArray(data.length);
27982
- result.set(data);
27983
- const centerX = width / 2,
27984
- centerY = height / 2,
27985
- maxDist = Math.sqrt(centerX * centerX + centerY * centerY),
27986
- pixelSize = this.dissolveConfig.noiseScale;
27987
- for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
27988
- const dx = x - centerX,
27989
- dy = y - centerY,
27990
- normalizedDist = Math.sqrt(dx * dx + dy * dy) / maxDist;
27991
- let dissolveThreshold = 1.4 * progress,
27992
- alpha = 1;
27993
- if (pixelSize > 0) {
27994
- dissolveThreshold += .4 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedDist < dissolveThreshold ? 0 : 1;
27995
- } else if (this.dissolveConfig.fadeEdge) {
27996
- const fadeEnd = dissolveThreshold + .15;
27997
- alpha = normalizedDist < dissolveThreshold ? 0 : normalizedDist > fadeEnd ? 1 : (normalizedDist - dissolveThreshold) / (fadeEnd - dissolveThreshold);
27998
- } else alpha = normalizedDist < dissolveThreshold ? 0 : 1;
27999
- const index = 4 * (y * width + x);
28000
- result[index + 3] = Math.floor(result[index + 3] * alpha);
28001
- }
28002
- return new ImageData(result, width, height);
28003
- }
28004
- applyRadialDissolve(imageData, progress) {
28005
- const {
28006
- data: data,
28007
- width: width,
28008
- height: height
28009
- } = imageData,
28010
- result = new Uint8ClampedArray(data.length);
28011
- result.set(data);
28012
- const centerX = width / 2,
28013
- centerY = height / 2,
28014
- pixelSize = this.dissolveConfig.noiseScale;
28015
- for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28016
- const dx = x - centerX,
28017
- dy = y - centerY,
28018
- normalizedAngle = (Math.atan2(dy, dx) + Math.PI) / (2 * Math.PI);
28019
- let dissolveThreshold = 1.2 * progress,
28020
- alpha = 1;
28021
- if (pixelSize > 0) {
28022
- dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedAngle < dissolveThreshold ? 0 : 1;
28023
- } else if (this.dissolveConfig.fadeEdge) {
28024
- const fadeEnd = dissolveThreshold + .08;
28025
- alpha = normalizedAngle < dissolveThreshold ? 0 : normalizedAngle > fadeEnd ? 1 : (normalizedAngle - dissolveThreshold) / (fadeEnd - dissolveThreshold);
28026
- } else alpha = normalizedAngle < dissolveThreshold ? 0 : 1;
28027
- const index = 4 * (y * width + x);
28028
- result[index + 3] = Math.floor(result[index + 3] * alpha);
28029
- }
28030
- return new ImageData(result, width, height);
28031
- }
28032
- applyLeftToRightDissolve(imageData, progress) {
28033
- const {
28034
- data: data,
28035
- width: width,
28036
- height: height
28037
- } = imageData,
28038
- result = new Uint8ClampedArray(data.length);
28039
- result.set(data);
28040
- const pixelSize = this.dissolveConfig.noiseScale;
28041
- for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28042
- const normalizedX = x / width;
28043
- let dissolveThreshold = 1.2 * progress,
28044
- alpha = 1;
28045
- if (pixelSize > 0) {
28046
- dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedX < dissolveThreshold ? 0 : 1;
28047
- } else if (this.dissolveConfig.fadeEdge) {
28048
- const fadeEnd = dissolveThreshold + .08;
28049
- alpha = normalizedX < dissolveThreshold ? 0 : normalizedX > fadeEnd ? 1 : (normalizedX - dissolveThreshold) / (fadeEnd - dissolveThreshold);
28050
- } else alpha = normalizedX < dissolveThreshold ? 0 : 1;
28051
- const index = 4 * (y * width + x);
28052
- result[index + 3] = Math.floor(result[index + 3] * alpha);
28053
- }
28054
- return new ImageData(result, width, height);
28055
- }
28056
- applyRightToLeftDissolve(imageData, progress) {
28057
- const {
28058
- data: data,
28059
- width: width,
28060
- height: height
28061
- } = imageData,
28062
- result = new Uint8ClampedArray(data.length);
28063
- result.set(data);
28064
- const pixelSize = this.dissolveConfig.noiseScale;
28065
- for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28066
- const normalizedX = x / width;
28067
- let dissolveThreshold = 1 - 1.2 * progress,
28068
- alpha = 1;
28069
- if (pixelSize > 0) {
28070
- dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedX > dissolveThreshold ? 0 : 1;
28071
- } else if (this.dissolveConfig.fadeEdge) {
28072
- const fadeStart = dissolveThreshold - .08;
28073
- alpha = normalizedX < fadeStart ? 1 : normalizedX > dissolveThreshold ? 0 : 1 - (normalizedX - fadeStart) / (dissolveThreshold - fadeStart);
28074
- } else alpha = normalizedX > dissolveThreshold ? 0 : 1;
28075
- const index = 4 * (y * width + x);
28076
- result[index + 3] = Math.floor(result[index + 3] * alpha);
28077
- }
28078
- return new ImageData(result, width, height);
28079
- }
28080
- applyTopToBottomDissolve(imageData, progress) {
28081
- const {
28082
- data: data,
28083
- width: width,
28084
- height: height
28085
- } = imageData,
28086
- result = new Uint8ClampedArray(data.length);
28087
- result.set(data);
28088
- const pixelSize = this.dissolveConfig.noiseScale;
28089
- for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28090
- const normalizedY = y / height;
28091
- let dissolveThreshold = 1.2 * progress,
28092
- alpha = 1;
28093
- if (pixelSize > 0) {
28094
- dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedY < dissolveThreshold ? 0 : 1;
28095
- } else if (this.dissolveConfig.fadeEdge) {
28096
- const fadeEnd = dissolveThreshold + .08;
28097
- alpha = normalizedY < dissolveThreshold ? 0 : normalizedY > fadeEnd ? 1 : (normalizedY - dissolveThreshold) / (fadeEnd - dissolveThreshold);
28098
- } else alpha = normalizedY < dissolveThreshold ? 0 : 1;
28099
- const index = 4 * (y * width + x);
28100
- result[index + 3] = Math.floor(result[index + 3] * alpha);
28101
- }
28102
- return new ImageData(result, width, height);
28103
- }
28104
- applyBottomToTopDissolve(imageData, progress) {
28105
- const {
28106
- data: data,
28107
- width: width,
28108
- height: height
28109
- } = imageData,
28110
- result = new Uint8ClampedArray(data.length);
28111
- result.set(data);
28112
- const pixelSize = this.dissolveConfig.noiseScale;
28113
- for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28114
- const normalizedY = y / height;
28115
- let dissolveThreshold = 1 - 1.2 * progress,
28116
- alpha = 1;
28117
- if (pixelSize > 0) {
28118
- dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedY > dissolveThreshold ? 0 : 1;
28119
- } else if (this.dissolveConfig.fadeEdge) {
28120
- const fadeStart = dissolveThreshold - .08;
28121
- alpha = normalizedY < fadeStart ? 1 : normalizedY > dissolveThreshold ? 0 : 1 - (normalizedY - fadeStart) / (dissolveThreshold - fadeStart);
28122
- } else alpha = normalizedY > dissolveThreshold ? 0 : 1;
28123
- const index = 4 * (y * width + x);
28124
- result[index + 3] = Math.floor(result[index + 3] * alpha);
28125
- }
28126
- return new ImageData(result, width, height);
28127
- }
28128
- }
28129
-
28130
- class Grayscale extends HybridEffectBase {
28131
- constructor(from, to, duration, easing, params) {
28132
- var _a, _b, _c;
28133
- super(from, to, duration, easing, params);
28134
- const rawStrength = void 0 !== (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.strength) ? params.options.strength : 1,
28135
- clampedStrength = Math.max(0, Math.min(1, rawStrength));
28136
- this.colorConfig = {
28137
- effectType: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.effectType) || "grayscale",
28138
- strength: clampedStrength,
28139
- useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL
28140
- };
28141
- }
28142
- getShaderSources() {
28143
- return {
28144
- vertex: ShaderLibrary.STANDARD_VERTEX_SHADER,
28145
- 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 `
28146
- };
28147
- }
28148
- applyWebGLEffect(canvas) {
28149
- if (!this.gl || !this.program || !this.webglCanvas) return null;
28150
- this.setupWebGLState(canvas);
28151
- const texture = this.createTextureFromCanvas(canvas);
28152
- if (!texture) return null;
28153
- const vertexBuffer = this.createFullScreenQuad();
28154
- if (!vertexBuffer) return this.gl.deleteTexture(texture), null;
28155
- try {
28156
- return this.gl.useProgram(this.program), this.setupVertexAttributes(), this.setColorUniforms(), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4), this.webglCanvas;
28157
- } finally {
28158
- this.gl.deleteTexture(texture), this.gl.deleteBuffer(vertexBuffer);
28159
- }
28160
- }
28161
- setColorUniforms() {
28162
- if (!this.gl || !this.program) return;
28163
- const currentTime = this.getAnimationTime(),
28164
- timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
28165
- strengthLocation = this.gl.getUniformLocation(this.program, "u_strength"),
28166
- effectTypeLocation = this.gl.getUniformLocation(this.program, "u_effectType"),
28167
- resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution");
28168
- this.gl.uniform1f(timeLocation, currentTime), this.gl.uniform1f(strengthLocation, this.colorConfig.strength), this.gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height);
28169
- this.gl.uniform1i(effectTypeLocation, {
28170
- grayscale: 0,
28171
- sepia: 1
28172
- }[this.colorConfig.effectType] || 0);
28173
- }
28174
- applyCanvas2DEffect(canvas) {
28175
- if (this.colorConfig.strength <= 0) {
28176
- const outputCanvas = this.createOutputCanvas(canvas);
28177
- return outputCanvas ? outputCanvas.canvas : null;
28178
- }
28179
- if (this.canUseCSSFilter()) return this.applyCSSFilter(canvas);
28180
- const outputCanvas = this.createOutputCanvas(canvas);
28181
- if (!outputCanvas) return null;
28182
- const {
28183
- ctx: ctx
28184
- } = outputCanvas;
28185
- try {
28186
- const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28187
- currentTime = this.getAnimationTime();
28188
- let processedImageData;
28189
- switch (this.colorConfig.effectType) {
28190
- case "grayscale":
28191
- default:
28192
- processedImageData = this.applyGrayscaleEffect(imageData, this.colorConfig.strength, currentTime);
28193
- break;
28194
- case "sepia":
28195
- processedImageData = this.applySepiaEffect(imageData, this.colorConfig.strength, currentTime);
28196
- }
28197
- return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(processedImageData, 0, 0), outputCanvas.canvas;
28198
- } catch (error) {
28199
- return null;
28200
- }
28201
- }
28202
- canUseCSSFilter() {
28203
- var _a;
28204
- return !!window.useFilterAPI && "undefined" != typeof CSS && (null === (_a = CSS.supports) || void 0 === _a ? void 0 : _a.call(CSS, "filter", "grayscale(1)"));
28205
- }
28206
- applyCSSFilter(canvas) {
28207
- try {
28208
- const outputCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height),
28209
- ctx = outputCanvas.getContext("2d");
28210
- if (!ctx) return null;
28211
- const currentTime = this.getAnimationTime(),
28212
- dynamicStrength = ImageProcessUtils.calculateDynamicStrength(this.colorConfig.strength, currentTime);
28213
- let filterValue = "";
28214
- 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;
28215
- } catch (error) {
28216
- return null;
28217
- }
28218
- }
28219
- applyGrayscaleEffect(imageData, strength, time) {
28220
- const {
28221
- data: data,
28222
- width: width,
28223
- height: height
28224
- } = imageData,
28225
- result = new Uint8ClampedArray(data.length),
28226
- dynamicStrength = ImageProcessUtils.calculateDynamicStrength(strength, time);
28227
- for (let i = 0; i < data.length; i += 4) {
28228
- const r = data[i],
28229
- g = data[i + 1],
28230
- b = data[i + 2],
28231
- a = data[i + 3],
28232
- gray = ImageProcessUtils.getLuminance(r, g, b);
28233
- 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;
28234
- }
28235
- return new ImageData(result, width, height);
28236
- }
28237
- applySepiaEffect(imageData, strength, time) {
28238
- const {
28239
- data: data,
28240
- width: width,
28241
- height: height
28242
- } = imageData,
28243
- result = new Uint8ClampedArray(data.length),
28244
- dynamicStrength = ImageProcessUtils.calculateDynamicStrength(strength, time);
28245
- for (let i = 0; i < data.length; i += 4) {
28246
- const r = data[i],
28247
- g = data[i + 1],
28248
- b = data[i + 2],
28249
- a = data[i + 3],
28250
- [sepiaR, sepiaG, sepiaB] = ImageProcessUtils.applySepiaToPixel(r, g, b);
28251
- 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;
28252
- }
28253
- return new ImageData(result, width, height);
28254
- }
28255
- afterStageRender(stage, canvas) {
28256
- if (this.canUseCSSFilter() && this.colorConfig.strength > 0) {
28257
- const cssResult = this.applyCSSFilter(canvas);
28258
- if (cssResult) return cssResult;
28259
- }
28260
- return super.afterStageRender(stage, canvas);
28261
- }
28262
- }
28263
-
28264
- class Distortion extends HybridEffectBase {
28265
- constructor(from, to, duration, easing, params) {
28266
- var _a, _b, _c;
28267
- super(from, to, duration, easing, params), this.distortionConfig = {
28268
- distortionType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.distortionType) || "wave",
28269
- strength: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.strength) || .3,
28270
- useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL
28271
- };
28272
- }
28273
- getShaderSources() {
28274
- return {
28275
- 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 ",
28276
- 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 "
28277
- };
28278
- }
28279
- applyWebGLEffect(canvas) {
28280
- if (!this.gl || !this.program || !this.webglCanvas) return null;
28281
- this.setupWebGLState(canvas);
28282
- const texture = this.createTextureFromCanvas(canvas);
28283
- if (!texture) return null;
28284
- const vertexBuffer = this.createFullScreenQuad();
28285
- if (!vertexBuffer) return this.gl.deleteTexture(texture), null;
28286
- try {
28287
- return this.gl.useProgram(this.program), this.setupVertexAttributes(), this.setDistortionUniforms(), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4), this.webglCanvas;
28288
- } finally {
28289
- this.gl.deleteTexture(texture), this.gl.deleteBuffer(vertexBuffer);
28290
- }
28291
- }
28292
- setDistortionUniforms() {
28293
- if (!this.gl || !this.program) return;
28294
- const currentTime = this.getAnimationTime(),
28295
- timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
28296
- strengthLocation = this.gl.getUniformLocation(this.program, "u_strength"),
28297
- distortionTypeLocation = this.gl.getUniformLocation(this.program, "u_distortionType"),
28298
- resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution");
28299
- this.gl.uniform1f(timeLocation, currentTime), this.gl.uniform1f(strengthLocation, this.distortionConfig.strength), this.gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height);
28300
- this.gl.uniform1i(distortionTypeLocation, {
28301
- wave: 0,
28302
- ripple: 1,
28303
- swirl: 2
28304
- }[this.distortionConfig.distortionType] || 0);
28305
- }
28306
- applyCanvas2DEffect(canvas) {
28307
- const outputCanvas = this.createOutputCanvas(canvas);
28308
- if (!outputCanvas) return null;
28309
- const {
28310
- ctx: ctx
28311
- } = outputCanvas;
28312
- try {
28313
- const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28314
- currentTime = this.getAnimationTime();
28315
- let distortedImageData;
28316
- switch (this.distortionConfig.distortionType) {
28317
- case "wave":
28318
- distortedImageData = this.applyWaveDistortion(imageData, this.distortionConfig.strength, currentTime);
28319
- break;
28320
- case "ripple":
28321
- distortedImageData = this.applyRippleDistortion(imageData, this.distortionConfig.strength, currentTime);
28322
- break;
28323
- case "swirl":
28324
- distortedImageData = this.applySwirlDistortion(imageData, this.distortionConfig.strength, currentTime);
28325
- break;
28326
- default:
28327
- distortedImageData = imageData;
28328
- }
28329
- return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(distortedImageData, 0, 0), outputCanvas.canvas;
28330
- } catch (error) {
28331
- return null;
28332
- }
28333
- }
28334
- applyWaveDistortion(imageData, strength, time) {
28335
- const {
28336
- data: data,
28337
- width: width,
28338
- height: height
28339
- } = imageData,
28340
- result = new Uint8ClampedArray(data.length);
28341
- for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28342
- const waveX = Math.sin(.1 * y + 3 * time) * strength * 20,
28343
- waveY = Math.sin(.1 * x + 2 * time) * strength * 20,
28344
- sourceX = Math.round(x - waveX),
28345
- sourceY = Math.round(y - waveY),
28346
- targetIndex = 4 * (y * width + x);
28347
- if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
28348
- const sourceIndex = 4 * (sourceY * width + sourceX);
28349
- result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
28350
- } else result[targetIndex + 3] = 0;
28351
- }
28352
- return new ImageData(result, width, height);
28353
- }
28354
- applyRippleDistortion(imageData, strength, time) {
28355
- const {
28356
- data: data,
28357
- width: width,
28358
- height: height
28359
- } = imageData,
28360
- result = new Uint8ClampedArray(data.length),
28361
- centerX = width / 2,
28362
- centerY = height / 2;
28363
- for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28364
- const dx = x - centerX,
28365
- dy = y - centerY,
28366
- distance = Math.sqrt(dx * dx + dy * dy),
28367
- ripple = Math.sin(.2 * distance - 5 * time) * strength * 10,
28368
- angle = Math.atan2(dy, dx),
28369
- sourceX = Math.round(x - Math.cos(angle) * ripple),
28370
- sourceY = Math.round(y - Math.sin(angle) * ripple),
28371
- targetIndex = 4 * (y * width + x);
28372
- if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
28373
- const sourceIndex = 4 * (sourceY * width + sourceX);
28374
- result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
28375
- } else result[targetIndex + 3] = 0;
28376
- }
28377
- return new ImageData(result, width, height);
28378
- }
28379
- applySwirlDistortion(imageData, strength, time) {
28380
- const {
28381
- data: data,
28382
- width: width,
28383
- height: height
28384
- } = imageData,
28385
- result = new Uint8ClampedArray(data.length),
28386
- centerX = width / 2,
28387
- centerY = height / 2;
28388
- for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28389
- const dx = x - centerX,
28390
- dy = y - centerY,
28391
- distance = Math.sqrt(dx * dx + dy * dy),
28392
- finalAngle = Math.atan2(dy, dx) + distance * strength * time * .02,
28393
- sourceX = Math.round(centerX + distance * Math.cos(finalAngle)),
28394
- sourceY = Math.round(centerY + distance * Math.sin(finalAngle)),
28395
- targetIndex = 4 * (y * width + x);
28396
- if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
28397
- const sourceIndex = 4 * (sourceY * width + sourceX);
28398
- result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
28399
- } else result[targetIndex + 3] = 0;
28400
- }
28401
- return new ImageData(result, width, height);
28402
- }
28403
- afterStageRender(stage, canvas) {
28404
- return this.distortionConfig.strength <= 0 ? canvas : super.afterStageRender(stage, canvas);
28405
- }
28406
- }
28407
-
28408
- class Particle extends HybridEffectBase {
28409
- constructor(from, to, duration, easing, params) {
28410
- var _a, _b, _c, _d, _e;
28411
- super(from, to, duration, easing, params), this.particles = [], this.positionBuffer = null, this.colorBuffer = null, this.particleConfig = {
28412
- effectType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.effectType) || "gravity",
28413
- count: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.count) || 4e3,
28414
- size: (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.size) || 20,
28415
- strength: (null === (_d = null == params ? void 0 : params.options) || void 0 === _d ? void 0 : _d.strength) || 1.5,
28416
- useWebGL: void 0 === (null === (_e = null == params ? void 0 : params.options) || void 0 === _e ? void 0 : _e.useWebGL) || params.options.useWebGL
28417
- };
28418
- }
28419
- getShaderSources() {
28420
- return {
28421
- 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 ",
28422
- 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 "
28423
- };
28424
- }
28425
- applyWebGLEffect(canvas) {
28426
- if (!this.gl || !this.program || !this.webglCanvas) return null;
28427
- this.setupWebGLState(canvas), 0 === this.particles.length && this.extractParticles(canvas), this.updateParticles(canvas);
28428
- const gl = this.gl;
28429
- return gl.enable(gl.BLEND), gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA), gl.useProgram(this.program), this.prepareAndDrawParticles(gl), this.webglCanvas;
28430
- }
28431
- applyCanvas2DEffect(canvas) {
28432
- const output = this.createOutputCanvas(canvas);
28433
- if (!output) return null;
28434
- const {
28435
- canvas: outputCanvas,
28436
- ctx: ctx
28437
- } = output,
28438
- progress = this.currentAnimationRatio;
28439
- switch (this.particleConfig.effectType) {
28440
- case "explode":
28441
- this.applyCanvas2DExplode(ctx, canvas, progress);
28442
- break;
28443
- case "gravity":
28444
- this.applyCanvas2DGravity(ctx, canvas, progress);
28445
- break;
28446
- case "vortex":
28447
- this.applyCanvas2DVortex(ctx, canvas, progress);
28448
- break;
28449
- default:
28450
- ctx.globalAlpha = Math.max(0, 1 - progress), ctx.drawImage(canvas, 0, 0);
28451
- }
28452
- return outputCanvas;
28453
- }
28454
- extractParticles(canvas) {
28455
- const tempCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height, 1),
28456
- tempCtx = tempCanvas.getContext("2d");
28457
- if (!tempCtx) return;
28458
- tempCtx.drawImage(canvas, 0, 0, tempCanvas.width, tempCanvas.height);
28459
- const data = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height).data;
28460
- this.particles = [];
28461
- const step = Math.max(1, Math.floor(Math.sqrt(tempCanvas.width * tempCanvas.height / (1.5 * this.particleConfig.count))));
28462
- for (let y = 0; y < tempCanvas.height; y += step) for (let x = 0; x < tempCanvas.width; x += step) {
28463
- const index = 4 * (y * tempCanvas.width + x),
28464
- r = data[index],
28465
- g = data[index + 1],
28466
- b = data[index + 2],
28467
- a = data[index + 3];
28468
- if (a > 5) {
28469
- const realX = x / tempCanvas.width * canvas.width,
28470
- realY = y / tempCanvas.height * canvas.height,
28471
- particle = {
28472
- x: realX,
28473
- y: realY,
28474
- originX: realX,
28475
- originY: realY,
28476
- vx: 0,
28477
- vy: 0,
28478
- r: r / 255,
28479
- g: g / 255,
28480
- b: b / 255,
28481
- a: Math.max(.6, a / 255),
28482
- life: 1,
28483
- size: this.particleConfig.size * (1 + .5 * Math.random())
28484
- };
28485
- this.particles.push(particle);
28486
- }
28487
- }
28488
- }
28489
- updateParticles(canvas) {
28490
- const centerX = canvas.width / 2,
28491
- centerY = canvas.height / 2,
28492
- progress = this.currentAnimationRatio,
28493
- duration = this.getDurationFromParent(),
28494
- isShortAnimation = duration < 2e3,
28495
- timeMultiplier = isShortAnimation ? Math.max(1.5, 3e3 / duration) : 1,
28496
- intensityBoost = isShortAnimation ? Math.min(2, 2e3 / duration) : 1;
28497
- this.particles.forEach(particle => {
28498
- const dx = particle.x - centerX,
28499
- dy = particle.y - centerY,
28500
- distance = Math.sqrt(dx * dx + dy * dy),
28501
- angle = Math.atan2(dy, dx);
28502
- this.applyParticleForces(particle, angle, distance, progress, intensityBoost, canvas), this.updateParticleProperties(particle, progress, isShortAnimation, timeMultiplier, intensityBoost);
28503
- });
28504
- }
28505
- applyParticleForces(particle, angle, distance, progress, intensityBoost, canvas) {
28506
- const time = this.getAnimationTime();
28507
- switch (this.particleConfig.effectType) {
28508
- case "explode":
28509
- const explodeIntensity = progress * this.particleConfig.strength * intensityBoost * 5;
28510
- particle.vx += Math.cos(angle) * explodeIntensity, particle.vy += Math.sin(angle) * explodeIntensity;
28511
- break;
28512
- case "gravity":
28513
- this.applyGravityEffect(particle, progress, intensityBoost, canvas, time);
28514
- break;
28515
- case "vortex":
28516
- this.applyVortexEffect(particle, progress, intensityBoost, canvas, angle, distance);
28517
- }
28518
- }
28519
- applyGravityEffect(particle, progress, intensityBoost, canvas, time) {
28520
- const gravityThreshold = (particle.originX + .7 * particle.originY) / (canvas.width + canvas.height) * .8;
28521
- if (progress > gravityThreshold) {
28522
- const gravityProgress = (progress - gravityThreshold) / (1 - gravityThreshold),
28523
- gravityForce = this.particleConfig.strength * gravityProgress * gravityProgress * 12 * intensityBoost;
28524
- particle.vy += gravityForce;
28525
- const turbulence = Math.sin(3 * time + .02 * particle.originX) * Math.cos(2 * time + .015 * particle.originY);
28526
- particle.vx += turbulence * this.particleConfig.strength * 2 * intensityBoost;
28527
- }
28528
- }
28529
- applyVortexEffect(particle, progress, intensityBoost, canvas, angle, distance) {
28530
- const centerX = canvas.width / 2,
28531
- centerY = canvas.height / 2,
28532
- spiralAngle = angle + progress * Math.PI * .8,
28533
- targetRadius = distance + progress * Math.max(canvas.width, canvas.height) * .7 * 1.8,
28534
- targetX = centerX + Math.cos(spiralAngle) * targetRadius,
28535
- targetY = centerY + Math.sin(spiralAngle) * targetRadius,
28536
- baseForce = progress * this.particleConfig.strength * .08 * intensityBoost;
28537
- particle.vx += (targetX - particle.x) * baseForce, particle.vy += (targetY - particle.y) * baseForce;
28538
- }
28539
- updateParticleProperties(particle, progress, isShortAnimation, timeMultiplier, intensityBoost) {
28540
- const dragCoeff = isShortAnimation ? .99 : .98;
28541
- if (particle.vx *= dragCoeff, particle.vy *= dragCoeff, particle.x += particle.vx, particle.y += particle.vy, isShortAnimation) {
28542
- const lifeDecayRate = Math.max(.1, .5 / timeMultiplier);
28543
- 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));
28544
- } 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));
28545
- }
28546
- prepareAndDrawParticles(gl) {
28547
- const positions = new Float32Array(2 * this.particles.length),
28548
- colors = new Float32Array(4 * this.particles.length),
28549
- sizes = new Float32Array(this.particles.length);
28550
- this.particles.forEach((particle, i) => {
28551
- 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);
28552
- }), this.updateParticleBuffers(gl, positions, colors, sizes), this.setParticleUniforms(gl), gl.drawArrays(gl.POINTS, 0, this.particles.length), this.cleanupTempBuffers(gl);
28553
- }
28554
- updateParticleBuffers(gl, positions, colors, sizes) {
28555
- this.positionBuffer || (this.positionBuffer = gl.createBuffer()), gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer), gl.bufferData(gl.ARRAY_BUFFER, positions, gl.DYNAMIC_DRAW);
28556
- const positionLocation = gl.getAttribLocation(this.program, "a_position");
28557
- 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);
28558
- const colorLocation = gl.getAttribLocation(this.program, "a_color");
28559
- gl.enableVertexAttribArray(colorLocation), gl.vertexAttribPointer(colorLocation, 4, gl.FLOAT, !1, 0, 0);
28560
- const sizeBuffer = gl.createBuffer();
28561
- gl.bindBuffer(gl.ARRAY_BUFFER, sizeBuffer), gl.bufferData(gl.ARRAY_BUFFER, sizes, gl.DYNAMIC_DRAW);
28562
- const sizeLocation = gl.getAttribLocation(this.program, "a_size");
28563
- gl.enableVertexAttribArray(sizeLocation), gl.vertexAttribPointer(sizeLocation, 1, gl.FLOAT, !1, 0, 0), this._tempSizeBuffer = sizeBuffer;
28564
- }
28565
- setParticleUniforms(gl) {
28566
- const resolutionLocation = gl.getUniformLocation(this.program, "u_resolution"),
28567
- timeLocation = gl.getUniformLocation(this.program, "u_time"),
28568
- forceStrengthLocation = gl.getUniformLocation(this.program, "u_forceStrength"),
28569
- effectTypeLocation = gl.getUniformLocation(this.program, "u_effectType");
28570
- gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height), gl.uniform1f(timeLocation, this.getAnimationTime()), gl.uniform1f(forceStrengthLocation, this.particleConfig.strength);
28571
- gl.uniform1i(effectTypeLocation, {
28572
- explode: 0,
28573
- vortex: 1,
28574
- gravity: 2
28575
- }[this.particleConfig.effectType] || 0);
28576
- }
28577
- cleanupTempBuffers(gl) {
28578
- const tempSizeBuffer = this._tempSizeBuffer;
28579
- tempSizeBuffer && (gl.deleteBuffer(tempSizeBuffer), delete this._tempSizeBuffer);
28580
- }
28581
- applyCanvas2DExplode(ctx, canvas, progress) {
28582
- const centerX = canvas.width / 2,
28583
- centerY = canvas.height / 2;
28584
- ctx.save(), ctx.globalAlpha = Math.max(0, 1 - progress), ctx.translate(centerX, centerY);
28585
- const scale = 1 + .5 * progress;
28586
- ctx.scale(scale, scale), ctx.translate(-centerX, -centerY), ctx.drawImage(canvas, 0, 0), ctx.restore();
28587
- }
28588
- applyCanvas2DGravity(ctx, canvas, progress) {
28589
- ctx.save(), ctx.globalAlpha = Math.max(0, 1 - progress);
28590
- const offsetY = progress * canvas.height * .3;
28591
- ctx.drawImage(canvas, 0, offsetY), ctx.restore();
28592
- }
28593
- applyCanvas2DVortex(ctx, canvas, progress) {
28594
- const centerX = canvas.width / 2,
28595
- centerY = canvas.height / 2;
28596
- 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();
28597
- }
28598
- }
28599
-
28600
- class Glitch extends Canvas2DEffectBase {
28601
- constructor(from, to, duration, easing, params) {
28602
- var _a, _b;
28603
- super(from, to, duration, easing, params), this.glitchConfig = {
28604
- effectType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.effectType) || "rgb-shift",
28605
- intensity: void 0 !== (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.intensity) ? params.options.intensity : .5
28606
- };
28607
- }
28608
- applyCanvas2DEffect(canvas) {
28609
- if (this.glitchConfig.intensity <= 0) {
28610
- const outputCanvas = this.createOutputCanvas(canvas);
28611
- return outputCanvas ? outputCanvas.canvas : null;
28612
- }
28613
- try {
28614
- switch (this.glitchConfig.effectType) {
28615
- case "rgb-shift":
28616
- default:
28617
- return this.applyRGBShiftGlitch(canvas);
28618
- case "digital-distortion":
28619
- return this.applyDigitalDistortionGlitch(canvas);
28620
- case "scan-lines":
28621
- return this.applyScanLineGlitch(canvas);
28622
- case "data-corruption":
28623
- return this.applyDataCorruptionGlitch(canvas);
28624
- }
28625
- } catch (error) {
28626
- return null;
28627
- }
28628
- }
28629
- applyRGBShiftGlitch(canvas) {
28630
- const outputCanvas = this.createOutputCanvas(canvas);
28631
- if (!outputCanvas) return null;
28632
- const {
28633
- ctx: ctx
28634
- } = outputCanvas;
28635
- try {
28636
- ctx.clearRect(0, 0, canvas.width, canvas.height);
28637
- const dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
28638
- maxOffset = Math.floor(20 * dynamicIntensity),
28639
- redOffset = this.generateRandomOffset(maxOffset),
28640
- greenOffset = this.generateRandomOffset(maxOffset, .3),
28641
- blueOffset = this.generateRandomOffset(-maxOffset),
28642
- tempCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height),
28643
- tempCtx = tempCanvas.getContext("2d");
28644
- tempCtx.drawImage(canvas, 0, 0);
28645
- const originalImageData = tempCtx.getImageData(0, 0, canvas.width, canvas.height),
28646
- redChannelData = ImageProcessUtils.extractChannel(originalImageData, 0),
28647
- greenChannelData = ImageProcessUtils.extractChannel(originalImageData, 1),
28648
- blueChannelData = ImageProcessUtils.extractChannel(originalImageData, 2);
28649
- 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;
28650
- } catch (error) {
28651
- return null;
28652
- }
28653
- }
28654
- applyDigitalDistortionGlitch(canvas) {
28655
- const outputCanvas = this.createOutputCanvas(canvas);
28656
- if (!outputCanvas) return null;
28657
- const {
28658
- ctx: ctx
28659
- } = outputCanvas;
28660
- try {
28661
- const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28662
- dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
28663
- distortedImageData = this.processDigitalDistortion(imageData, dynamicIntensity);
28664
- return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(distortedImageData, 0, 0), outputCanvas.canvas;
28665
- } catch (error) {
28666
- return null;
28667
- }
28668
- }
28669
- applyScanLineGlitch(canvas) {
28670
- const outputCanvas = this.createOutputCanvas(canvas);
28671
- if (!outputCanvas) return null;
28672
- const {
28673
- ctx: ctx
28674
- } = outputCanvas;
28675
- try {
28676
- const dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
28677
- lineSpacing = Math.max(2, Math.floor(10 - 8 * dynamicIntensity));
28678
- ctx.globalCompositeOperation = "multiply";
28679
- for (let y = 0; y < canvas.height; y += lineSpacing) if (Math.random() < dynamicIntensity) {
28680
- const opacity = .1 + .4 * dynamicIntensity;
28681
- ctx.fillStyle = `rgba(0, 0, 0, ${opacity})`, ctx.fillRect(0, y, canvas.width, 1);
28682
- }
28683
- ctx.globalCompositeOperation = "screen";
28684
- const brightLineCount = Math.floor(20 * dynamicIntensity);
28685
- for (let i = 0; i < brightLineCount; i++) {
28686
- const y = Math.random() * canvas.height,
28687
- opacity = .3 * dynamicIntensity;
28688
- ctx.fillStyle = `rgba(255, 255, 255, ${opacity})`, ctx.fillRect(0, Math.floor(y), canvas.width, 1);
28689
- }
28690
- return ctx.globalCompositeOperation = "source-over", outputCanvas.canvas;
28691
- } catch (error) {
28692
- return null;
28693
- }
28694
- }
28695
- applyDataCorruptionGlitch(canvas) {
28696
- const outputCanvas = this.createOutputCanvas(canvas);
28697
- if (!outputCanvas) return null;
28698
- const {
28699
- ctx: ctx
28700
- } = outputCanvas;
28701
- try {
28702
- const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28703
- dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
28704
- corruptedImageData = this.processDataCorruption(imageData, dynamicIntensity);
28705
- return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(corruptedImageData, 0, 0), outputCanvas.canvas;
28706
- } catch (error) {
28707
- return null;
28708
- }
28709
- }
28710
- generateRandomOffset(maxOffset, scale = 1) {
28711
- return {
28712
- x: (Math.random() - .5) * maxOffset,
28713
- y: (Math.random() - .5) * maxOffset * scale
28714
- };
28715
- }
28716
- processDigitalDistortion(imageData, intensity) {
28717
- const {
28718
- data: data,
28719
- width: width,
28720
- height: height
28721
- } = imageData,
28722
- result = new Uint8ClampedArray(data),
28723
- sliceCount = Math.floor(20 * intensity) + 5,
28724
- sliceHeight = Math.floor(height / sliceCount);
28725
- for (let i = 0; i < sliceCount; i++) if (Math.random() < intensity) {
28726
- const y = i * sliceHeight,
28727
- sliceEnd = Math.min(y + sliceHeight, height),
28728
- offset = Math.floor((Math.random() - .5) * width * intensity * .1);
28729
- this.shiftSliceHorizontal(result, width, height, y, sliceEnd, offset);
28730
- }
28731
- const noiseIntensity = .3 * intensity;
28732
- 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());
28733
- return new ImageData(result, width, height);
28734
- }
28735
- shiftSliceHorizontal(data, width, height, startY, endY, offset) {
28736
- const tempRow = new Uint8ClampedArray(4 * width);
28737
- for (let y = startY; y < endY; y++) {
28738
- const rowStart = y * width * 4;
28739
- for (let x = 0; x < 4 * width; x++) tempRow[x] = data[rowStart + x];
28740
- for (let x = 0; x < width; x++) {
28741
- const targetIndex = rowStart + 4 * x,
28742
- sourceIndex = 4 * ((x - offset + width) % width);
28743
- data[targetIndex] = tempRow[sourceIndex], data[targetIndex + 1] = tempRow[sourceIndex + 1], data[targetIndex + 2] = tempRow[sourceIndex + 2], data[targetIndex + 3] = tempRow[sourceIndex + 3];
28744
- }
28745
- }
28746
- }
28747
- processDataCorruption(imageData, intensity) {
28748
- const {
28749
- data: data,
28750
- width: width,
28751
- height: height
28752
- } = imageData,
28753
- result = new Uint8ClampedArray(data),
28754
- stripeCount = Math.floor(15 * intensity) + 5;
28755
- for (let i = 0; i < stripeCount; i++) if (Math.random() < intensity) {
28756
- const x = Math.floor(Math.random() * width),
28757
- stripeWidth = Math.floor(5 * Math.random()) + 1,
28758
- color = Math.random() < .5 ? 0 : 255;
28759
- for (let y = 0; y < height; y++) for (let dx = 0; dx < stripeWidth && x + dx < width; dx++) {
28760
- const index = 4 * (y * width + x + dx);
28761
- result[index] = color, result[index + 1] = color, result[index + 2] = color;
28762
- }
28763
- }
28764
- const corruptionCount = Math.floor(20 * intensity);
28765
- for (let i = 0; i < corruptionCount; i++) {
28766
- const blockX = Math.floor(Math.random() * width),
28767
- blockY = Math.floor(Math.random() * height),
28768
- blockW = Math.floor(20 * Math.random()) + 5,
28769
- blockH = Math.floor(10 * Math.random()) + 2;
28770
- this.corruptBlock(result, width, height, blockX, blockY, blockW, blockH);
28771
- }
28772
- return new ImageData(result, width, height);
28773
- }
28774
- corruptBlock(data, width, height, x, y, w, h) {
28775
- for (let dy = 0; dy < h && y + dy < height; dy++) for (let dx = 0; dx < w && x + dx < width; dx++) {
28776
- const index = 4 * ((y + dy) * width + (x + dx));
28777
- Math.random() < .7 && (data[index] = 255 * Math.random(), data[index + 1] = 255 * Math.random(), data[index + 2] = 255 * Math.random());
28778
- }
28779
- }
28780
- }
28781
-
28782
- class GaussianBlur extends AStageAnimate {
28783
- constructor(from, to, duration, easing, params) {
28784
- var _a, _b;
28785
- super(from, to, duration, easing, params), this.blurConfig = {
28786
- blurRadius: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.blurRadius) || 8,
28787
- useOptimizedBlur: void 0 === (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.useOptimizedBlur) || params.options.useOptimizedBlur
28788
- };
28789
- }
28790
- applyCSSBlur(canvas, radius) {
28791
- const c = vglobal.createCanvas({
28792
- width: canvas.width,
28793
- height: canvas.height,
28794
- dpr: vglobal.devicePixelRatio
28795
- }),
28796
- ctx = c.getContext("2d");
28797
- return ctx ? (ctx.filter = `blur(${radius}px)`, ctx.drawImage(canvas, 0, 0), ctx.filter = "none", c) : canvas;
28798
- }
28799
- applyDownsampleBlur(imageData, radius) {
28800
- const {
28801
- width: width,
28802
- height: height
28803
- } = imageData,
28804
- downsample = Math.max(1, Math.floor(radius / 2)),
28805
- smallWidth = Math.floor(width / downsample),
28806
- smallHeight = Math.floor(height / downsample),
28807
- tempCanvas = vglobal.createCanvas({
28808
- width: smallWidth,
28809
- height: smallHeight,
28810
- dpr: 1
28811
- }),
28812
- tempCtx = tempCanvas.getContext("2d");
28813
- if (!tempCtx) return imageData;
28814
- const originalCanvas = vglobal.createCanvas({
28815
- width: width,
28816
- height: height,
28817
- dpr: 1
28818
- }),
28819
- originalCtx = originalCanvas.getContext("2d");
28820
- 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;
28821
- }
28822
- afterStageRender(stage, canvas) {
28823
- if (this.blurConfig.blurRadius <= 0) return canvas;
28824
- let result;
28825
- if (this.blurConfig.useOptimizedBlur) result = this.applyCSSBlur(canvas, this.blurConfig.blurRadius);else {
28826
- const c = vglobal.createCanvas({
28827
- width: canvas.width,
28828
- height: canvas.height,
28829
- dpr: vglobal.devicePixelRatio
28830
- }),
28831
- ctx = c.getContext("2d");
28832
- if (!ctx) return !1;
28833
- ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.drawImage(canvas, 0, 0);
28834
- const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28835
- blurredImageData = this.applyDownsampleBlur(imageData, this.blurConfig.blurRadius);
28836
- ctx.putImageData(blurredImageData, 0, 0), result = c;
28837
- }
28838
- const ctx = result.getContext("2d");
28839
- 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;
28840
- }
28841
- }
28842
-
28843
- class Pixelation extends DisappearAnimateBase {
28844
- constructor(from, to, duration, easing, params) {
28845
- var _a, _b;
28846
- super(from, to, duration, easing, params), this.pixelationConfig = {
28847
- maxPixelSize: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.maxPixelSize) || 20,
28848
- method: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.method) || "out"
28849
- };
28850
- }
28851
- applyDownsamplePixelation(canvas, pixelSize) {
28852
- if (pixelSize <= 1) return canvas;
28853
- const {
28854
- width: width,
28855
- height: height
28856
- } = canvas,
28857
- smallWidth = Math.ceil(width / pixelSize),
28858
- smallHeight = Math.ceil(height / pixelSize),
28859
- smallCanvas = vglobal.createCanvas({
28860
- width: smallWidth,
28861
- height: smallHeight,
28862
- dpr: 1
28863
- }),
28864
- smallCtx = smallCanvas.getContext("2d");
28865
- if (!smallCtx) return canvas;
28866
- const outputCanvas = vglobal.createCanvas({
28867
- width: width,
28868
- height: height,
28869
- dpr: vglobal.devicePixelRatio
28870
- }),
28871
- outputCtx = outputCanvas.getContext("2d");
28872
- return outputCtx ? (smallCtx.imageSmoothingEnabled = !1, outputCtx.imageSmoothingEnabled = !1, smallCtx.drawImage(canvas, 0, 0, smallWidth, smallHeight), outputCtx.drawImage(smallCanvas, 0, 0, width, height), outputCanvas) : canvas;
28873
- }
28874
- updateAnimationProgress() {
28875
- if ("in" === this.pixelationConfig.method) {
28876
- return this.pixelationConfig.maxPixelSize - this.currentAnimationRatio * (this.pixelationConfig.maxPixelSize - 1);
28877
- }
28878
- return 1 + this.currentAnimationRatio * (this.pixelationConfig.maxPixelSize - 1);
28879
- }
28880
- afterStageRender(stage, canvas) {
28881
- const currentPixelSize = this.updateAnimationProgress();
28882
- if (currentPixelSize <= 1) return canvas;
28883
- return this.applyDownsamplePixelation(canvas, currentPixelSize);
28884
- }
28885
- }
28886
-
28887
27535
  const registerCustomAnimate = () => {
28888
- 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);
27536
+ 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);
28889
27537
  };
28890
27538
 
28891
27539
  class AxisEnter extends AComponentAnimate {
@@ -54442,7 +53090,7 @@
54442
53090
  }
54443
53091
 
54444
53092
  function getAxisConfigInPivotChart(col, row, layout) {
54445
- var _a, _b, _c, _d, _e, _f, _g;
53093
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
54446
53094
  if (layout._table.isPivotChart()) if (layout.indicatorsAsCol) {
54447
53095
  if (layout.hasTwoIndicatorAxes && row === layout.columnHeaderLevelCount - 1 && col >= layout.rowHeaderLevelCount && col < layout.colCount - layout.rightFrozenColCount) {
54448
53096
  const axisRange = getRange("top", col, row + 1, col, layout.columnHeaderLevelCount - 1, col, row, 1, layout);
@@ -54481,7 +53129,10 @@
54481
53129
  const info = layout.getIndicatorInfo(key);
54482
53130
  info && (indicatorInfo = info);
54483
53131
  });
54484
- const axisRange = getRange("bottom", col, row - 1, col, row, col, row, 0, layout);
53132
+ const axisRange = getRange("bottom", col, row - 1, col, row, col, row, 0, layout),
53133
+ {
53134
+ chartType: chartType
53135
+ } = getAxisOption(col, row - 1, "bottom", layout);
54485
53136
  if (!axisRange) return;
54486
53137
  const chartCellStyle = layout._table._getCellStyle(col, row - 1),
54487
53138
  padding = getQuadProps(getProp("padding", chartCellStyle, col, row - 1, layout._table)),
@@ -54494,12 +53145,21 @@
54494
53145
  targetRange: targetRange,
54495
53146
  theme: theme
54496
53147
  } = axisRange;
54497
- return isNumber$4(null == axisOption ? void 0 : axisOption.min) && (range.min = axisOption.min, range.min > 0 && (axisOption.zero = !1)), isNumber$4(null == axisOption ? void 0 : axisOption.max) && (range.max = axisOption.max, range.max < 0 && (axisOption.zero = !1)), merge$1({
53148
+ isNumber$4(null == axisOption ? void 0 : axisOption.min) && (range.min = axisOption.min, range.min > 0 && (axisOption.zero = !1)), isNumber$4(null == axisOption ? void 0 : axisOption.max) && (range.max = axisOption.max, range.max < 0 && (axisOption.zero = !1));
53149
+ let domain = [];
53150
+ if ("heatmap" === chartType) {
53151
+ const colDimensionKey = layout.getDimensionKeyInChartSpec(col, layout.rowCount - layout.bottomFrozenRowCount - 1, "xField"),
53152
+ data = null !== (_a = layout.dataset.collectedValues[colDimensionKey]) && void 0 !== _a ? _a : [],
53153
+ colPath = layout.getColKeysPath(col, row);
53154
+ domain = null !== (_b = null == data ? void 0 : data[null != colPath ? colPath : ""]) && void 0 !== _b ? _b : [];
53155
+ }
53156
+ return merge$1({
54498
53157
  title: {
54499
53158
  visible: !0,
54500
53159
  text: null == indicatorInfo ? void 0 : indicatorInfo.title
54501
53160
  },
54502
- range: range
53161
+ range: range,
53162
+ domain: "linear" === (null == axisOption ? void 0 : axisOption.type) ? void 0 : Array.from(domain)
54503
53163
  }, axisOption, {
54504
53164
  orient: "bottom",
54505
53165
  type: (null == axisOption ? void 0 : axisOption.type) || "linear",
@@ -54517,9 +53177,9 @@
54517
53177
  if (col === layout.rowHeaderLevelCount - 1 && row >= layout.columnHeaderLevelCount && row < layout.rowCount - layout.bottomFrozenRowCount) {
54518
53178
  let rowDimensionKey = layout.getDimensionKeyInChartSpec(layout.rowHeaderLevelCount, row);
54519
53179
  isArray$7(rowDimensionKey) && (rowDimensionKey = rowDimensionKey[0]);
54520
- const data = null !== (_a = layout.dataset.collectedValues[rowDimensionKey]) && void 0 !== _a ? _a : [],
53180
+ const data = null !== (_c = layout.dataset.collectedValues[rowDimensionKey]) && void 0 !== _c ? _c : [],
54521
53181
  rowPath = layout.getRowKeysPath(col, row),
54522
- domain = null !== (_b = data[null != rowPath ? rowPath : ""]) && void 0 !== _b ? _b : [],
53182
+ domain = null !== (_d = data[null != rowPath ? rowPath : ""]) && void 0 !== _d ? _d : [],
54523
53183
  {
54524
53184
  axisOption: axisOption,
54525
53185
  theme: theme,
@@ -54537,9 +53197,9 @@
54537
53197
  }
54538
53198
  }, axisOption, {
54539
53199
  orient: "left",
54540
- type: null !== (_c = null == axisOption ? void 0 : axisOption.type) && void 0 !== _c ? _c : "band",
53200
+ type: null !== (_e = null == axisOption ? void 0 : axisOption.type) && void 0 !== _e ? _e : "band",
54541
53201
  __vtableChartTheme: theme,
54542
- inverse: transformInverse(axisOption, "horizontal" === (null !== (_d = null == spec ? void 0 : spec.direction) && void 0 !== _d ? _d : "scatter" === chartType ? "vertical" : "horizontal")),
53202
+ inverse: transformInverse(axisOption, "horizontal" === (null !== (_f = null == spec ? void 0 : spec.direction) && void 0 !== _f ? _f : "scatter" === chartType ? "vertical" : "horizontal")),
54543
53203
  __vtablePadding: padding
54544
53204
  });
54545
53205
  }
@@ -54551,7 +53211,10 @@
54551
53211
  const info = layout.getIndicatorInfo(key);
54552
53212
  info && (indicatorInfo = info);
54553
53213
  });
54554
- const axisRange = getRange("left", col + 1, row, col, row, col, row, 0, layout);
53214
+ const axisRange = getRange("left", col + 1, row, col, row, col, row, 0, layout),
53215
+ {
53216
+ chartType: chartType
53217
+ } = getAxisOption(col + 1, row, "left", layout);
54555
53218
  if (!axisRange) return;
54556
53219
  const chartCellStyle = layout._table._getCellStyle(col + 1, row),
54557
53220
  padding = getQuadProps(getProp("padding", chartCellStyle, col + 1, row, layout._table)),
@@ -54564,13 +53227,22 @@
54564
53227
  targetRange: targetRange,
54565
53228
  theme: theme
54566
53229
  } = axisRange;
54567
- return isNumber$4(null == axisOption ? void 0 : axisOption.min) && (range.min = axisOption.min, range.min > 0 && (axisOption.zero = !1)), isNumber$4(null == axisOption ? void 0 : axisOption.max) && (range.max = axisOption.max, range.max < 0 && (axisOption.zero = !1)), merge$1({
53230
+ isNumber$4(null == axisOption ? void 0 : axisOption.min) && (range.min = axisOption.min, range.min > 0 && (axisOption.zero = !1)), isNumber$4(null == axisOption ? void 0 : axisOption.max) && (range.max = axisOption.max, range.max < 0 && (axisOption.zero = !1));
53231
+ let domain = [];
53232
+ if ("heatmap" === chartType) {
53233
+ const rowDimensionKey = layout.getDimensionKeyInChartSpec(layout.rowHeaderLevelCount, row, "yField"),
53234
+ data = null !== (_g = layout.dataset.collectedValues[rowDimensionKey]) && void 0 !== _g ? _g : [],
53235
+ rowPath = layout.getRowKeysPath(col, row);
53236
+ domain = null !== (_h = null == data ? void 0 : data[null != rowPath ? rowPath : ""]) && void 0 !== _h ? _h : [];
53237
+ }
53238
+ return merge$1({
54568
53239
  title: {
54569
53240
  visible: !0,
54570
53241
  text: null == indicatorInfo ? void 0 : indicatorInfo.title,
54571
53242
  autoRotate: !0
54572
53243
  },
54573
- range: range
53244
+ range: range,
53245
+ domain: "linear" === (null == axisOption ? void 0 : axisOption.type) ? void 0 : Array.from(domain)
54574
53246
  }, axisOption, {
54575
53247
  orient: "left",
54576
53248
  type: (null == axisOption ? void 0 : axisOption.type) || "linear",
@@ -54586,7 +53258,10 @@
54586
53258
  });
54587
53259
  }
54588
53260
  if (col === layout.colCount - layout.rightFrozenColCount && row >= layout.columnHeaderLevelCount && row < layout.rowCount - layout.bottomFrozenRowCount) {
54589
- const axisRange = getRange("right", col - 1, row, layout.rowHeaderLevelCount - 1, row, col, row, 1, layout);
53261
+ const axisRange = getRange("right", col - 1, row, layout.rowHeaderLevelCount - 1, row, col, row, 1, layout),
53262
+ {
53263
+ chartType: chartType
53264
+ } = getAxisOption(col - 1, row, "right", layout);
54590
53265
  if (!axisRange) return;
54591
53266
  const chartCellStyle = layout._table._getCellStyle(col - 1, row),
54592
53267
  padding = getQuadProps(getProp("padding", chartCellStyle, col - 1, row, layout._table)),
@@ -54599,11 +53274,20 @@
54599
53274
  targetRange: targetRange,
54600
53275
  theme: theme
54601
53276
  } = axisRange;
54602
- return isNumber$4(null == axisOption ? void 0 : axisOption.min) && (range.min = axisOption.min, range.min > 0 && (axisOption.zero = !1)), isNumber$4(null == axisOption ? void 0 : axisOption.max) && (range.max = axisOption.max, range.max < 0 && (axisOption.zero = !1)), merge$1({
53277
+ isNumber$4(null == axisOption ? void 0 : axisOption.min) && (range.min = axisOption.min, range.min > 0 && (axisOption.zero = !1)), isNumber$4(null == axisOption ? void 0 : axisOption.max) && (range.max = axisOption.max, range.max < 0 && (axisOption.zero = !1));
53278
+ let domain = [];
53279
+ if ("heatmap" === chartType) {
53280
+ const rowDimensionKey = layout.getDimensionKeyInChartSpec(layout.colCount - layout.rightFrozenColCount - 1, row, "yField"),
53281
+ data = null !== (_j = layout.dataset.collectedValues[rowDimensionKey]) && void 0 !== _j ? _j : [],
53282
+ rowPath = layout.getRowKeysPath(col, row);
53283
+ domain = null !== (_k = null == data ? void 0 : data[null != rowPath ? rowPath : ""]) && void 0 !== _k ? _k : [];
53284
+ }
53285
+ return merge$1({
54603
53286
  range: range,
54604
53287
  title: {
54605
53288
  autoRotate: !0
54606
- }
53289
+ },
53290
+ domain: "linear" === (null == axisOption ? void 0 : axisOption.type) ? void 0 : Array.from(domain)
54607
53291
  }, axisOption, {
54608
53292
  orient: "right",
54609
53293
  type: (null == axisOption ? void 0 : axisOption.type) || "linear",
@@ -54621,9 +53305,9 @@
54621
53305
  if (row === layout.rowCount - layout.bottomFrozenRowCount && col >= layout.rowHeaderLevelCount && col < layout.colCount - layout.rightFrozenColCount) {
54622
53306
  let columnDimensionKey = layout.getDimensionKeyInChartSpec(col, layout.columnHeaderLevelCount);
54623
53307
  isArray$7(columnDimensionKey) && (columnDimensionKey = columnDimensionKey[0]);
54624
- const data = null !== (_e = layout.dataset.collectedValues[columnDimensionKey]) && void 0 !== _e ? _e : [],
53308
+ const data = null !== (_l = layout.dataset.collectedValues[columnDimensionKey]) && void 0 !== _l ? _l : [],
54625
53309
  colPath = layout.getColKeysPath(col, row),
54626
- domain = null !== (_f = null == data ? void 0 : data[null != colPath ? colPath : ""]) && void 0 !== _f ? _f : [],
53310
+ domain = null !== (_m = null == data ? void 0 : data[null != colPath ? colPath : ""]) && void 0 !== _m ? _m : [],
54627
53311
  {
54628
53312
  axisOption: axisOption,
54629
53313
  isPercent: isPercent,
@@ -54638,7 +53322,7 @@
54638
53322
  range: "linear" === (null == axisOption ? void 0 : axisOption.type) ? domain : void 0
54639
53323
  }, axisOption, {
54640
53324
  orient: "bottom",
54641
- type: null !== (_g = null == axisOption ? void 0 : axisOption.type) && void 0 !== _g ? _g : "band",
53325
+ type: null !== (_o = null == axisOption ? void 0 : axisOption.type) && void 0 !== _o ? _o : "band",
54642
53326
  __vtableChartTheme: theme,
54643
53327
  __vtablePadding: padding
54644
53328
  });
@@ -55145,7 +53829,7 @@
55145
53829
  }
55146
53830
  constructor(container, options = {}) {
55147
53831
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
55148
- if (super(), this.showFrozenIcon = !0, this.version = "1.19.10-alpha.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
53832
+ if (super(), this.showFrozenIcon = !0, this.version = "1.19.10-alpha.1", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
55149
53833
  this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
55150
53834
  options: options,
55151
53835
  container: container