@visactor/vtable-calendar 1.22.13-alpha.10 → 1.22.13-alpha.11

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.
@@ -4575,6 +4575,7 @@
4575
4575
  backgroundScale: 1,
4576
4576
  backgroundOffsetX: 0,
4577
4577
  backgroundOffsetY: 0,
4578
+ backgroundPosition: "top-left",
4578
4579
  blur: 0,
4579
4580
  filter: "",
4580
4581
  cursor: null,
@@ -4747,11 +4748,16 @@
4747
4748
  const DefaultImageAttribute = Object.assign(Object.assign({
4748
4749
  repeatX: "no-repeat",
4749
4750
  repeatY: "no-repeat",
4751
+ imageMode: void 0,
4750
4752
  image: "",
4751
4753
  width: 0,
4752
4754
  height: 0,
4753
4755
  maxWidth: 500,
4754
- maxHeight: 500
4756
+ maxHeight: 500,
4757
+ imagePosition: "top-left",
4758
+ imageScale: 1,
4759
+ imageOffsetX: 0,
4760
+ imageOffsetY: 0
4755
4761
  }, DefaultAttribute), {
4756
4762
  fill: !0,
4757
4763
  cornerRadius: 0,
@@ -9152,6 +9158,7 @@
9152
9158
  const tempConstantXYKey = ["x", "y"],
9153
9159
  tempConstantScaleXYKey = ["scaleX", "scaleY"],
9154
9160
  tempConstantAngleKey = ["angle"],
9161
+ builtinTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave"]),
9155
9162
  point = new Point();
9156
9163
  const NOWORK_ANIMATE_ATTR = {
9157
9164
  strokeSeg: 1,
@@ -9208,7 +9215,7 @@
9208
9215
  }
9209
9216
  constructor(params = {}) {
9210
9217
  var _a;
9211
- super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
9218
+ super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background && this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0), isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
9212
9219
  }
9213
9220
  getGraphicService() {
9214
9221
  var _a, _b;
@@ -9397,7 +9404,7 @@
9397
9404
  });
9398
9405
  }
9399
9406
  setAttributes(params, forceUpdateTag = !1, context) {
9400
- 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));
9407
+ params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0), isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
9401
9408
  }
9402
9409
  _setAttributes(params, forceUpdateTag = !1, context) {
9403
9410
  const keys = Object.keys(params);
@@ -9412,7 +9419,7 @@
9412
9419
  const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
9413
9420
  [key]: value
9414
9421
  }, this.attribute, key, context);
9415
- params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "shadowGraphic" === key && this.setShadowGraphic(value);
9422
+ params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
9416
9423
  }
9417
9424
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
9418
9425
  for (let i = 0; i < k.length; i++) {
@@ -9431,7 +9438,7 @@
9431
9438
  const context = {
9432
9439
  type: AttributeUpdateType.INIT
9433
9440
  };
9434
- params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
9441
+ params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background && this.loadImage(params.background, !0), isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
9435
9442
  }
9436
9443
  translate(x, y) {
9437
9444
  var _a, _b;
@@ -9764,7 +9771,8 @@
9764
9771
  return isString$2(path, !0) ? this.pathProxy = new CustomPath2D().fromString(path) : this.pathProxy = new CustomPath2D(), this.pathProxy;
9765
9772
  }
9766
9773
  loadImage(image, background = !1) {
9767
- if (!image || background && backgroundNotImage(image)) return;
9774
+ if (background && (null == image ? void 0 : image.background) && (image = image.background), background && (!image || backgroundNotImage(image))) return void (this.backgroundImg = !1);
9775
+ if (!image) return;
9768
9776
  const url = image;
9769
9777
  this.resources || (this.resources = new Map());
9770
9778
  const cache = {
@@ -9819,7 +9827,10 @@
9819
9827
  }
9820
9828
  }
9821
9829
  function backgroundNotImage(image) {
9822
- return !(!image.fill && !image.stroke);
9830
+ return "string" == typeof image ? !(image.startsWith("<svg") || isValidUrl$1(image) || image.includes("/") || isBase64$1(image)) : !(!image.fill && !image.stroke) || !("string" != typeof image.gradient || !Array.isArray(image.stops));
9831
+ }
9832
+ function isExternalTexture(texture) {
9833
+ return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$7(texture));
9823
9834
  }
9824
9835
  Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget$2);
9825
9836
 
@@ -11913,7 +11924,7 @@
11913
11924
  return [new Paragraph(text1, paragraph.newLine, paragraph.character, paragraph.ascentDescentMode), new Paragraph(text2, !0, paragraph.character, paragraph.ascentDescentMode)];
11914
11925
  }
11915
11926
 
11916
- const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", ...GRAPHIC_UPDATE_TAG_KEY];
11927
+ const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", "imageMode", "imagePosition", "imageScale", "imageOffsetX", "imageOffsetY", ...GRAPHIC_UPDATE_TAG_KEY];
11917
11928
  let Image$1 = class Image extends Graphic {
11918
11929
  constructor(params) {
11919
11930
  super(params), this.type = "image", this.numberType = IMAGE_NUMBER_TYPE, this.loadImage(this.attribute.image);
@@ -12018,6 +12029,7 @@
12018
12029
  };
12019
12030
  Image$1.NOWORK_ANIMATE_ATTR = Object.assign({
12020
12031
  image: 1,
12032
+ imageMode: 1,
12021
12033
  repeatX: 1,
12022
12034
  repeatY: 1
12023
12035
  }, NOWORK_ANIMATE_ATTR);
@@ -12994,11 +13006,12 @@
12994
13006
  backgroundScale = graphicAttribute.backgroundScale,
12995
13007
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
12996
13008
  backgroundOffsetY = graphicAttribute.backgroundOffsetY,
12997
- backgroundClip = graphicAttribute.backgroundClip
13009
+ backgroundClip = graphicAttribute.backgroundClip,
13010
+ backgroundPosition = graphicAttribute.backgroundPosition
12998
13011
  } = graphic.attribute;
12999
13012
  if (background) if (graphic.backgroundImg && graphic.resources) {
13000
- const res = graphic.resources.get(background);
13001
- if ("success" !== res.state || !res.data) return;
13013
+ const res = graphic.resources.get(getBackgroundImage(background));
13014
+ if (!res || "success" !== res.state || !res.data) return;
13002
13015
  if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
13003
13016
  const groupAttribute = getTheme(graphic.parent).group,
13004
13017
  {
@@ -13015,59 +13028,160 @@
13015
13028
  backgroundKeepAspectRatio: backgroundKeepAspectRatio,
13016
13029
  backgroundScale: backgroundScale,
13017
13030
  backgroundOffsetX: backgroundOffsetX,
13018
- backgroundOffsetY: backgroundOffsetY
13031
+ backgroundOffsetY: backgroundOffsetY,
13032
+ backgroundPosition: backgroundPosition
13019
13033
  }), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
13020
13034
  } else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
13021
13035
  }
13022
13036
  doDrawImage(context, data, b, params) {
13023
- const {
13024
- backgroundMode: backgroundMode,
13025
- backgroundFit: backgroundFit,
13026
- backgroundKeepAspectRatio: backgroundKeepAspectRatio,
13027
- backgroundScale = 1,
13028
- backgroundOffsetX = 0,
13029
- backgroundOffsetY = 0
13030
- } = params,
13031
- targetW = b.width(),
13032
- targetH = b.height();
13033
- let w = targetW,
13034
- h = targetH;
13035
- if ("no-repeat" === backgroundMode) {
13036
- if (backgroundFit) {
13037
- if (backgroundKeepAspectRatio) {
13038
- const maxScale = Math.max(targetW / data.width, targetH / data.height);
13039
- context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
13040
- } else context.drawImage(data, b.x1, b.y1, b.width(), b.height());
13041
- } else {
13042
- const resW = data.width * backgroundScale,
13043
- resH = data.height * backgroundScale;
13044
- context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
13045
- }
13046
- } else {
13047
- if (backgroundFit && "repeat" !== backgroundMode && (data.width || data.height)) {
13048
- const resW = data.width,
13049
- resH = data.height;
13050
- if ("repeat-x" === backgroundMode) {
13051
- w = resW * (targetH / resH), h = targetH;
13052
- } else if ("repeat-y" === backgroundMode) {
13053
- h = resH * (targetW / resW), w = targetW;
13054
- }
13055
- const dpr = context.dpr,
13056
- canvas = canvasAllocate.allocate({
13057
- width: w,
13058
- height: h,
13059
- dpr: dpr
13060
- }),
13061
- ctx = canvas.getContext("2d");
13062
- ctx && (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, w, h), ctx.drawImage(data, 0, 0, w, h), data = canvas.nativeCanvas), canvasAllocate.free(canvas);
13063
- }
13064
- const dpr = context.dpr,
13065
- pattern = context.createPattern(data, backgroundMode);
13066
- pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0])), context.fillStyle = pattern, context.translate(b.x1, b.y1), context.fillRect(0, 0, targetW, targetH), context.translate(-b.x1, -b.y1);
13067
- }
13037
+ drawBackgroundImage(context, data, b, params);
13068
13038
  }
13069
13039
  }
13070
13040
  const defaultBaseBackgroundRenderContribution = new DefaultBaseBackgroundRenderContribution();
13041
+ const verticalPositionKeywords = new Set(["top", "center", "bottom"]);
13042
+ function getBackgroundImage(background) {
13043
+ var _a;
13044
+ return null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
13045
+ }
13046
+ function resolveBackgroundSizing({
13047
+ backgroundFit: backgroundFit,
13048
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
13049
+ }) {
13050
+ return backgroundFit ? backgroundKeepAspectRatio ? "cover" : "fill" : "auto";
13051
+ }
13052
+ const NO_REPEAT_SIZING_MAP = {
13053
+ "no-repeat-cover": "cover",
13054
+ "no-repeat-contain": "contain",
13055
+ "no-repeat-fill": "fill",
13056
+ "no-repeat-auto": "auto"
13057
+ };
13058
+ function resolveBackgroundDrawMode({
13059
+ backgroundMode: backgroundMode,
13060
+ backgroundFit: backgroundFit,
13061
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
13062
+ }) {
13063
+ const sizing = NO_REPEAT_SIZING_MAP[backgroundMode];
13064
+ return sizing ? {
13065
+ backgroundRepeatMode: "no-repeat",
13066
+ backgroundSizing: sizing
13067
+ } : {
13068
+ backgroundRepeatMode: backgroundMode,
13069
+ backgroundSizing: resolveBackgroundSizing({
13070
+ backgroundFit: backgroundFit,
13071
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
13072
+ })
13073
+ };
13074
+ }
13075
+ function isPercentageValue(value) {
13076
+ return /^-?\d+(\.\d+)?%$/.test(value);
13077
+ }
13078
+ function parsePositionToken(value, remainSpace, startKeyword, centerKeyword, endKeyword) {
13079
+ if ("number" == typeof value && Number.isFinite(value)) return value;
13080
+ const normalizedValue = `${null != value ? value : ""}`.trim().toLowerCase();
13081
+ if (!normalizedValue || normalizedValue === startKeyword) return 0;
13082
+ if (normalizedValue === centerKeyword) return remainSpace / 2;
13083
+ if (normalizedValue === endKeyword) return remainSpace;
13084
+ if (isPercentageValue(normalizedValue)) return remainSpace * parseFloat(normalizedValue) / 100;
13085
+ const parsedValue = Number(normalizedValue);
13086
+ return Number.isFinite(parsedValue) ? parsedValue : 0;
13087
+ }
13088
+ function normalizeBackgroundPosition(position) {
13089
+ var _a, _b;
13090
+ if (Array.isArray(position)) return [null !== (_a = position[0]) && void 0 !== _a ? _a : "left", null !== (_b = position[1]) && void 0 !== _b ? _b : "top"];
13091
+ const tokens = `${null != position ? position : "top-left"}`.trim().toLowerCase().replace(/-/g, " ").split(/\s+/).filter(Boolean);
13092
+ if (0 === tokens.length) return ["left", "top"];
13093
+ if (1 === tokens.length) {
13094
+ const token = tokens[0];
13095
+ return "center" === token ? ["center", "center"] : verticalPositionKeywords.has(token) ? ["center", token] : [token, "center"];
13096
+ }
13097
+ let horizontal, vertical;
13098
+ const genericTokens = [];
13099
+ for (let i = 0; i < 2; i++) {
13100
+ const token = tokens[i];
13101
+ "left" !== token && "right" !== token ? "top" !== token && "bottom" !== token ? genericTokens.push(token) : vertical = token : horizontal = token;
13102
+ }
13103
+ return null == horizontal && genericTokens.length && (horizontal = genericTokens.shift()), null == vertical && genericTokens.length && (vertical = genericTokens.shift()), [null != horizontal ? horizontal : "left", null != vertical ? vertical : "top"];
13104
+ }
13105
+ function resolveBackgroundPosition(position, remainWidth, remainHeight) {
13106
+ const [horizontalPosition, verticalPosition] = normalizeBackgroundPosition(position);
13107
+ return {
13108
+ x: parsePositionToken(horizontalPosition, remainWidth, "left", "center", "right"),
13109
+ y: parsePositionToken(verticalPosition, remainHeight, "top", "center", "bottom")
13110
+ };
13111
+ }
13112
+ function pickRenderableDimension(...values) {
13113
+ for (const value of values) if ("number" == typeof value && Number.isFinite(value) && value > 0) return value;
13114
+ return null;
13115
+ }
13116
+ function resolveRenderableImageSize(data) {
13117
+ if (!data) return null;
13118
+ const width = pickRenderableDimension(data.naturalWidth, data.videoWidth, data.width),
13119
+ height = pickRenderableDimension(data.naturalHeight, data.videoHeight, data.height);
13120
+ return null == width || null == height ? null : {
13121
+ width: width,
13122
+ height: height
13123
+ };
13124
+ }
13125
+ function drawBackgroundImage(context, data, b, params) {
13126
+ var _a, _b;
13127
+ const {
13128
+ backgroundMode: backgroundMode,
13129
+ backgroundFit: backgroundFit,
13130
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
13131
+ backgroundScale = 1,
13132
+ backgroundOffsetX = 0,
13133
+ backgroundOffsetY = 0,
13134
+ backgroundPosition = "top-left"
13135
+ } = params,
13136
+ targetW = b.width(),
13137
+ targetH = b.height(),
13138
+ sourceSize = resolveRenderableImageSize(data),
13139
+ {
13140
+ backgroundRepeatMode: backgroundRepeatMode,
13141
+ backgroundSizing: resolvedBackgroundSizing
13142
+ } = resolveBackgroundDrawMode({
13143
+ backgroundMode: backgroundMode,
13144
+ backgroundFit: backgroundFit,
13145
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
13146
+ });
13147
+ let w = targetW,
13148
+ h = targetH;
13149
+ if (targetW <= 0 || targetH <= 0) return;
13150
+ if ("no-repeat" === backgroundRepeatMode) {
13151
+ let drawWidth = null !== (_a = null == sourceSize ? void 0 : sourceSize.width) && void 0 !== _a ? _a : targetW,
13152
+ drawHeight = null !== (_b = null == sourceSize ? void 0 : sourceSize.height) && void 0 !== _b ? _b : targetH;
13153
+ if ("cover" !== resolvedBackgroundSizing && "contain" !== resolvedBackgroundSizing || !sourceSize) "fill" === resolvedBackgroundSizing && (drawWidth = targetW, drawHeight = targetH);else {
13154
+ const scale = "cover" === resolvedBackgroundSizing ? Math.max(targetW / sourceSize.width, targetH / sourceSize.height) : Math.min(targetW / sourceSize.width, targetH / sourceSize.height);
13155
+ drawWidth = sourceSize.width * scale, drawHeight = sourceSize.height * scale;
13156
+ }
13157
+ drawWidth *= backgroundScale, drawHeight *= backgroundScale;
13158
+ const {
13159
+ x: x,
13160
+ y: y
13161
+ } = resolveBackgroundPosition(backgroundPosition, targetW - drawWidth, targetH - drawHeight);
13162
+ return void context.drawImage(data, b.x1 + x + backgroundOffsetX, b.y1 + y + backgroundOffsetY, drawWidth, drawHeight);
13163
+ }
13164
+ if (backgroundFit && "repeat" !== backgroundRepeatMode && sourceSize) {
13165
+ const resW = sourceSize.width,
13166
+ resH = sourceSize.height;
13167
+ if ("repeat-x" === backgroundRepeatMode) {
13168
+ w = resW * (targetH / resH), h = targetH;
13169
+ } else if ("repeat-y" === backgroundRepeatMode) {
13170
+ h = resH * (targetW / resW), w = targetW;
13171
+ }
13172
+ const dpr = context.dpr,
13173
+ canvas = canvasAllocate.allocate({
13174
+ width: w,
13175
+ height: h,
13176
+ dpr: dpr
13177
+ }),
13178
+ ctx = canvas.getContext("2d");
13179
+ ctx && (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, w, h), ctx.drawImage(data, 0, 0, w, h), data = canvas.nativeCanvas), canvasAllocate.free(canvas);
13180
+ }
13181
+ const dpr = context.dpr,
13182
+ pattern = context.createPattern(data, backgroundRepeatMode);
13183
+ pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0])), context.fillStyle = pattern, context.translate(b.x1, b.y1), context.fillRect(0, 0, targetW, targetH), context.translate(-b.x1, -b.y1);
13184
+ }
13071
13185
  let DefaultBaseInteractiveRenderContribution = class {
13072
13186
  constructor(subRenderContribitions) {
13073
13187
  this.subRenderContribitions = subRenderContribitions, this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
@@ -13113,6 +13227,7 @@
13113
13227
  }
13114
13228
  const defaultBaseClipRenderAfterContribution = new DefaultBaseClipRenderAfterContribution();
13115
13229
 
13230
+ const builtinProceduralTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid"]);
13116
13231
  function formatRatio(ratio) {
13117
13232
  return ratio <= .5 ? 4 * ratio - 1 : -4 * ratio + 3;
13118
13233
  }
@@ -13226,38 +13341,43 @@
13226
13341
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
13227
13342
  }
13228
13343
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
13229
- var _a;
13344
+ var _a, _b, _c, _d, _e, _f;
13230
13345
  const {
13231
13346
  textureRatio = graphicAttribute.textureRatio,
13232
13347
  textureOptions = null
13233
13348
  } = graphic.attribute;
13234
- let pattern = this.textureMap.get(texture);
13235
- if (!pattern) switch (texture) {
13236
- case "circle":
13237
- pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
13238
- break;
13239
- case "diamond":
13240
- pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
13241
- break;
13242
- case "rect":
13243
- pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
13244
- break;
13245
- case "vertical-line":
13246
- pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
13247
- break;
13248
- case "horizontal-line":
13249
- pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
13250
- break;
13251
- case "bias-lr":
13252
- pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
13253
- break;
13254
- case "bias-rl":
13255
- pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
13256
- break;
13257
- case "grid":
13258
- pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
13349
+ let pattern = null;
13350
+ const textureRadius = null !== (_a = null == textureOptions ? void 0 : textureOptions.radius) && void 0 !== _a ? _a : 0,
13351
+ patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr, textureRadius);
13352
+ if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
13353
+ if ("string" == typeof texture) switch (texture) {
13354
+ case "circle":
13355
+ pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
13356
+ break;
13357
+ case "diamond":
13358
+ pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
13359
+ break;
13360
+ case "rect":
13361
+ pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
13362
+ break;
13363
+ case "vertical-line":
13364
+ pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
13365
+ break;
13366
+ case "horizontal-line":
13367
+ pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
13368
+ break;
13369
+ case "bias-lr":
13370
+ pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
13371
+ break;
13372
+ case "bias-rl":
13373
+ pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
13374
+ break;
13375
+ case "grid":
13376
+ pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
13377
+ }
13378
+ pattern || (pattern = this.createResourcePattern(texture, graphic, context, texturePadding, textureRadius)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
13259
13379
  }
13260
- if (textureOptions && textureOptions.dynamicTexture) {
13380
+ if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
13261
13381
  const {
13262
13382
  gridConfig = {},
13263
13383
  useNewCanvas: useNewCanvas
@@ -13302,10 +13422,24 @@
13302
13422
  for (let i = 0; i < gridRows; i++) for (let j = 0; j < gridColumns; j++) {
13303
13423
  const _x = x + cellSize / 2 + j * cellSize,
13304
13424
  _y = y + cellSize / 2 + i * cellSize;
13305
- null === (_a = textureOptions.beforeDynamicTexture) || void 0 === _a || _a.call(textureOptions, context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height()), context.beginPath(), !1 === parsedPath.draw(context, Math.min(sizeW - gutterColumn, sizeH - gutterRow), _x, _y, 0) && context.closePath(), context.fillStyle = textureColor, textureOptions.dynamicTexture(context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height());
13425
+ null === (_b = textureOptions.beforeDynamicTexture) || void 0 === _b || _b.call(textureOptions, context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height()), context.beginPath(), !1 === parsedPath.draw(context, Math.min(sizeW - gutterColumn, sizeH - gutterRow), _x, _y, 0) && context.closePath(), context.fillStyle = textureColor, textureOptions.dynamicTexture(context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height());
13306
13426
  }
13307
13427
  useNewCanvas && (originalContext.globalAlpha = 1, originalContext.drawImage(newCanvas.nativeCanvas, 0, 0, newCanvas.nativeCanvas.width, newCanvas.nativeCanvas.height, b.x1, b.y1, b.width() * originalContext.dpr, b.height() * originalContext.dpr)), originalContext.restore();
13308
- } else if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
13428
+ } else if (pattern) {
13429
+ if (pattern.setTransform) {
13430
+ const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
13431
+ alignOffsetX = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _c ? _c : 0,
13432
+ alignOffsetY = null !== (_d = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _d ? _d : 0;
13433
+ let translateX = 0,
13434
+ translateY = 0;
13435
+ if (alignToGraphic) {
13436
+ const m = context.currentMatrix;
13437
+ translateX = (null !== (_e = null == m ? void 0 : m.e) && void 0 !== _e ? _e : 0) + x + alignOffsetX, translateY = (null !== (_f = null == m ? void 0 : m.f) && void 0 !== _f ? _f : 0) + y + alignOffsetY;
13438
+ } else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
13439
+ pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
13440
+ }
13441
+ context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
13442
+ } else if ("wave" === texture) {
13309
13443
  context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
13310
13444
  const b = graphic.AABBBounds;
13311
13445
  drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
@@ -13313,6 +13447,45 @@
13313
13447
  }), x + b.x1 - x, y + b.y1 - y), context.restore();
13314
13448
  }
13315
13449
  }
13450
+ getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr, textureRadius) {
13451
+ return "string" != typeof texture ? texturePadding > 0 || textureRadius > 0 ? null : texture : "wave" === texture ? null : builtinProceduralTextureTypes.has(texture) ? `builtin:${texture}|size:${textureSize}|padding:${texturePadding}|color:${textureColor}|dpr:${dpr}` : `resource:${texture}|padding:${texturePadding}|radius:${textureRadius}|dpr:${dpr}`;
13452
+ }
13453
+ createResourcePattern(texture, graphic, context, texturePadding, textureRadius) {
13454
+ var _a;
13455
+ const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
13456
+ data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
13457
+ if (!data) return null;
13458
+ if (texturePadding > 0 || textureRadius > 0) {
13459
+ const w = data.naturalWidth || data.width,
13460
+ h = data.naturalHeight || data.height;
13461
+ if (w > 0 && h > 0) {
13462
+ const tileW = w + 2 * texturePadding,
13463
+ tileH = h + 2 * texturePadding,
13464
+ canvas = canvasAllocate.allocate({
13465
+ width: tileW,
13466
+ height: tileH,
13467
+ dpr: context.dpr
13468
+ }),
13469
+ ctx = canvas.getContext("2d");
13470
+ if (ctx) {
13471
+ if (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, tileW, tileH), textureRadius > 0) {
13472
+ const r = Math.max(0, Math.min(textureRadius, Math.min(w, h) / 2)),
13473
+ x0 = texturePadding,
13474
+ y0 = texturePadding,
13475
+ x1 = x0 + w,
13476
+ y1 = y0 + h;
13477
+ ctx.beginPath(), ctx.moveTo(x0 + r, y0), ctx.lineTo(x1 - r, y0), ctx.quadraticCurveTo(x1, y0, x1, y0 + r), ctx.lineTo(x1, y1 - r), ctx.quadraticCurveTo(x1, y1, x1 - r, y1), ctx.lineTo(x0 + r, y1), ctx.quadraticCurveTo(x0, y1, x0, y1 - r), ctx.lineTo(x0, y0 + r), ctx.quadraticCurveTo(x0, y0, x0 + r, y0), ctx.closePath(), ctx.clip();
13478
+ }
13479
+ ctx.drawImage(data, texturePadding, texturePadding, w, h);
13480
+ const pattern = context.createPattern(canvas.nativeCanvas, "repeat");
13481
+ return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), canvasAllocate.free(canvas), pattern;
13482
+ }
13483
+ canvasAllocate.free(canvas);
13484
+ }
13485
+ }
13486
+ const pattern = context.createPattern(data, "repeat");
13487
+ return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
13488
+ }
13316
13489
  }
13317
13490
  const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();
13318
13491
 
@@ -13424,27 +13597,32 @@
13424
13597
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
13425
13598
  const {
13426
13599
  background: background,
13600
+ backgroundOpacity = graphicAttribute.backgroundOpacity,
13601
+ opacity = graphicAttribute.opacity,
13427
13602
  backgroundMode = graphicAttribute.backgroundMode,
13428
13603
  backgroundFit = graphicAttribute.backgroundFit,
13429
13604
  backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
13430
13605
  backgroundScale = graphicAttribute.backgroundScale,
13431
13606
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
13432
- backgroundOffsetY = graphicAttribute.backgroundOffsetY
13607
+ backgroundOffsetY = graphicAttribute.backgroundOffsetY,
13608
+ backgroundClip = graphicAttribute.backgroundClip,
13609
+ backgroundPosition = graphicAttribute.backgroundPosition
13433
13610
  } = graphic.attribute;
13434
13611
  if (background) if (graphic.backgroundImg && graphic.resources) {
13435
- const res = graphic.resources.get(background);
13436
- if ("success" !== res.state || !res.data) return;
13612
+ const res = graphic.resources.get(getBackgroundImage(background));
13613
+ if (!res || "success" !== res.state || !res.data) return;
13437
13614
  context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0);
13438
13615
  const b = graphic.AABBBounds;
13439
- this.doDrawImage(context, res.data, b, {
13616
+ context.globalAlpha = backgroundOpacity * opacity, backgroundClip && context.clip(), this.doDrawImage(context, res.data, b, {
13440
13617
  backgroundMode: backgroundMode,
13441
13618
  backgroundFit: backgroundFit,
13442
13619
  backgroundKeepAspectRatio: backgroundKeepAspectRatio,
13443
13620
  backgroundScale: backgroundScale,
13444
13621
  backgroundOffsetX: backgroundOffsetX,
13445
- backgroundOffsetY: backgroundOffsetY
13622
+ backgroundOffsetY: backgroundOffsetY,
13623
+ backgroundPosition: backgroundPosition
13446
13624
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
13447
- } else context.highPerformanceSave(), context.fillStyle = background, context.fill(), context.highPerformanceRestore();
13625
+ } else context.highPerformanceSave(), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
13448
13626
  }
13449
13627
  }
13450
13628
  const defaultGroupBackgroundRenderContribution = new DefaultGroupBackgroundRenderContribution();
@@ -14926,9 +15104,17 @@
14926
15104
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
14927
15105
  var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
14928
15106
  const {
15107
+ backgroundOpacity = graphicAttribute.backgroundOpacity,
15108
+ opacity = graphicAttribute.opacity,
14929
15109
  backgroundMode = graphicAttribute.backgroundMode,
14930
15110
  backgroundFit = graphicAttribute.backgroundFit,
14931
- backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio
15111
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
15112
+ backgroundScale = graphicAttribute.backgroundScale,
15113
+ backgroundOffsetX = graphicAttribute.backgroundOffsetX,
15114
+ backgroundOffsetY = graphicAttribute.backgroundOffsetY,
15115
+ backgroundPosition = graphicAttribute.backgroundPosition,
15116
+ backgroundClip = graphicAttribute.backgroundClip,
15117
+ backgroundCornerRadius = graphicAttribute.backgroundCornerRadius
14932
15118
  } = graphic.attribute;
14933
15119
  let matrix,
14934
15120
  {
@@ -14940,18 +15126,18 @@
14940
15126
  };
14941
15127
  let b;
14942
15128
  "richtext" === graphic.type && (matrix = context.currentMatrix.clone(), context.restore(), context.save(), context.setTransformForCurrent());
14943
- const shouldReCalBounds = isObject$7(background) && background.background,
15129
+ const backgroundConfig = isObject$7(background) && background.background ? background : null,
14944
15130
  onlyTranslate = graphic.transMatrix.onlyTranslate();
14945
- if (shouldReCalBounds) {
15131
+ if (backgroundConfig) {
14946
15132
  const _b = graphic.AABBBounds,
14947
- x = (null !== (_a = background.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = background.dx) && void 0 !== _c ? _c : 0),
14948
- y = (null !== (_d = background.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = background.dy) && void 0 !== _e ? _e : 0),
14949
- w = null !== (_f = background.width) && void 0 !== _f ? _f : _b.width(),
14950
- h = null !== (_g = background.height) && void 0 !== _g ? _g : _b.height();
14951
- if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = background.background, !onlyTranslate) {
15133
+ x = (null !== (_a = backgroundConfig.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = backgroundConfig.dx) && void 0 !== _c ? _c : 0),
15134
+ y = (null !== (_d = backgroundConfig.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = backgroundConfig.dy) && void 0 !== _e ? _e : 0),
15135
+ w = null !== (_f = backgroundConfig.width) && void 0 !== _f ? _f : _b.width(),
15136
+ h = null !== (_g = backgroundConfig.height) && void 0 !== _g ? _g : _b.height();
15137
+ if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = backgroundConfig.background, !onlyTranslate) {
14952
15138
  const w = b.width(),
14953
15139
  h = b.height();
14954
- b.set((null !== (_h = background.x) && void 0 !== _h ? _h : 0) + (null !== (_j = background.dx) && void 0 !== _j ? _j : 0), (null !== (_k = background.y) && void 0 !== _k ? _k : 0) + (null !== (_l = background.dy) && void 0 !== _l ? _l : 0), w, h);
15140
+ b.set((null !== (_h = backgroundConfig.x) && void 0 !== _h ? _h : 0) + (null !== (_j = backgroundConfig.dx) && void 0 !== _j ? _j : 0), (null !== (_k = backgroundConfig.y) && void 0 !== _k ? _k : 0) + (null !== (_l = backgroundConfig.dy) && void 0 !== _l ? _l : 0), w, h);
14955
15141
  }
14956
15142
  } else b = graphic.AABBBounds, onlyTranslate || (b = getTextBounds(Object.assign(Object.assign({}, graphic.attribute), {
14957
15143
  angle: 0,
@@ -14964,19 +15150,18 @@
14964
15150
  })).clone());
14965
15151
  if (graphic.backgroundImg && graphic.resources) {
14966
15152
  const res = graphic.resources.get(background);
14967
- if ("success" !== res.state || !res.data) return void restore();
14968
- context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, {
15153
+ if (!res || "success" !== res.state || !res.data) return void restore();
15154
+ context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.globalAlpha = backgroundOpacity * opacity, backgroundClip && (context.beginPath(), backgroundCornerRadius ? createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0) : context.rect(b.x1, b.y1, b.width(), b.height()), context.clip()), this.doDrawImage(context, res.data, b, {
14969
15155
  backgroundMode: backgroundMode,
14970
15156
  backgroundFit: backgroundFit,
14971
- backgroundKeepAspectRatio: backgroundKeepAspectRatio
15157
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15158
+ backgroundScale: backgroundScale,
15159
+ backgroundOffsetX: backgroundOffsetX,
15160
+ backgroundOffsetY: backgroundOffsetY,
15161
+ backgroundPosition: backgroundPosition
14972
15162
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
14973
- } else {
14974
- const {
14975
- backgroundCornerRadius: backgroundCornerRadius
14976
- } = graphic.attribute;
14977
- context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = background, backgroundCornerRadius ? (createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0), context.fill()) : context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
14978
- }
14979
- shouldReCalBounds && boundsAllocate.free(b), restore();
15163
+ } else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, backgroundCornerRadius ? (createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0), context.fill()) : context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
15164
+ backgroundConfig && boundsAllocate.free(b), restore();
14980
15165
  }
14981
15166
  }
14982
15167
  const defaultTextBackgroundRenderContribution = new DefaultTextBackgroundRenderContribution();
@@ -15403,6 +15588,92 @@
15403
15588
  };
15404
15589
  };
15405
15590
  const repeatStr = ["", "repeat-x", "repeat-y", "repeat"];
15591
+ function resolveImageMode({
15592
+ repeatX = "no-repeat",
15593
+ repeatY = "no-repeat",
15594
+ imageMode: imageMode
15595
+ }) {
15596
+ const repeatMode = resolveImageRepeatMode(repeatX, repeatY);
15597
+ return {
15598
+ repeatMode: repeatMode,
15599
+ sizingMode: "no-repeat" === repeatMode && null != imageMode ? imageMode : "fill"
15600
+ };
15601
+ }
15602
+ const IMAGE_MODE_TO_BACKGROUND_MODE = {
15603
+ cover: "no-repeat-cover",
15604
+ contain: "no-repeat-contain",
15605
+ fill: "no-repeat-fill",
15606
+ auto: "no-repeat-auto"
15607
+ };
15608
+ function resolveBackgroundParamsByImageSizing(sizingMode) {
15609
+ return {
15610
+ backgroundMode: IMAGE_MODE_TO_BACKGROUND_MODE[sizingMode],
15611
+ backgroundFit: !1,
15612
+ backgroundKeepAspectRatio: !1
15613
+ };
15614
+ }
15615
+ function resolveImageRepeatMode(repeatX, repeatY) {
15616
+ let repeat = 0;
15617
+ return "repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat ? repeatStr[repeat] : "no-repeat";
15618
+ }
15619
+ function shouldClipImageByLayout({
15620
+ repeatX = "no-repeat",
15621
+ repeatY = "no-repeat",
15622
+ imageMode: imageMode,
15623
+ imageScale = 1,
15624
+ imageOffsetX = 0,
15625
+ imageOffsetY = 0,
15626
+ imagePosition = "top-left"
15627
+ }) {
15628
+ const {
15629
+ repeatMode: repeatMode,
15630
+ sizingMode: sizingMode
15631
+ } = resolveImageMode({
15632
+ repeatX: repeatX,
15633
+ repeatY: repeatY,
15634
+ imageMode: imageMode
15635
+ });
15636
+ return "no-repeat" === repeatMode && ("cover" === sizingMode || "auto" === sizingMode || 1 !== imageScale || 0 !== imageOffsetX || 0 !== imageOffsetY);
15637
+ }
15638
+ function drawImageWithLayout(context, data, x, y, width, height, {
15639
+ repeatX = "no-repeat",
15640
+ repeatY = "no-repeat",
15641
+ imageMode: imageMode,
15642
+ imageScale = 1,
15643
+ imageOffsetX = 0,
15644
+ imageOffsetY = 0,
15645
+ imagePosition = "top-left"
15646
+ }) {
15647
+ const {
15648
+ repeatMode: repeatMode,
15649
+ sizingMode: sizingMode
15650
+ } = resolveImageMode({
15651
+ repeatX: repeatX,
15652
+ repeatY: repeatY,
15653
+ imageMode: imageMode
15654
+ }),
15655
+ imageBackgroundParams = "no-repeat" === repeatMode ? resolveBackgroundParamsByImageSizing(sizingMode) : {
15656
+ backgroundMode: repeatMode,
15657
+ backgroundFit: !1,
15658
+ backgroundKeepAspectRatio: !1
15659
+ };
15660
+ drawBackgroundImage(context, data, {
15661
+ x1: x,
15662
+ y1: y,
15663
+ x2: x + width,
15664
+ y2: y + height,
15665
+ width: () => width,
15666
+ height: () => height
15667
+ }, {
15668
+ backgroundMode: imageBackgroundParams.backgroundMode,
15669
+ backgroundFit: imageBackgroundParams.backgroundFit,
15670
+ backgroundKeepAspectRatio: imageBackgroundParams.backgroundKeepAspectRatio,
15671
+ backgroundScale: imageScale,
15672
+ backgroundOffsetX: imageOffsetX,
15673
+ backgroundOffsetY: imageOffsetY,
15674
+ backgroundPosition: imagePosition
15675
+ });
15676
+ }
15406
15677
  let DefaultCanvasImageRender = class extends BaseRender {
15407
15678
  constructor(graphicRenderContributions) {
15408
15679
  super(), this.graphicRenderContributions = graphicRenderContributions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution], this.init(graphicRenderContributions);
@@ -15417,6 +15688,11 @@
15417
15688
  cornerRadius = imageAttribute.cornerRadius,
15418
15689
  fillStrokeOrder = imageAttribute.fillStrokeOrder,
15419
15690
  cornerType = imageAttribute.cornerType,
15691
+ imageMode = imageAttribute.imageMode,
15692
+ imageScale = imageAttribute.imageScale,
15693
+ imageOffsetX = imageAttribute.imageOffsetX,
15694
+ imageOffsetY = imageAttribute.imageOffsetY,
15695
+ imagePosition = imageAttribute.imagePosition,
15420
15696
  image: url
15421
15697
  } = image.attribute,
15422
15698
  data = this.valid(image, imageAttribute, fillCb);
@@ -15433,22 +15709,33 @@
15433
15709
  const width = image.width,
15434
15710
  height = image.height;
15435
15711
  context.beginPath();
15436
- let needRestore = !1;
15437
- 0 === cornerRadius || isArray$5(cornerRadius) && cornerRadius.every(num => 0 === num) ? context.rect(x, y, width, height) : (createRectPath(context, x, y, width, height, cornerRadius, "bevel" !== cornerType), needRestore = !0), context.setShadowBlendStyle && context.setShadowBlendStyle(image, image.attribute, imageAttribute);
15712
+ let needCornerClip = !1;
15713
+ 0 === cornerRadius || isArray$5(cornerRadius) && cornerRadius.every(num => 0 === num) ? context.rect(x, y, width, height) : (createRectPath(context, x, y, width, height, cornerRadius, "bevel" !== cornerType), needCornerClip = !0), context.setShadowBlendStyle && context.setShadowBlendStyle(image, image.attribute, imageAttribute);
15438
15714
  const _runFill = () => {
15439
- if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
15440
- context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
15441
- let repeat = 0;
15442
- if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
15443
- const pattern = context.createPattern(res.data, repeatStr[repeat]);
15444
- context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
15445
- } else context.drawImage(res.data, x, y, width, height);
15446
- }
15715
+ doFill && (fillCb ? fillCb(context, image.attribute, imageAttribute) : fVisible && (context.setCommonStyle(image, image.attribute, x, y, imageAttribute), drawImageWithLayout(context, res.data, x, y, width, height, {
15716
+ repeatX: repeatX,
15717
+ repeatY: repeatY,
15718
+ imageMode: imageMode,
15719
+ imageScale: imageScale,
15720
+ imageOffsetX: imageOffsetX,
15721
+ imageOffsetY: imageOffsetY,
15722
+ imagePosition: imagePosition
15723
+ })));
15447
15724
  },
15448
15725
  _runStroke = () => {
15449
15726
  doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
15450
- };
15451
- fillStrokeOrder ? (_runStroke(), needRestore && (context.save(), context.clip()), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), _runFill(), needRestore && context.restore()) : (needRestore && (context.save(), context.clip()), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), _runFill(), needRestore && context.restore(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
15727
+ },
15728
+ needLayoutClip = shouldClipImageByLayout({
15729
+ repeatX: repeatX,
15730
+ repeatY: repeatY,
15731
+ imageMode: imageMode,
15732
+ imageScale: imageScale,
15733
+ imageOffsetX: imageOffsetX,
15734
+ imageOffsetY: imageOffsetY,
15735
+ imagePosition: imagePosition
15736
+ }),
15737
+ needClip = needCornerClip || needLayoutClip;
15738
+ fillStrokeOrder ? (_runStroke(), needClip && (context.save(), context.clip()), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), _runFill(), needClip && context.restore()) : (needClip && (context.save(), context.clip()), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), _runFill(), needClip && context.restore(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
15452
15739
  }
15453
15740
  draw(image, renderService, drawContext) {
15454
15741
  const {
@@ -16302,7 +16589,7 @@
16302
16589
  return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);
16303
16590
  }
16304
16591
  clearScreen(renderService, context, drawContext) {
16305
- var _a, _b, _c;
16592
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
16306
16593
  const {
16307
16594
  clear: clear,
16308
16595
  viewBox: viewBox
@@ -16312,9 +16599,20 @@
16312
16599
  if (clear) {
16313
16600
  context.clearRect(0, 0, width, height), (null === (_a = renderService.drawParams) || void 0 === _a ? void 0 : _a.stage) && renderService.drawParams.stage.hooks.afterClearRect.call(renderService.drawParams);
16314
16601
  const stage = null === (_b = renderService.drawParams) || void 0 === _b ? void 0 : _b.stage;
16315
- if (stage && (context.globalAlpha = null !== (_c = stage.attribute.opacity) && void 0 !== _c ? _c : 1), stage && stage.backgroundImg && stage.resources) {
16316
- const res = stage.resources.get(clear);
16317
- res && "success" === res.state && res.data && context.drawImage(res.data, 0, 0, width, height);
16602
+ if (stage && (context.globalAlpha = (null !== (_c = stage.attribute.opacity) && void 0 !== _c ? _c : 1) * (null !== (_d = stage.attribute.backgroundOpacity) && void 0 !== _d ? _d : 1)), stage && stage.backgroundImg && stage.resources) {
16603
+ const res = stage.resources.get(getBackgroundImage(clear));
16604
+ if (res && "success" === res.state && res.data) {
16605
+ const backgroundBounds = boundsAllocate.allocate(0, 0, 0 + width, 0 + height);
16606
+ drawBackgroundImage(context, res.data, backgroundBounds, {
16607
+ backgroundMode: null !== (_e = stage.attribute.backgroundMode) && void 0 !== _e ? _e : DefaultAttribute.backgroundMode,
16608
+ backgroundFit: null !== (_f = stage.attribute.backgroundFit) && void 0 !== _f ? _f : DefaultAttribute.backgroundFit,
16609
+ backgroundKeepAspectRatio: null !== (_g = stage.attribute.backgroundKeepAspectRatio) && void 0 !== _g ? _g : DefaultAttribute.backgroundKeepAspectRatio,
16610
+ backgroundScale: null !== (_h = stage.attribute.backgroundScale) && void 0 !== _h ? _h : DefaultAttribute.backgroundScale,
16611
+ backgroundOffsetX: null !== (_j = stage.attribute.backgroundOffsetX) && void 0 !== _j ? _j : DefaultAttribute.backgroundOffsetX,
16612
+ backgroundOffsetY: null !== (_k = stage.attribute.backgroundOffsetY) && void 0 !== _k ? _k : DefaultAttribute.backgroundOffsetY,
16613
+ backgroundPosition: null !== (_l = stage.attribute.backgroundPosition) && void 0 !== _l ? _l : DefaultAttribute.backgroundPosition
16614
+ }), boundsAllocate.free(backgroundBounds);
16615
+ }
16318
16616
  } else context.fillStyle = createColor(context, clear, {
16319
16617
  AABBBounds: {
16320
16618
  x1: 0,
@@ -16817,7 +17115,7 @@
16817
17115
  return null !== (_a = this._background) && void 0 !== _a ? _a : DefaultConfig.BACKGROUND;
16818
17116
  }
16819
17117
  set background(b) {
16820
- this._background = b;
17118
+ this._background = b, this.syncBackgroundImage(b);
16821
17119
  }
16822
17120
  get defaultLayer() {
16823
17121
  return this.at(0);
@@ -16831,6 +17129,18 @@
16831
17129
  set ticker(ticker) {
16832
17130
  ticker.bindStage(this), this._ticker && this._ticker.removeListener("tick", this.afterTickCb), ticker.addTimeline(this.timeline), this._ticker = ticker, this._ticker.on("tick", this.afterTickCb);
16833
17131
  }
17132
+ syncBackgroundImage(background) {
17133
+ var _a;
17134
+ const source = null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
17135
+ this.backgroundImg = !1, this.isImageBackgroundSource(source) && this.loadImage(source, !0);
17136
+ }
17137
+ isImageBackgroundSource(source) {
17138
+ if (!source) return !1;
17139
+ if ("string" == typeof source) return source.startsWith("<svg") || isValidUrl$1(source) || source.includes("/") || isBase64$1(source);
17140
+ if (!isObject$7(source)) return !1;
17141
+ const gradientSource = source;
17142
+ return "string" != typeof gradientSource.gradient || !Array.isArray(gradientSource.stops);
17143
+ }
16834
17144
  constructor(params = {}) {
16835
17145
  var _a, _b;
16836
17146
  super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
@@ -16869,9 +17179,7 @@
16869
17179
  main: !0
16870
17180
  })), 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 = {
16871
17181
  tickRenderMode: "effect"
16872
- }), this.optmize(params.optimize), params.background && isString$2(this._background) && this._background.includes("/") && this.setAttributes({
16873
- background: this._background
16874
- }), this.initAnimate(params), this.rafId = null !== (_b = params.rafId) && void 0 !== _b ? _b : Math.floor(6 * Math.random());
17182
+ }), this.optmize(params.optimize), params.background && this.syncBackgroundImage(this._background), this.initAnimate(params), this.rafId = null !== (_b = params.rafId) && void 0 !== _b ? _b : Math.floor(6 * Math.random());
16875
17183
  }
16876
17184
  initAnimate(params) {
16877
17185
  var _a;
@@ -24261,6 +24569,7 @@
24261
24569
  if (custom.prototype.constructor === custom) {
24262
24570
  const descriptor = Object.getOwnPropertyDescriptor(custom, "prototype");
24263
24571
  if (descriptor && !descriptor.writable) return 1;
24572
+ if (Object.getOwnPropertyNames(custom.prototype).length > 1) return 1;
24264
24573
  }
24265
24574
  return 2;
24266
24575
  }
@@ -32420,7 +32729,31 @@
32420
32729
  return graphicCreator.symbol(style);
32421
32730
  }
32422
32731
  _renderHandlerText(value, position) {
32423
- var _a, _b, _c;
32732
+ return graphicCreator.text(this._getHandlerTextAttributes(value, position));
32733
+ }
32734
+ _getHandlerPosition(isStart) {
32735
+ return this.attribute.range && isStart ? "start" : "end";
32736
+ }
32737
+ _getHandlerTextStyle(value, position) {
32738
+ const {
32739
+ align: align,
32740
+ handlerSize = 14,
32741
+ handlerText = {},
32742
+ railHeight: railHeight,
32743
+ railWidth: railWidth,
32744
+ slidable: slidable
32745
+ } = this.attribute;
32746
+ return isFunction$3(handlerText.style) ? handlerText.style(value, position, {
32747
+ layout: this.attribute.layout,
32748
+ align: align,
32749
+ railWidth: railWidth,
32750
+ railHeight: railHeight,
32751
+ handlerSize: handlerSize,
32752
+ slidable: slidable
32753
+ }) : handlerText.style;
32754
+ }
32755
+ _getHandlerTextAttributes(value, position) {
32756
+ var _a, _b;
32424
32757
  const {
32425
32758
  align: align,
32426
32759
  handlerSize = 14,
@@ -32432,13 +32765,13 @@
32432
32765
  isHorizontal = this._isHorizontal,
32433
32766
  pos = this.calculatePosByValue(value, position),
32434
32767
  textSpace = null !== (_a = handlerText.space) && void 0 !== _a ? _a : 4,
32768
+ handlerTextStyle = this._getHandlerTextStyle(value, position),
32435
32769
  textStyle = {
32436
32770
  text: handlerText.formatter ? handlerText.formatter(value) : value.toFixed(null !== (_b = handlerText.precision) && void 0 !== _b ? _b : 0),
32437
- lineHeight: null === (_c = handlerText.style) || void 0 === _c ? void 0 : _c.lineHeight,
32771
+ lineHeight: null == handlerTextStyle ? void 0 : handlerTextStyle.lineHeight,
32438
32772
  cursor: !1 === slidable ? "default" : getDefaultCursor(isHorizontal)
32439
32773
  };
32440
- isHorizontal ? "top" === align ? (textStyle.textBaseline = "bottom", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight - handlerSize) / 2 - textSpace) : (textStyle.textBaseline = "top", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight + handlerSize) / 2 + textSpace) : "left" === align ? (textStyle.textBaseline = "middle", textStyle.textAlign = "end", textStyle.x = (railWidth - handlerSize) / 2 - textSpace, textStyle.y = pos) : (textStyle.textBaseline = "middle", textStyle.textAlign = "start", textStyle.x = (railWidth + handlerSize) / 2 + textSpace, textStyle.y = pos);
32441
- return graphicCreator.text(Object.assign(Object.assign({}, textStyle), handlerText.style));
32774
+ return isHorizontal ? "top" === align ? (textStyle.textBaseline = "bottom", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight - handlerSize) / 2 - textSpace) : (textStyle.textBaseline = "top", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight + handlerSize) / 2 + textSpace) : "left" === align ? (textStyle.textBaseline = "middle", textStyle.textAlign = "end", textStyle.x = (railWidth - handlerSize) / 2 - textSpace, textStyle.y = pos) : (textStyle.textBaseline = "middle", textStyle.textAlign = "start", textStyle.x = (railWidth + handlerSize) / 2 + textSpace, textStyle.y = pos), Object.assign(Object.assign({}, textStyle), handlerTextStyle);
32442
32775
  }
32443
32776
  _renderTooltip() {
32444
32777
  var _a;
@@ -32566,31 +32899,19 @@
32566
32899
  }
32567
32900
  }
32568
32901
  _updateHandler(handler, position, value) {
32569
- var _a;
32570
32902
  const isHorizontal = this._isHorizontal;
32571
32903
  handler.setAttribute(isHorizontal ? "x" : "y", position);
32572
32904
  const updateHandlerText = handler.name === SLIDER_ELEMENT_NAME.startHandler ? this._startHandlerText : this._endHandlerText;
32573
32905
  if (updateHandlerText) {
32574
- const {
32575
- handlerText = {}
32576
- } = this.attribute;
32577
- updateHandlerText.setAttributes({
32578
- text: handlerText.formatter ? handlerText.formatter(value) : value.toFixed(null !== (_a = handlerText.precision) && void 0 !== _a ? _a : 0),
32579
- [isHorizontal ? "x" : "y"]: position
32580
- });
32906
+ const handlerPosition = this._getHandlerPosition(handler.name === SLIDER_ELEMENT_NAME.startHandler);
32907
+ updateHandlerText.setAttributes(this._getHandlerTextAttributes(value, handlerPosition));
32581
32908
  }
32582
32909
  handler.name === SLIDER_ELEMENT_NAME.startHandler ? (this._currentValue.startValue = value, this._currentValue.startPos = position) : (this._currentValue.endValue = value, this._currentValue.endPos = position);
32583
32910
  }
32584
32911
  _updateHandlerText(handlerText, position, value) {
32585
- var _a;
32586
32912
  const isHorizontal = this._isHorizontal,
32587
- {
32588
- handlerText: handlerTextAttr = {}
32589
- } = this.attribute;
32590
- handlerText.setAttributes({
32591
- [isHorizontal ? "x" : "y"]: position,
32592
- text: handlerTextAttr.formatter ? handlerTextAttr.formatter(value) : value.toFixed(null !== (_a = handlerTextAttr.precision) && void 0 !== _a ? _a : 0)
32593
- });
32913
+ handlerPosition = this._getHandlerPosition(handlerText.name === SLIDER_ELEMENT_NAME.startHandlerText);
32914
+ handlerText.setAttributes(this._getHandlerTextAttributes(value, handlerPosition));
32594
32915
  const updateHandler = handlerText.name === SLIDER_ELEMENT_NAME.startHandlerText ? this._startHandler : this._endHandler;
32595
32916
  updateHandler && updateHandler.setAttributes({
32596
32917
  [isHorizontal ? "x" : "y"]: position
@@ -56409,7 +56730,7 @@
56409
56730
  }
56410
56731
  constructor(container, options = {}) {
56411
56732
  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;
56412
- if (super(), this.showFrozenIcon = !0, this.version = "1.22.13-alpha.10", 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");
56733
+ if (super(), this.showFrozenIcon = !0, this.version = "1.22.13-alpha.11", 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");
56413
56734
  this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
56414
56735
  options: options,
56415
56736
  container: container