@visactor/vrender 0.22.0 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3924,10 +3924,10 @@
3924
3924
  x = current[5], y = current[6], controlX = current[3], controlY = current[4], this.bezierCurveTo(current[1] + l, current[2] + t, controlX + l, controlY + t, x + l, y + t);
3925
3925
  break;
3926
3926
  case "s":
3927
- tempX = x + current[3], tempY = y + current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.bezierCurveTo(controlX + l, controlY + t, x + current[1] + l, y + current[2] + t, tempX + l, tempY + t), controlX = x + current[1], controlY = y + current[2], x = tempX, y = tempY;
3927
+ tempX = x + current[3], tempY = y + current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x, controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = x + current[1], tempControlY = y + current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t), controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
3928
3928
  break;
3929
3929
  case "S":
3930
- tempX = current[3], tempY = current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.bezierCurveTo(controlX + l, controlY + t, current[1] + l, current[2] + t, tempX + l, tempY + t), x = tempX, y = tempY, controlX = current[1], controlY = current[2];
3930
+ tempX = current[3], tempY = current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x, controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = current[1], tempControlY = current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t), controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
3931
3931
  break;
3932
3932
  case "q":
3933
3933
  tempX = x + current[3], tempY = y + current[4], controlX = x + current[1], controlY = y + current[2], this.quadraticCurveTo(controlX + l, controlY + t, tempX + l, tempY + t), x = tempX, y = tempY;
@@ -4155,7 +4155,7 @@
4155
4155
  opacity: 1,
4156
4156
  background: null,
4157
4157
  autoAnimateTexture: !1,
4158
- textureRatio: 0,
4158
+ textureRatio: 1,
4159
4159
  textureOptions: null,
4160
4160
  backgroundOpacity: 1,
4161
4161
  backgroundCornerRadius: 0,
@@ -4318,6 +4318,7 @@
4318
4318
  keepDirIn3d: !0
4319
4319
  });
4320
4320
  const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), {
4321
+ upgradeAttrs: null,
4321
4322
  editable: !1,
4322
4323
  editOptions: null,
4323
4324
  ascentDescentMode: "actual",
@@ -10154,7 +10155,7 @@
10154
10155
  null != onStart && animate.onStart(onStart), null != onFrame && animate.onFrame(onFrame), null != onEnd && animate.onEnd(onEnd), null != onRemove && animate.onRemove(onRemove), animate.interpolateFunc = params.interpolate;
10155
10156
  }
10156
10157
  return this.animates.set(animate.id, animate), animate.onRemove(() => {
10157
- this.animates.delete(animate.id);
10158
+ animate.stop(), this.animates.delete(animate.id);
10158
10159
  }), animate;
10159
10160
  }
10160
10161
  onAttributeUpdate(context) {
@@ -10219,9 +10220,10 @@
10219
10220
  this.hasState() && this.normalAttrs ? (this.currentStates = [], this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
10220
10221
  }
10221
10222
  removeState(stateName, hasAnimation) {
10222
- if ((this.currentStates ? this.currentStates.indexOf(stateName) : -1) >= 0) {
10223
- const currentStates = this.currentStates.filter(state => state !== stateName);
10224
- this.useStates(currentStates, hasAnimation);
10223
+ if (this.currentStates) {
10224
+ const filter = isArray$1(stateName) ? s => !stateName.includes(s) : s => s !== stateName,
10225
+ newStates = this.currentStates.filter(filter);
10226
+ newStates.length !== this.currentStates.length && this.useStates(newStates, hasAnimation);
10225
10227
  }
10226
10228
  }
10227
10229
  toggleState(stateName, hasAnimation) {
@@ -10358,7 +10360,7 @@
10358
10360
  if (this.stage = stage, this.layer = layer, this.setStageToShadowRoot(stage, layer), this.animates && this.animates.size) {
10359
10361
  const timeline = stage.getTimeline();
10360
10362
  this.animates.forEach(a => {
10361
- a.setTimeline(timeline);
10363
+ a.timeline === defaultTimeline && a.setTimeline(timeline);
10362
10364
  });
10363
10365
  }
10364
10366
  this._onSetStage && this._onSetStage(this, stage, layer), application.graphicService.onSetStage(this, stage);
@@ -10462,7 +10464,7 @@
10462
10464
  return shadowRoot && (shadowRoot.shadowHost = this), this.shadowRoot = null != shadowRoot ? shadowRoot : application.graphicService.creator.shadowRoot(this), this.addUpdateBoundTag(), this.shadowRoot.setStage(this.stage, this.layer), this.shadowRoot;
10463
10465
  }
10464
10466
  detachShadow() {
10465
- this.shadowRoot && (this.addUpdateBoundTag(), this.shadowRoot = null);
10467
+ this.shadowRoot && (this.addUpdateBoundTag(), this.shadowRoot.release(!0), this.shadowRoot = null);
10466
10468
  }
10467
10469
  toJson() {
10468
10470
  return {
@@ -10514,7 +10516,7 @@
10514
10516
  });
10515
10517
  }
10516
10518
  release() {
10517
- this.releaseStatus = "released", application.graphicService.onRelease(this);
10519
+ this.releaseStatus = "released", this.stopAnimates(), application.graphicService.onRelease(this);
10518
10520
  }
10519
10521
  _emitCustomEvent(type, context) {
10520
10522
  var _a, _b;
@@ -11090,6 +11092,11 @@
11090
11092
  getNoWorkAnimateAttr() {
11091
11093
  return Group.NOWORK_ANIMATE_ATTR;
11092
11094
  }
11095
+ release(all) {
11096
+ all && this.forEachChildren(g => {
11097
+ g.release(all);
11098
+ }), super.release();
11099
+ }
11093
11100
  }
11094
11101
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
11095
11102
  function createGroup(attributes) {
@@ -13339,6 +13346,20 @@
13339
13346
  getParsedPath() {
13340
13347
  return this.shouldUpdateShape() && (this.doUpdateParsedPath(), this.clearUpdateShapeTag()), this._parsedPath;
13341
13348
  }
13349
+ getParsedPath2D() {
13350
+ let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
13351
+ let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
13352
+ let size = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
13353
+ let path = null;
13354
+ try {
13355
+ path = new Path2D();
13356
+ } catch (err) {
13357
+ return null;
13358
+ }
13359
+ const parsedPath = this.getParsedPath();
13360
+ if (!parsedPath) return null;
13361
+ parsedPath.draw(path, size, x, y);
13362
+ }
13342
13363
  isValid() {
13343
13364
  return super.isValid() && this._isValid();
13344
13365
  }
@@ -13957,7 +13978,7 @@
13957
13978
  this.width = width, "vertical" === this.direction && (this.widthOrigin = this.width, this.width = this.heightOrigin, this.height = this.widthOrigin);
13958
13979
  }
13959
13980
  drawBackground(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
13960
- if (!this.character.background || this.character.backgroundOpacity && !(this.character.backgroundOpacity > 0)) return;
13981
+ if ("" === this.text || "\n" === this.text || !this.character.background || this.character.backgroundOpacity && !(this.character.backgroundOpacity > 0)) return;
13961
13982
  let baseline = top + ascent,
13962
13983
  text = this.text,
13963
13984
  left = this.left + deltaLeft;
@@ -13975,19 +13996,11 @@
13975
13996
  }
13976
13997
  }
13977
13998
  }
13978
- switch (this.character.script) {
13979
- case "super":
13980
- baseline -= this.ascent * (1 / 3);
13981
- break;
13982
- case "sub":
13983
- baseline += this.descent / 2;
13984
- }
13985
- "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
13986
- const fillStyle = ctx.fillStyle,
13987
- globalAlpha = ctx.globalAlpha;
13988
- ctx.fillStyle = this.character.background, void 0 !== this.character.backgroundOpacity && (ctx.globalAlpha = this.character.backgroundOpacity);
13989
13999
  const lrtb = getFixedLRTB(left, left + (this.widthOrigin || this.width), top, top + lineHeight);
13990
- ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top), ctx.fillStyle = fillStyle, ctx.globalAlpha = globalAlpha;
14000
+ return Object.assign(Object.assign({}, lrtb), {
14001
+ fillStyle: this.character.background,
14002
+ globalAlpha: this.character.backgroundOpacity
14003
+ });
13991
14004
  }
13992
14005
  draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
13993
14006
  let baseline = top + ascent,
@@ -14261,8 +14274,19 @@
14261
14274
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
14262
14275
  }
14263
14276
  }
14277
+ let fillStyle = "",
14278
+ globalAlpha = -1,
14279
+ currBgList = [];
14280
+ const bgList = [currBgList];
14264
14281
  this.paragraphs.forEach((paragraph, index) => {
14265
- paragraph instanceof RichTextIcon || paragraph.drawBackground(ctx, y, this.ascent, x, 0 === index, this.textAlign, this.height);
14282
+ if (paragraph instanceof RichTextIcon) return;
14283
+ const data = paragraph.drawBackground(ctx, y, this.ascent, x, 0 === index, this.textAlign, this.height);
14284
+ data && (fillStyle === data.fillStyle && globalAlpha === data.globalAlpha || (currBgList = [], bgList.push(currBgList), fillStyle = data.fillStyle, globalAlpha = data.globalAlpha), currBgList.push(data));
14285
+ }), bgList.forEach(bg => {
14286
+ if (0 === bg.length) return;
14287
+ const data = bg[0],
14288
+ end = bg[bg.length - 1];
14289
+ ctx.fillStyle = data.fillStyle, ctx.globalAlpha = data.globalAlpha, ctx.fillRect(data.left, data.top, end.right - data.left, end.bottom - data.top);
14266
14290
  }), this.paragraphs.forEach((paragraph, index) => {
14267
14291
  if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
14268
14292
  x: x + paragraph._x,
@@ -14500,7 +14524,7 @@
14500
14524
  case "right":
14501
14525
  deltaX = -aabbBounds.width();
14502
14526
  }
14503
- return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), aabbBounds;
14527
+ return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
14504
14528
  }
14505
14529
  needUpdateTags(keys) {
14506
14530
  return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
@@ -14528,48 +14552,53 @@
14528
14552
  }
14529
14553
  combinedStyleToCharacter(config) {
14530
14554
  const {
14531
- fill: fill,
14532
- stroke: stroke,
14533
- fontSize: fontSize,
14534
- fontFamily: fontFamily,
14535
- fontStyle: fontStyle,
14536
- fontWeight: fontWeight,
14537
- lineWidth: lineWidth,
14538
- opacity: opacity,
14539
- fillOpacity: fillOpacity,
14540
- strokeOpacity: strokeOpacity
14541
- } = this.attribute;
14542
- return Object.assign({
14543
- fill: fill,
14544
- stroke: stroke,
14545
- fontSize: fontSize,
14546
- fontFamily: fontFamily,
14547
- fontStyle: fontStyle,
14548
- fontWeight: fontWeight,
14549
- lineWidth: lineWidth,
14550
- opacity: opacity,
14551
- fillOpacity: fillOpacity,
14552
- strokeOpacity: strokeOpacity
14553
- }, config);
14555
+ fill: fill,
14556
+ stroke: stroke,
14557
+ fontSize: fontSize,
14558
+ fontFamily: fontFamily,
14559
+ fontStyle: fontStyle,
14560
+ fontWeight: fontWeight,
14561
+ lineWidth: lineWidth,
14562
+ opacity: opacity,
14563
+ fillOpacity: fillOpacity,
14564
+ lineHeight: lineHeight,
14565
+ strokeOpacity: strokeOpacity,
14566
+ upgradeAttrs: upgradeAttrs
14567
+ } = this.attribute,
14568
+ out = Object.assign({
14569
+ fill: fill,
14570
+ stroke: stroke,
14571
+ fontSize: fontSize,
14572
+ fontFamily: fontFamily,
14573
+ fontStyle: fontStyle,
14574
+ fontWeight: fontWeight,
14575
+ lineWidth: lineWidth,
14576
+ opacity: opacity,
14577
+ fillOpacity: fillOpacity,
14578
+ strokeOpacity: strokeOpacity
14579
+ }, config);
14580
+ return (null == upgradeAttrs ? void 0 : upgradeAttrs.lineHeight) && (out.lineHeight = lineHeight), out;
14554
14581
  }
14555
14582
  doUpdateFrameCache(tc) {
14556
14583
  var _a;
14557
14584
  const {
14558
- maxWidth: maxWidth,
14559
- maxHeight: maxHeight,
14560
- width: width,
14561
- height: height,
14562
- ellipsis: ellipsis,
14563
- wordBreak: wordBreak,
14564
- verticalDirection: verticalDirection,
14565
- textAlign: textAlign,
14566
- textBaseline: textBaseline,
14567
- layoutDirection: layoutDirection,
14568
- singleLine: singleLine,
14569
- disableAutoWrapLine: disableAutoWrapLine,
14570
- editable: editable,
14571
- ascentDescentMode: ascentDescentMode
14572
- } = this.attribute;
14585
+ maxWidth: maxWidth,
14586
+ maxHeight: maxHeight,
14587
+ width: width,
14588
+ height: height,
14589
+ ellipsis: ellipsis,
14590
+ wordBreak: wordBreak,
14591
+ verticalDirection: verticalDirection,
14592
+ textAlign: textAlign,
14593
+ textBaseline: textBaseline,
14594
+ layoutDirection: layoutDirection,
14595
+ singleLine: singleLine,
14596
+ disableAutoWrapLine: disableAutoWrapLine,
14597
+ editable: editable,
14598
+ ascentDescentMode: ascentDescentMode,
14599
+ upgradeAttrs: upgradeAttrs
14600
+ } = this.attribute,
14601
+ enableMultiBreakLine = upgradeAttrs && upgradeAttrs.multiBreakLine;
14573
14602
  let {
14574
14603
  textConfig: _tc = []
14575
14604
  } = this.attribute;
@@ -14591,7 +14620,10 @@
14591
14620
  const richTextConfig = this.combinedStyleToCharacter(textConfig[i]);
14592
14621
  if (isNumber$1(richTextConfig.text) && (richTextConfig.text = `${richTextConfig.text}`), richTextConfig.text && richTextConfig.text.includes("\n")) {
14593
14622
  const textParts = richTextConfig.text.split("\n");
14594
- for (let j = 0; j < textParts.length; j++) paragraphs.push(new Paragraph(textParts[j], 0 !== j, richTextConfig, ascentDescentMode));
14623
+ for (let j = 0; j < textParts.length; j++) if (0 === j) paragraphs.push(new Paragraph(textParts[j], !1, richTextConfig, ascentDescentMode));else if (textParts[j] || i === textConfig.length - 1) paragraphs.push(new Paragraph(textParts[j], !0, richTextConfig, ascentDescentMode));else {
14624
+ const nextRichTextConfig = this.combinedStyleToCharacter(textConfig[i + 1]);
14625
+ paragraphs.push(new Paragraph(textParts[j], !0, nextRichTextConfig, ascentDescentMode));
14626
+ }
14595
14627
  } else richTextConfig.text && paragraphs.push(new Paragraph(richTextConfig.text, !1, richTextConfig, ascentDescentMode));
14596
14628
  }
14597
14629
  const maxWidthFinite = "number" == typeof maxWidth && Number.isFinite(maxWidth) && maxWidth > 0,
@@ -14600,7 +14632,7 @@
14600
14632
  richTextHeightEnable = "number" == typeof height && Number.isFinite(height) && height > 0 && (!maxHeightFinite || height <= maxHeight),
14601
14633
  frame = new Frame(0, 0, (richTextWidthEnable ? width : maxWidthFinite ? maxWidth : 0) || 0, (richTextHeightEnable ? height : maxHeightFinite ? maxHeight : 0) || 0, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection || "horizontal", !richTextWidthEnable && maxWidthFinite, !richTextHeightEnable && maxHeightFinite, singleLine || !1, null === (_a = this._frameCache) || void 0 === _a ? void 0 : _a.icons),
14602
14634
  wrapper = new Wrapper(frame);
14603
- if (wrapper.newLine = editable, disableAutoWrapLine) {
14635
+ if (wrapper.newLine = enableMultiBreakLine, disableAutoWrapLine) {
14604
14636
  let lineCount = 0,
14605
14637
  skip = !1;
14606
14638
  for (let i = 0; i < paragraphs.length; i++) {
@@ -14616,7 +14648,7 @@
14616
14648
  l.calcOffset(offsetSize, !1);
14617
14649
  });
14618
14650
  }
14619
- editable && frame.lines.forEach(item => {
14651
+ enableMultiBreakLine && frame.lines.forEach(item => {
14620
14652
  const lastParagraphs = item.paragraphs;
14621
14653
  item.paragraphs = item.paragraphs.filter(p => "" !== p.text), 0 === item.paragraphs.length && lastParagraphs.length && (lastParagraphs[0].text = "\n", item.paragraphs.push(lastParagraphs[0]));
14622
14654
  }), this._frameCache = frame;
@@ -15602,7 +15634,7 @@
15602
15634
  }
15603
15635
  class DefaultBaseTextureRenderContribution {
15604
15636
  constructor() {
15605
- this.time = exports.BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 10;
15637
+ this.time = exports.BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 10, this._tempSymbolGraphic = null;
15606
15638
  }
15607
15639
  createCommonPattern(size, padding, color, targetContext, cb) {
15608
15640
  const r = (size - 2 * padding) / 2,
@@ -15716,7 +15748,35 @@
15716
15748
  case "grid":
15717
15749
  pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
15718
15750
  }
15719
- if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
15751
+ if (textureOptions && textureOptions.dynamicTexture) {
15752
+ context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
15753
+ const {
15754
+ gridConfig = {}
15755
+ } = textureOptions,
15756
+ b = graphic.AABBBounds,
15757
+ width = b.width(),
15758
+ height = b.height(),
15759
+ padding = texturePadding,
15760
+ cellSize = textureSize,
15761
+ gridColumns = gridConfig.columns ? gridConfig.columns : Math.ceil(width / cellSize),
15762
+ gridRows = gridConfig.rows ? gridConfig.rows : Math.ceil(height / cellSize),
15763
+ gutterColumn = gridConfig.gutterColumn ? gridConfig.gutterColumn : 2 * padding,
15764
+ gutterRow = gridConfig.gutterRow ? gridConfig.gutterRow : 2 * padding;
15765
+ this._tempSymbolGraphic || (this._tempSymbolGraphic = createSymbol({}));
15766
+ const sizeW = gridConfig.columns ? width / gridConfig.columns : cellSize,
15767
+ sizeH = gridConfig.rows ? height / gridConfig.rows : cellSize;
15768
+ this._tempSymbolGraphic.setAttributes({
15769
+ size: [sizeW - gutterColumn, sizeH - gutterRow],
15770
+ symbolType: texture
15771
+ });
15772
+ const parsedPath = this._tempSymbolGraphic.getParsedPath();
15773
+ for (let i = 0; i < gridRows; i++) for (let j = 0; j < gridColumns; j++) {
15774
+ const _x = x + cellSize / 2 + j * cellSize,
15775
+ _y = y + cellSize / 2 + i * cellSize;
15776
+ context.beginPath(), !1 === parsedPath.draw(context, Math.min(sizeW - gutterColumn, sizeH - gutterRow), _x, _y, 0) && context.closePath(), context.fillStyle = textureColor, textureOptions.dynamicTexture(context, i, j, gridRows, gridColumns, textureRatio, graphic);
15777
+ }
15778
+ context.restore();
15779
+ } else if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
15720
15780
  context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
15721
15781
  const b = graphic.AABBBounds;
15722
15782
  drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
@@ -20274,6 +20334,7 @@
20274
20334
  fill = "black",
20275
20335
  stroke = !1,
20276
20336
  fontWeight = "normal",
20337
+ lineHeight: lineHeight,
20277
20338
  fontFamily = "Arial"
20278
20339
  } = attribute;
20279
20340
  let {
@@ -20284,7 +20345,8 @@
20284
20345
  stroke: stroke,
20285
20346
  fontSize: fontSize,
20286
20347
  fontWeight: fontWeight,
20287
- fontFamily: fontFamily
20348
+ fontFamily: fontFamily,
20349
+ lineHeight: lineHeight
20288
20350
  };
20289
20351
  }
20290
20352
  function findConfigIndexByCursorIdx(textConfig, cursorIndex) {
@@ -20533,15 +20595,15 @@
20533
20595
  }, this.handleFocusOut = () => {
20534
20596
  throw new Error("不会走到这里 handleFocusOut");
20535
20597
  }, this.handleMove = e => {
20536
- this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave, {
20598
+ this.currRt && !this.currRt.attribute.editable && this.deFocus(!0), this.isEditableRichtext(e) ? (this.handleEnter(), e.target.once("pointerleave", this.handleLeave, {
20537
20599
  capture: !0
20538
- }), this.tryShowSelection(e, !1));
20539
- }, this.handleEnter = e => {
20600
+ }), this.tryShowSelection(e, !1)) : this.handleLeave();
20601
+ }, this.handleEnter = () => {
20540
20602
  this.editing = !0, this.pluginService.stage.setCursor("text");
20541
- }, this.handleLeave = e => {
20603
+ }, this.handleLeave = () => {
20542
20604
  this.editing = !1, this.pluginService.stage.setCursor("default");
20543
20605
  }, this.handlePointerDown = e => {
20544
- this.editing ? this.onFocus(e) : this.deFocus(!0), this.triggerRender(), this.pointerDown = !0, this.updateCbs.forEach(cb => cb(this.editing ? "onfocus" : "defocus", this));
20606
+ this.editing && this.isEditableRichtext(e) ? this.onFocus(e) : this.deFocus(!0), this.triggerRender(), this.pointerDown = !0, this.updateCbs.forEach(cb => cb(this.editing ? "onfocus" : "defocus", this));
20545
20607
  }, this.handlePointerUp = e => {
20546
20608
  this.pointerDown = !1;
20547
20609
  }, this.handleDBLClick = e => {
@@ -20649,7 +20711,7 @@
20649
20711
  } = cache,
20650
20712
  totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20651
20713
  if (x) {
20652
- x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 2] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + .2 : x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 1] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + 1 - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - 1 + .2 : this.curCursorIdx += x, this.curCursorIdx < -.1 ? this.curCursorIdx = -.1 : this.curCursorIdx > totalCursorCount + .1 && (this.curCursorIdx = totalCursorCount + .1);
20714
+ x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 2] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + .2 : x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 1] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + 1 - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - 1 + .2 : this.curCursorIdx += x, this.curCursorIdx < -.1 ? this.curCursorIdx = -.1 : this.curCursorIdx > totalCursorCount + .1 && (this.curCursorIdx = totalCursorCount + .1), this.selectionStartCursorIdx = this.curCursorIdx;
20653
20715
  const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
20654
20716
  this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this.hideSelection();
20655
20717
  }
@@ -20742,7 +20804,8 @@
20742
20804
  lineWidth: 1,
20743
20805
  zIndex: -1
20744
20806
  });
20745
- this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot();
20807
+ const shadow = this.getShadow(this.currRt);
20808
+ this.addEditLineOrBgOrBounds(this.shadowBounds, shadow), this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot();
20746
20809
  }
20747
20810
  trySyncPlaceholderToTextConfig() {
20748
20811
  if (!this.currRt) return;
@@ -20777,8 +20840,22 @@
20777
20840
  stopPropagation(e) {
20778
20841
  e.stopPropagation();
20779
20842
  }
20843
+ addEditLineOrBgOrBounds(graphic, shadowRoot) {
20844
+ let group = shadowRoot.getElementById("emptyBoundsContainer");
20845
+ group || (group = createGroup({
20846
+ x: 0,
20847
+ y: 0,
20848
+ width: 0,
20849
+ height: 0,
20850
+ boundsMode: "empty"
20851
+ }), group.id = "emptyBoundsContainer", shadowRoot.add(group)), group.add(graphic);
20852
+ }
20853
+ removeEditLineOrBgOrBounds(graphic, shadowRoot) {
20854
+ const group = shadowRoot.getElementById("emptyBoundsContainer");
20855
+ group && group.removeChild(graphic);
20856
+ }
20780
20857
  onFocus(e, data) {
20781
- this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0;
20858
+ this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0, this.editing = !0;
20782
20859
  const target = e.target;
20783
20860
  if (!target || "richtext" !== target.type) return;
20784
20861
  this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
@@ -20802,7 +20879,7 @@
20802
20879
  width: 0,
20803
20880
  height: 0
20804
20881
  });
20805
- this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
20882
+ this.editBg = g, this.addEditLineOrBgOrBounds(this.editLine, shadowRoot), this.addEditLineOrBgOrBounds(this.editBg, shadowRoot);
20806
20883
  }
20807
20884
  if (data = data || this.computedCursorPosByEvent(e, cache)) {
20808
20885
  const {
@@ -20867,27 +20944,22 @@
20867
20944
  }
20868
20945
  deFocus() {
20869
20946
  let trulyDeFocus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
20870
- this.updateCbs && this.updateCbs.forEach(cb => cb("beforeDefocus", this, {
20947
+ this.editing = !1, this.updateCbs && this.updateCbs.forEach(cb => cb("beforeDefocus", this, {
20871
20948
  trulyDeFocus: trulyDeFocus
20872
20949
  }));
20873
- const target = this.currRt;
20874
- if (!target) return;
20950
+ const currRt = this.currRt;
20951
+ if (!currRt) return;
20875
20952
  const {
20876
20953
  editOptions = {}
20877
- } = target.attribute;
20878
- editOptions.stopPropagation && target.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20879
- const currRt = this.currRt;
20880
- this.currRt = null, this.editLine && (this.editLine.parent && this.editLine.parent.removeChild(this.editLine), this.editLine.release(), this.editLine = null, this.editBg.parent && this.editBg.parent.removeChild(this.editBg), this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.shadowBounds.parent && this.shadowBounds.parent.removeChild(this.shadowBounds), this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder), this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1;
20881
- const textConfig = currRt.attribute.textConfig;
20882
- let lastConfig = textConfig[textConfig.length - 1],
20883
- cleared = !1;
20884
- for (; lastConfig && "\n" === lastConfig.text;) textConfig.pop(), lastConfig = textConfig[textConfig.length - 1], cleared = !0;
20885
- cleared && currRt.setAttributes({
20886
- textConfig: textConfig
20887
- });
20954
+ } = currRt.attribute;
20955
+ editOptions.stopPropagation && currRt.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), currRt.detachShadow()), this.currRt = null;
20956
+ const shadowRoot = this.getShadow(currRt);
20957
+ this.editLine && (this.removeEditLineOrBgOrBounds(this.editLine, shadowRoot), this.editLine.release(), this.editLine = null, this.removeEditLineOrBgOrBounds(this.editBg, shadowRoot), this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.removeEditLineOrBgOrBounds(this.shadowBounds, shadowRoot), this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder), this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1, currRt.removeEventListener("pointerleave", this.handleLeave);
20888
20958
  }
20889
20959
  addAnimateToLine(line) {
20890
- line.animates && line.animates.forEach(animate => {
20960
+ line.setAttributes({
20961
+ opacity: 1
20962
+ }), line.animates && line.animates.forEach(animate => {
20891
20963
  animate.stop(), animate.release();
20892
20964
  });
20893
20965
  line.animate({
@@ -20996,7 +21068,8 @@
20996
21068
  getShadow(rt) {
20997
21069
  const sr = rt.shadowRoot || rt.attachShadow();
20998
21070
  return sr.setAttributes({
20999
- boundsMode: "empty"
21071
+ width: 1,
21072
+ height: 1
21000
21073
  }), sr;
21001
21074
  }
21002
21075
  getLineByPoint(cache, p1) {
@@ -21030,7 +21103,10 @@
21030
21103
  return -1;
21031
21104
  }
21032
21105
  isRichtext(e) {
21033
- return !(!e.target || "richtext" !== e.target.type || !e.target.attribute.editable);
21106
+ return !(!e.target || "richtext" !== e.target.type);
21107
+ }
21108
+ isEditableRichtext(e) {
21109
+ return this.isRichtext(e) && !!e.target.attribute.editable;
21034
21110
  }
21035
21111
  triggerRender() {
21036
21112
  this.pluginService.stage.renderNextFrame();
@@ -21176,7 +21252,7 @@
21176
21252
  target && (this.currRt = target, e ? this._forceFocusByEvent(e) : this._forceFocusByCursorIndex(null != cursorIndex ? cursorIndex : -.1));
21177
21253
  }
21178
21254
  _forceFocusByEvent(e) {
21179
- this.handleEnter(e), this.handlePointerDown(e), this.handlePointerUp(e);
21255
+ this.handleEnter(), this.handlePointerDown(e), this.handlePointerUp(e);
21180
21256
  }
21181
21257
  _forceFocusByCursorIndex(cursorIndex) {
21182
21258
  const richtext = this.currRt;
@@ -27497,13 +27573,15 @@
27497
27573
  this.canvas = new NodeCanvas(options);
27498
27574
  }
27499
27575
  createWindowByCanvas(params) {
27500
- const canvas = params.canvas;
27576
+ var _a;
27577
+ const canvas = params.canvas,
27578
+ dpr = null !== (_a = params.dpr) && void 0 !== _a ? _a : 1;
27501
27579
  let width = params.width,
27502
27580
  height = params.height;
27503
- null != width && null != height && params.canvasControled || (width = canvas.width, height = canvas.height), this.canvas = new NodeCanvas({
27581
+ null != width && null != height && params.canvasControled || (width = canvas.width / dpr, height = canvas.height / dpr), this.canvas = new NodeCanvas({
27504
27582
  width: width,
27505
27583
  height: height,
27506
- dpr: 1,
27584
+ dpr: dpr,
27507
27585
  nativeCanvas: canvas,
27508
27586
  canvasControled: params.canvasControled
27509
27587
  });
@@ -31241,9 +31319,193 @@
31241
31319
  _registerWrapText.__loaded = !1;
31242
31320
  const registerWrapText = _registerWrapText;
31243
31321
 
31322
+ function randomOpacity(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31323
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31324
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31325
+ graphic.dynamicTextureCache || (graphic.dynamicTextureCache = new Array(rowCount * columnCount).fill(0).map(item => 2 * Math.random() * Math.PI));
31326
+ const targetRandomValue = graphic.dynamicTextureCache[row * columnCount + column],
31327
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI + targetRandomValue) + 1) / 2;
31328
+ return Math.min(1, Math.max(0, _r));
31329
+ }
31330
+ function columnLeftToRight(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31331
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31332
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31333
+ const delay = column / columnCount,
31334
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * delay * Math.PI) + 1) / 2;
31335
+ return Math.min(1, Math.max(0, _r));
31336
+ }
31337
+ function columnRightToLeft(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31338
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31339
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31340
+ const delay = (columnCount - 1 - column) / columnCount,
31341
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * delay * Math.PI) + 1) / 2;
31342
+ return Math.min(1, Math.max(0, _r));
31343
+ }
31344
+ function rowTopToBottom(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31345
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31346
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31347
+ const delay = row / rowCount,
31348
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * delay * Math.PI) + 1) / 2;
31349
+ return Math.min(1, Math.max(0, _r));
31350
+ }
31351
+ function rowBottomToTop(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31352
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31353
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31354
+ const delay = (rowCount - 1 - row) / rowCount,
31355
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * delay * Math.PI) + 1) / 2;
31356
+ return Math.min(1, Math.max(0, _r));
31357
+ }
31358
+ function diagonalCenterToEdge(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31359
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31360
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31361
+ const centerRow = rowCount / 2,
31362
+ centerCol = columnCount / 2,
31363
+ distance = Math.sqrt(Math.pow((row - centerRow) / rowCount, 2) + Math.pow((column - centerCol) / columnCount, 2)),
31364
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * distance * Math.PI) + 1) / 2;
31365
+ return Math.min(1, Math.max(0, _r));
31366
+ }
31367
+ function diagonalTopLeftToBottomRight(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31368
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31369
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31370
+ const delay = (row / rowCount + column / columnCount) / 2,
31371
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * delay * Math.PI) + 1) / 2;
31372
+ return Math.min(1, Math.max(0, _r));
31373
+ }
31374
+ function rotationScan(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31375
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31376
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31377
+ const centerRow = rowCount / 2,
31378
+ centerCol = columnCount / 2,
31379
+ angle = Math.atan2(row - centerRow, column - centerCol),
31380
+ delay = (angle < 0 ? angle + 2 * Math.PI : angle) / (2 * Math.PI),
31381
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * delay * Math.PI) + 1) / 2;
31382
+ return Math.min(1, Math.max(0, _r));
31383
+ }
31384
+ function rippleEffect(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31385
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31386
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31387
+ const centerRow = rowCount / 2,
31388
+ centerCol = columnCount / 2,
31389
+ normalizedDistance = Math.sqrt(Math.pow(row - centerRow, 2) + Math.pow(column - centerCol, 2)) / Math.sqrt(Math.pow(rowCount / 2, 2) + Math.pow(columnCount / 2, 2)),
31390
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI * 3 - 2 * normalizedDistance * Math.PI) + 1) / 2;
31391
+ return Math.min(1, Math.max(0, _r));
31392
+ }
31393
+ function snakeWave(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31394
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31395
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31396
+ const delay = (row + column) % (rowCount + columnCount) / (rowCount + columnCount),
31397
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 4 * delay * Math.PI) + 1) / 2;
31398
+ return Math.min(1, Math.max(0, _r));
31399
+ }
31400
+ function alternatingWave(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31401
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31402
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31403
+ const rowPhase = row / rowCount,
31404
+ colPhase = column / columnCount,
31405
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * rowPhase * Math.PI) * Math.sin(2 * ratio * Math.PI - 2 * colPhase * Math.PI) + 1) / 2;
31406
+ return Math.min(1, Math.max(0, _r));
31407
+ }
31408
+ function spiralEffect(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31409
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31410
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31411
+ const centerRow = rowCount / 2,
31412
+ centerCol = columnCount / 2,
31413
+ distance = Math.sqrt(Math.pow(row - centerRow, 2) + Math.pow(column - centerCol, 2)),
31414
+ angle = Math.atan2(row - centerRow, column - centerCol),
31415
+ delay = (distance / Math.sqrt(Math.pow(rowCount / 2, 2) + Math.pow(columnCount / 2, 2)) + angle / (2 * Math.PI)) / 2,
31416
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 4 * delay * Math.PI) + 1) / 2;
31417
+ return Math.min(1, Math.max(0, _r));
31418
+ }
31419
+ function columnCenterToEdge(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31420
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31421
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31422
+ const centerCol = columnCount / 2,
31423
+ distance = Math.abs(column - centerCol) / centerCol,
31424
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * distance * Math.PI) + 1) / 2;
31425
+ return Math.min(1, Math.max(0, _r));
31426
+ }
31427
+ function columnEdgeToCenter(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31428
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31429
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31430
+ const centerCol = columnCount / 2,
31431
+ distance = 1 - Math.abs(column - centerCol) / centerCol,
31432
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * distance * Math.PI) + 1) / 2;
31433
+ return Math.min(1, Math.max(0, _r));
31434
+ }
31435
+ function rowCenterToEdge(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31436
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31437
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31438
+ const centerRow = rowCount / 2,
31439
+ distance = Math.abs(row - centerRow) / centerRow,
31440
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * distance * Math.PI) + 1) / 2;
31441
+ return Math.min(1, Math.max(0, _r));
31442
+ }
31443
+ function rowEdgeToCenter(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31444
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31445
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31446
+ const centerRow = rowCount / 2,
31447
+ distance = 1 - Math.abs(row - centerRow) / centerRow,
31448
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * distance * Math.PI) + 1) / 2;
31449
+ return Math.min(1, Math.max(0, _r));
31450
+ }
31451
+ function cornerToCenter(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31452
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31453
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31454
+ const centerRow = rowCount / 2,
31455
+ centerCol = columnCount / 2,
31456
+ distance = Math.sqrt(Math.pow((row - centerRow) / centerRow, 2) + Math.pow((column - centerCol) / centerCol, 2)),
31457
+ normalizedDistance = Math.min(distance, 1),
31458
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * normalizedDistance * Math.PI) + 1) / 2;
31459
+ return Math.min(1, Math.max(0, _r));
31460
+ }
31461
+ function centerToCorner(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31462
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31463
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31464
+ const centerRow = rowCount / 2,
31465
+ centerCol = columnCount / 2,
31466
+ distance = Math.sqrt(Math.pow((row - centerRow) / centerRow, 2) + Math.pow((column - centerCol) / centerCol, 2)),
31467
+ normalizedDistance = 1 - Math.min(distance, 1),
31468
+ _r = minRatio + amplitude * (Math.sin(2 * ratio * Math.PI - 2 * normalizedDistance * Math.PI) + 1) / 2;
31469
+ return Math.min(1, Math.max(0, _r));
31470
+ }
31471
+ function pulseWave(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31472
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31473
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31474
+ const centerRow = rowCount / 2,
31475
+ centerCol = columnCount / 2,
31476
+ distance = Math.sqrt(Math.pow((row - centerRow) / centerRow, 2) + Math.pow((column - centerCol) / centerCol, 2)),
31477
+ normalizedDistance = Math.min(distance, 1),
31478
+ wavePhase = 2 * ratio * Math.PI * 3,
31479
+ decay = Math.max(0, 1 - normalizedDistance),
31480
+ _r = minRatio + amplitude * ((Math.sin(wavePhase - 4 * normalizedDistance * Math.PI) + 1) / 2) * (.7 * decay + .3);
31481
+ return Math.min(1, Math.max(0, _r));
31482
+ }
31483
+ function particleEffect(ctx, row, column, rowCount, columnCount, ratio, graphic) {
31484
+ let minRatio = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
31485
+ let amplitude = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 1;
31486
+ graphic.dynamicTextureCache || (graphic.dynamicTextureCache = {
31487
+ phases: new Array(rowCount * columnCount).fill(0).map(() => 2 * Math.random() * Math.PI),
31488
+ speeds: new Array(rowCount * columnCount).fill(0).map(() => .5 + .5 * Math.random()),
31489
+ directions: new Array(rowCount * columnCount).fill(0).map(() => 2 * Math.random() * Math.PI)
31490
+ });
31491
+ const index = row * columnCount + column,
31492
+ phase = graphic.dynamicTextureCache.phases[index],
31493
+ speed = graphic.dynamicTextureCache.speeds[index],
31494
+ direction = graphic.dynamicTextureCache.directions[index],
31495
+ centerRow = rowCount / 2,
31496
+ centerCol = columnCount / 2,
31497
+ distance = Math.sqrt(Math.pow((row - centerRow) / centerRow, 2) + Math.pow((column - centerCol) / centerCol, 2)),
31498
+ normalizedDistance = Math.min(distance, 1),
31499
+ scatterRatio = (ratio - .4) / .6,
31500
+ movement = Math.sin(scatterRatio * speed * 8 * Math.PI + phase + direction * scatterRatio),
31501
+ distanceEffect = Math.cos(normalizedDistance * Math.PI + scatterRatio * Math.PI),
31502
+ _r = minRatio + amplitude * ((movement + 1) / 2 * Math.max(0, 1 - 1.2 * scatterRatio) * (.3 + .7 * distanceEffect));
31503
+ return Math.min(1, Math.max(0, _r));
31504
+ }
31505
+
31244
31506
  const roughModule = _roughModule;
31245
31507
 
31246
- const version = "0.22.0";
31508
+ const version = "0.22.1";
31247
31509
  preLoadAllModule();
31248
31510
  if (isBrowserEnv()) {
31249
31511
  loadBrowserEnv(container);
@@ -31575,6 +31837,7 @@
31575
31837
  exports.addAttributeToPrototype = addAttributeToPrototype;
31576
31838
  exports.alignBezierCurves = alignBezierCurves;
31577
31839
  exports.alignSubpath = alignSubpath;
31840
+ exports.alternatingWave = alternatingWave;
31578
31841
  exports.application = application;
31579
31842
  exports.applyTransformOnBezierCurves = applyTransformOnBezierCurves;
31580
31843
  exports.arc3dCanvasPickModule = arc3dCanvasPickModule;
@@ -31599,6 +31862,7 @@
31599
31862
  exports.calculateArcCornerRadius = calculateArcCornerRadius;
31600
31863
  exports.calculateLineHeight = calculateLineHeight;
31601
31864
  exports.canvasAllocate = canvasAllocate;
31865
+ exports.centerToCorner = centerToCorner;
31602
31866
  exports.centroidOfSubpath = centroidOfSubpath;
31603
31867
  exports.circleBounds = circleBounds;
31604
31868
  exports.circleCanvasPickModule = circleCanvasPickModule;
@@ -31608,8 +31872,13 @@
31608
31872
  exports.cloneGraphic = cloneGraphic;
31609
31873
  exports.colorEqual = colorEqual;
31610
31874
  exports.colorStringInterpolationToStr = colorStringInterpolationToStr;
31875
+ exports.columnCenterToEdge = columnCenterToEdge;
31876
+ exports.columnEdgeToCenter = columnEdgeToCenter;
31877
+ exports.columnLeftToRight = columnLeftToRight;
31878
+ exports.columnRightToLeft = columnRightToLeft;
31611
31879
  exports.container = container;
31612
31880
  exports.cornerTangents = cornerTangents;
31881
+ exports.cornerToCenter = cornerToCenter;
31613
31882
  exports.createArc = createArc;
31614
31883
  exports.createArc3d = createArc3d;
31615
31884
  exports.createArea = createArea;
@@ -31670,6 +31939,8 @@
31670
31939
  exports.defaultTextAllocate = defaultTextAllocate;
31671
31940
  exports.defaultTicker = defaultTicker;
31672
31941
  exports.defaultTimeline = defaultTimeline;
31942
+ exports.diagonalCenterToEdge = diagonalCenterToEdge;
31943
+ exports.diagonalTopLeftToBottomRight = diagonalTopLeftToBottomRight;
31673
31944
  exports.drawArc = drawArc;
31674
31945
  exports.drawArcPath = drawArcPath$1;
31675
31946
  exports.drawAreaSegments = drawAreaSegments;
@@ -31783,6 +32054,7 @@
31783
32054
  exports.parsePadding = parsePadding;
31784
32055
  exports.parseStroke = parseStroke;
31785
32056
  exports.parseSvgPath = parseSvgPath;
32057
+ exports.particleEffect = particleEffect;
31786
32058
  exports.pathCanvasPickModule = pathCanvasPickModule;
31787
32059
  exports.pathMathPickModule = pathMathPickModule;
31788
32060
  exports.pathModule = pathModule;
@@ -31797,12 +32069,14 @@
31797
32069
  exports.polygonMathPickModule = polygonMathPickModule;
31798
32070
  exports.polygonModule = polygonModule;
31799
32071
  exports.preLoadAllModule = preLoadAllModule;
32072
+ exports.pulseWave = pulseWave;
31800
32073
  exports.pyramid3dCanvasPickModule = pyramid3dCanvasPickModule;
31801
32074
  exports.pyramid3dModule = pyramid3dModule;
31802
32075
  exports.quadCalc = quadCalc;
31803
32076
  exports.quadLength = quadLength;
31804
32077
  exports.quadPointAt = quadPointAt;
31805
32078
  exports.rafBasedSto = rafBasedSto;
32079
+ exports.randomOpacity = randomOpacity;
31806
32080
  exports.rect3dCanvasPickModule = rect3dCanvasPickModule;
31807
32081
  exports.rect3dModule = rect3dModule;
31808
32082
  exports.rectCanvasPickModule = rectCanvasPickModule;
@@ -31858,16 +32132,24 @@
31858
32132
  exports.richTextMathPickModule = richTextMathPickModule;
31859
32133
  exports.richtextCanvasPickModule = richtextCanvasPickModule;
31860
32134
  exports.richtextModule = richtextModule;
32135
+ exports.rippleEffect = rippleEffect;
31861
32136
  exports.rotateX = rotateX;
31862
32137
  exports.rotateY = rotateY;
31863
32138
  exports.rotateZ = rotateZ;
32139
+ exports.rotationScan = rotationScan;
31864
32140
  exports.roughModule = roughModule;
32141
+ exports.rowBottomToTop = rowBottomToTop;
32142
+ exports.rowCenterToEdge = rowCenterToEdge;
32143
+ exports.rowEdgeToCenter = rowEdgeToCenter;
32144
+ exports.rowTopToBottom = rowTopToBottom;
31865
32145
  exports.runFill = runFill;
31866
32146
  exports.runStroke = runStroke;
31867
32147
  exports.scaleMat4 = scaleMat4;
31868
32148
  exports.segments = segments;
31869
32149
  exports.shouldUseMat4 = shouldUseMat4;
32150
+ exports.snakeWave = snakeWave;
31870
32151
  exports.snapLength = snapLength;
32152
+ exports.spiralEffect = spiralEffect;
31871
32153
  exports.splitArc = splitArc;
31872
32154
  exports.splitArea = splitArea;
31873
32155
  exports.splitCircle = splitCircle;