@visactor/vchart 2.0.22-alpha.0 → 2.0.22-alpha.2

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/build/index.js CHANGED
@@ -11436,7 +11436,9 @@
11436
11436
  background: null,
11437
11437
  autoAnimateTexture: !1,
11438
11438
  textureRatio: 1,
11439
- textureOptions: null,
11439
+ textureOptions: {
11440
+ alignToGraphic: !0
11441
+ },
11440
11442
  backgroundOpacity: 1,
11441
11443
  backgroundCornerRadius: 0,
11442
11444
  texture: null,
@@ -11450,6 +11452,7 @@
11450
11452
  backgroundScale: 1,
11451
11453
  backgroundOffsetX: 0,
11452
11454
  backgroundOffsetY: 0,
11455
+ backgroundPosition: "top-left",
11453
11456
  blur: 0,
11454
11457
  filter: "",
11455
11458
  cursor: null,
@@ -11622,11 +11625,16 @@
11622
11625
  const DefaultImageAttribute = Object.assign(Object.assign({
11623
11626
  repeatX: "no-repeat",
11624
11627
  repeatY: "no-repeat",
11628
+ imageMode: void 0,
11625
11629
  image: "",
11626
11630
  width: 0,
11627
11631
  height: 0,
11628
11632
  maxWidth: 500,
11629
- maxHeight: 500
11633
+ maxHeight: 500,
11634
+ imagePosition: "top-left",
11635
+ imageScale: 1,
11636
+ imageOffsetX: 0,
11637
+ imageOffsetY: 0
11630
11638
  }, DefaultAttribute), {
11631
11639
  fill: !0,
11632
11640
  cornerRadius: 0,
@@ -16678,7 +16686,8 @@
16678
16686
  return isString$1(path, !0) ? this.pathProxy = new CustomPath2D().fromString(path) : this.pathProxy = new CustomPath2D(), this.pathProxy;
16679
16687
  }
16680
16688
  loadImage(image, background = !1) {
16681
- if (!image || background && backgroundNotImage(image)) return;
16689
+ if (background && (null == image ? void 0 : image.background) && (image = image.background), background && (!image || backgroundNotImage(image))) return void (this.backgroundImg = !1);
16690
+ if (!image) return;
16682
16691
  const url = image;
16683
16692
  this.resources || (this.resources = new Map());
16684
16693
  const cache = {
@@ -16733,7 +16742,7 @@
16733
16742
  }
16734
16743
  }
16735
16744
  function backgroundNotImage(image) {
16736
- return !(!image.fill && !image.stroke);
16745
+ 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));
16737
16746
  }
16738
16747
  function isExternalTexture(texture) {
16739
16748
  return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$2(texture));
@@ -18869,7 +18878,7 @@
18869
18878
  return [new Paragraph(text1, paragraph.newLine, paragraph.character, paragraph.ascentDescentMode), new Paragraph(text2, !0, paragraph.character, paragraph.ascentDescentMode)];
18870
18879
  }
18871
18880
 
18872
- const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", ...GRAPHIC_UPDATE_TAG_KEY];
18881
+ const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", "imageMode", "imagePosition", "imageScale", "imageOffsetX", "imageOffsetY", ...GRAPHIC_UPDATE_TAG_KEY];
18873
18882
  class Image extends Graphic {
18874
18883
  constructor(params) {
18875
18884
  super(params), this.type = "image", this.numberType = IMAGE_NUMBER_TYPE, this.loadImage(this.attribute.image);
@@ -18974,6 +18983,7 @@
18974
18983
  }
18975
18984
  Image.NOWORK_ANIMATE_ATTR = Object.assign({
18976
18985
  image: 1,
18986
+ imageMode: 1,
18977
18987
  repeatX: 1,
18978
18988
  repeatY: 1
18979
18989
  }, NOWORK_ANIMATE_ATTR);
@@ -20167,11 +20177,12 @@
20167
20177
  backgroundScale = graphicAttribute.backgroundScale,
20168
20178
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
20169
20179
  backgroundOffsetY = graphicAttribute.backgroundOffsetY,
20170
- backgroundClip = graphicAttribute.backgroundClip
20180
+ backgroundClip = graphicAttribute.backgroundClip,
20181
+ backgroundPosition = graphicAttribute.backgroundPosition
20171
20182
  } = graphic.attribute;
20172
20183
  if (background) if (graphic.backgroundImg && graphic.resources) {
20173
- const res = graphic.resources.get(background);
20174
- if ("success" !== res.state || !res.data) return;
20184
+ const res = graphic.resources.get(getBackgroundImage(background));
20185
+ if (!res || "success" !== res.state || !res.data) return;
20175
20186
  if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
20176
20187
  const groupAttribute = getTheme$1(graphic.parent).group,
20177
20188
  {
@@ -20188,59 +20199,160 @@
20188
20199
  backgroundKeepAspectRatio: backgroundKeepAspectRatio,
20189
20200
  backgroundScale: backgroundScale,
20190
20201
  backgroundOffsetX: backgroundOffsetX,
20191
- backgroundOffsetY: backgroundOffsetY
20202
+ backgroundOffsetY: backgroundOffsetY,
20203
+ backgroundPosition: backgroundPosition
20192
20204
  }), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
20193
20205
  } else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
20194
20206
  }
20195
20207
  doDrawImage(context, data, b, params) {
20196
- const {
20197
- backgroundMode: backgroundMode,
20198
- backgroundFit: backgroundFit,
20199
- backgroundKeepAspectRatio: backgroundKeepAspectRatio,
20200
- backgroundScale = 1,
20201
- backgroundOffsetX = 0,
20202
- backgroundOffsetY = 0
20203
- } = params,
20204
- targetW = b.width(),
20205
- targetH = b.height();
20206
- let w = targetW,
20207
- h = targetH;
20208
- if ("no-repeat" === backgroundMode) {
20209
- if (backgroundFit) {
20210
- if (backgroundKeepAspectRatio) {
20211
- const maxScale = Math.max(targetW / data.width, targetH / data.height);
20212
- context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
20213
- } else context.drawImage(data, b.x1, b.y1, b.width(), b.height());
20214
- } else {
20215
- const resW = data.width * backgroundScale,
20216
- resH = data.height * backgroundScale;
20217
- context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
20218
- }
20219
- } else {
20220
- if (backgroundFit && "repeat" !== backgroundMode && (data.width || data.height)) {
20221
- const resW = data.width,
20222
- resH = data.height;
20223
- if ("repeat-x" === backgroundMode) {
20224
- w = resW * (targetH / resH), h = targetH;
20225
- } else if ("repeat-y" === backgroundMode) {
20226
- h = resH * (targetW / resW), w = targetW;
20227
- }
20228
- const dpr = context.dpr,
20229
- canvas = canvasAllocate.allocate({
20230
- width: w,
20231
- height: h,
20232
- dpr: dpr
20233
- }),
20234
- ctx = canvas.getContext("2d");
20235
- 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);
20236
- }
20237
- const dpr = context.dpr,
20238
- pattern = context.createPattern(data, backgroundMode);
20239
- 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);
20240
- }
20208
+ drawBackgroundImage(context, data, b, params);
20241
20209
  }
20242
20210
  }
20243
20211
  const defaultBaseBackgroundRenderContribution = new DefaultBaseBackgroundRenderContribution();
20212
+ const verticalPositionKeywords = new Set(["top", "center", "bottom"]);
20213
+ function getBackgroundImage(background) {
20214
+ var _a;
20215
+ return null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
20216
+ }
20217
+ function resolveBackgroundSizing({
20218
+ backgroundFit: backgroundFit,
20219
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
20220
+ }) {
20221
+ return backgroundFit ? backgroundKeepAspectRatio ? "cover" : "fill" : "auto";
20222
+ }
20223
+ const NO_REPEAT_SIZING_MAP = {
20224
+ "no-repeat-cover": "cover",
20225
+ "no-repeat-contain": "contain",
20226
+ "no-repeat-fill": "fill",
20227
+ "no-repeat-auto": "auto"
20228
+ };
20229
+ function resolveBackgroundDrawMode({
20230
+ backgroundMode: backgroundMode,
20231
+ backgroundFit: backgroundFit,
20232
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
20233
+ }) {
20234
+ const sizing = NO_REPEAT_SIZING_MAP[backgroundMode];
20235
+ return sizing ? {
20236
+ backgroundRepeatMode: "no-repeat",
20237
+ backgroundSizing: sizing
20238
+ } : {
20239
+ backgroundRepeatMode: backgroundMode,
20240
+ backgroundSizing: resolveBackgroundSizing({
20241
+ backgroundFit: backgroundFit,
20242
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
20243
+ })
20244
+ };
20245
+ }
20246
+ function isPercentageValue(value) {
20247
+ return /^-?\d+(\.\d+)?%$/.test(value);
20248
+ }
20249
+ function parsePositionToken(value, remainSpace, startKeyword, centerKeyword, endKeyword) {
20250
+ if ("number" == typeof value && Number.isFinite(value)) return value;
20251
+ const normalizedValue = `${null != value ? value : ""}`.trim().toLowerCase();
20252
+ if (!normalizedValue || normalizedValue === startKeyword) return 0;
20253
+ if (normalizedValue === centerKeyword) return remainSpace / 2;
20254
+ if (normalizedValue === endKeyword) return remainSpace;
20255
+ if (isPercentageValue(normalizedValue)) return remainSpace * parseFloat(normalizedValue) / 100;
20256
+ const parsedValue = Number(normalizedValue);
20257
+ return Number.isFinite(parsedValue) ? parsedValue : 0;
20258
+ }
20259
+ function normalizeBackgroundPosition(position) {
20260
+ var _a, _b;
20261
+ if (Array.isArray(position)) return [null !== (_a = position[0]) && void 0 !== _a ? _a : "left", null !== (_b = position[1]) && void 0 !== _b ? _b : "top"];
20262
+ const tokens = `${null != position ? position : "top-left"}`.trim().toLowerCase().replace(/-/g, " ").split(/\s+/).filter(Boolean);
20263
+ if (0 === tokens.length) return ["left", "top"];
20264
+ if (1 === tokens.length) {
20265
+ const token = tokens[0];
20266
+ return "center" === token ? ["center", "center"] : verticalPositionKeywords.has(token) ? ["center", token] : [token, "center"];
20267
+ }
20268
+ let horizontal, vertical;
20269
+ const genericTokens = [];
20270
+ for (let i = 0; i < 2; i++) {
20271
+ const token = tokens[i];
20272
+ "left" !== token && "right" !== token ? "top" !== token && "bottom" !== token ? genericTokens.push(token) : vertical = token : horizontal = token;
20273
+ }
20274
+ return null == horizontal && genericTokens.length && (horizontal = genericTokens.shift()), null == vertical && genericTokens.length && (vertical = genericTokens.shift()), [null != horizontal ? horizontal : "left", null != vertical ? vertical : "top"];
20275
+ }
20276
+ function resolveBackgroundPosition(position, remainWidth, remainHeight) {
20277
+ const [horizontalPosition, verticalPosition] = normalizeBackgroundPosition(position);
20278
+ return {
20279
+ x: parsePositionToken(horizontalPosition, remainWidth, "left", "center", "right"),
20280
+ y: parsePositionToken(verticalPosition, remainHeight, "top", "center", "bottom")
20281
+ };
20282
+ }
20283
+ function pickRenderableDimension(...values) {
20284
+ for (const value of values) if ("number" == typeof value && Number.isFinite(value) && value > 0) return value;
20285
+ return null;
20286
+ }
20287
+ function resolveRenderableImageSize(data) {
20288
+ if (!data) return null;
20289
+ const width = pickRenderableDimension(data.naturalWidth, data.videoWidth, data.width),
20290
+ height = pickRenderableDimension(data.naturalHeight, data.videoHeight, data.height);
20291
+ return null == width || null == height ? null : {
20292
+ width: width,
20293
+ height: height
20294
+ };
20295
+ }
20296
+ function drawBackgroundImage(context, data, b, params) {
20297
+ var _a, _b;
20298
+ const {
20299
+ backgroundMode: backgroundMode,
20300
+ backgroundFit: backgroundFit,
20301
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
20302
+ backgroundScale = 1,
20303
+ backgroundOffsetX = 0,
20304
+ backgroundOffsetY = 0,
20305
+ backgroundPosition = "top-left"
20306
+ } = params,
20307
+ targetW = b.width(),
20308
+ targetH = b.height(),
20309
+ sourceSize = resolveRenderableImageSize(data),
20310
+ {
20311
+ backgroundRepeatMode: backgroundRepeatMode,
20312
+ backgroundSizing: resolvedBackgroundSizing
20313
+ } = resolveBackgroundDrawMode({
20314
+ backgroundMode: backgroundMode,
20315
+ backgroundFit: backgroundFit,
20316
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
20317
+ });
20318
+ let w = targetW,
20319
+ h = targetH;
20320
+ if (targetW <= 0 || targetH <= 0) return;
20321
+ if ("no-repeat" === backgroundRepeatMode) {
20322
+ let drawWidth = null !== (_a = null == sourceSize ? void 0 : sourceSize.width) && void 0 !== _a ? _a : targetW,
20323
+ drawHeight = null !== (_b = null == sourceSize ? void 0 : sourceSize.height) && void 0 !== _b ? _b : targetH;
20324
+ if ("cover" !== resolvedBackgroundSizing && "contain" !== resolvedBackgroundSizing || !sourceSize) "fill" === resolvedBackgroundSizing && (drawWidth = targetW, drawHeight = targetH);else {
20325
+ const scale = "cover" === resolvedBackgroundSizing ? Math.max(targetW / sourceSize.width, targetH / sourceSize.height) : Math.min(targetW / sourceSize.width, targetH / sourceSize.height);
20326
+ drawWidth = sourceSize.width * scale, drawHeight = sourceSize.height * scale;
20327
+ }
20328
+ drawWidth *= backgroundScale, drawHeight *= backgroundScale;
20329
+ const {
20330
+ x: x,
20331
+ y: y
20332
+ } = resolveBackgroundPosition(backgroundPosition, targetW - drawWidth, targetH - drawHeight);
20333
+ return void context.drawImage(data, b.x1 + x + backgroundOffsetX, b.y1 + y + backgroundOffsetY, drawWidth, drawHeight);
20334
+ }
20335
+ if (backgroundFit && "repeat" !== backgroundRepeatMode && sourceSize) {
20336
+ const resW = sourceSize.width,
20337
+ resH = sourceSize.height;
20338
+ if ("repeat-x" === backgroundRepeatMode) {
20339
+ w = resW * (targetH / resH), h = targetH;
20340
+ } else if ("repeat-y" === backgroundRepeatMode) {
20341
+ h = resH * (targetW / resW), w = targetW;
20342
+ }
20343
+ const dpr = context.dpr,
20344
+ canvas = canvasAllocate.allocate({
20345
+ width: w,
20346
+ height: h,
20347
+ dpr: dpr
20348
+ }),
20349
+ ctx = canvas.getContext("2d");
20350
+ 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);
20351
+ }
20352
+ const dpr = context.dpr,
20353
+ pattern = context.createPattern(data, backgroundRepeatMode);
20354
+ 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);
20355
+ }
20244
20356
  let DefaultBaseInteractiveRenderContribution = class {
20245
20357
  constructor(subRenderContribitions) {
20246
20358
  this.subRenderContribitions = subRenderContribitions, this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
@@ -20399,13 +20511,14 @@
20399
20511
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
20400
20512
  }
20401
20513
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
20402
- var _a;
20514
+ var _a, _b, _c, _d, _e, _f;
20403
20515
  const {
20404
20516
  textureRatio = graphicAttribute.textureRatio,
20405
20517
  textureOptions = null
20406
20518
  } = graphic.attribute;
20407
20519
  let pattern = null;
20408
- const patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr);
20520
+ const textureRadius = null !== (_a = null == textureOptions ? void 0 : textureOptions.radius) && void 0 !== _a ? _a : 0,
20521
+ patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr, textureRadius);
20409
20522
  if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
20410
20523
  if ("string" == typeof texture) switch (texture) {
20411
20524
  case "circle":
@@ -20432,7 +20545,7 @@
20432
20545
  case "grid":
20433
20546
  pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
20434
20547
  }
20435
- pattern || (pattern = this.createResourcePattern(texture, graphic, context)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
20548
+ pattern || (pattern = this.createResourcePattern(texture, graphic, context, texturePadding, textureRadius)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
20436
20549
  }
20437
20550
  if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
20438
20551
  const {
@@ -20479,10 +20592,24 @@
20479
20592
  for (let i = 0; i < gridRows; i++) for (let j = 0; j < gridColumns; j++) {
20480
20593
  const _x = x + cellSize / 2 + j * cellSize,
20481
20594
  _y = y + cellSize / 2 + i * cellSize;
20482
- 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());
20595
+ 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());
20483
20596
  }
20484
20597
  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();
20485
- } else if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
20598
+ } else if (pattern) {
20599
+ if (pattern.setTransform) {
20600
+ const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
20601
+ alignOffsetX = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _c ? _c : 0,
20602
+ alignOffsetY = null !== (_d = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _d ? _d : 0;
20603
+ let translateX = 0,
20604
+ translateY = 0;
20605
+ if (alignToGraphic) {
20606
+ const m = context.currentMatrix;
20607
+ 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;
20608
+ } else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
20609
+ pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
20610
+ }
20611
+ context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
20612
+ } else if ("wave" === texture) {
20486
20613
  context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
20487
20614
  const b = graphic.AABBBounds;
20488
20615
  drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
@@ -20490,14 +20617,42 @@
20490
20617
  }), x + b.x1 - x, y + b.y1 - y), context.restore();
20491
20618
  }
20492
20619
  }
20493
- getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr) {
20494
- return "string" != typeof texture ? texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
20620
+ getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr, textureRadius) {
20621
+ return "string" != typeof texture ? texturePadding > 0 || textureRadius > 0 ? null : texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
20495
20622
  }
20496
- createResourcePattern(texture, graphic, context) {
20623
+ createResourcePattern(texture, graphic, context, texturePadding, textureRadius) {
20497
20624
  var _a;
20498
20625
  const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
20499
20626
  data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
20500
20627
  if (!data) return null;
20628
+ if (texturePadding > 0 || textureRadius > 0) {
20629
+ const w = data.naturalWidth || data.width,
20630
+ h = data.naturalHeight || data.height;
20631
+ if (w > 0 && h > 0) {
20632
+ const tileW = w + 2 * texturePadding,
20633
+ tileH = h + 2 * texturePadding,
20634
+ canvas = canvasAllocate.allocate({
20635
+ width: tileW,
20636
+ height: tileH,
20637
+ dpr: context.dpr
20638
+ }),
20639
+ ctx = canvas.getContext("2d");
20640
+ if (ctx) {
20641
+ if (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, tileW, tileH), textureRadius > 0) {
20642
+ const r = Math.max(0, Math.min(textureRadius, Math.min(w, h) / 2)),
20643
+ x0 = texturePadding,
20644
+ y0 = texturePadding,
20645
+ x1 = x0 + w,
20646
+ y1 = y0 + h;
20647
+ 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();
20648
+ }
20649
+ ctx.drawImage(data, texturePadding, texturePadding, w, h);
20650
+ const pattern = context.createPattern(canvas.nativeCanvas, "repeat");
20651
+ 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;
20652
+ }
20653
+ canvasAllocate.free(canvas);
20654
+ }
20655
+ }
20501
20656
  const pattern = context.createPattern(data, "repeat");
20502
20657
  return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
20503
20658
  }
@@ -20612,27 +20767,32 @@
20612
20767
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
20613
20768
  const {
20614
20769
  background: background,
20770
+ backgroundOpacity = graphicAttribute.backgroundOpacity,
20771
+ opacity = graphicAttribute.opacity,
20615
20772
  backgroundMode = graphicAttribute.backgroundMode,
20616
20773
  backgroundFit = graphicAttribute.backgroundFit,
20617
20774
  backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
20618
20775
  backgroundScale = graphicAttribute.backgroundScale,
20619
20776
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
20620
- backgroundOffsetY = graphicAttribute.backgroundOffsetY
20777
+ backgroundOffsetY = graphicAttribute.backgroundOffsetY,
20778
+ backgroundClip = graphicAttribute.backgroundClip,
20779
+ backgroundPosition = graphicAttribute.backgroundPosition
20621
20780
  } = graphic.attribute;
20622
20781
  if (background) if (graphic.backgroundImg && graphic.resources) {
20623
- const res = graphic.resources.get(background);
20624
- if ("success" !== res.state || !res.data) return;
20782
+ const res = graphic.resources.get(getBackgroundImage(background));
20783
+ if (!res || "success" !== res.state || !res.data) return;
20625
20784
  context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0);
20626
20785
  const b = graphic.AABBBounds;
20627
- this.doDrawImage(context, res.data, b, {
20786
+ context.globalAlpha = backgroundOpacity * opacity, backgroundClip && context.clip(), this.doDrawImage(context, res.data, b, {
20628
20787
  backgroundMode: backgroundMode,
20629
20788
  backgroundFit: backgroundFit,
20630
20789
  backgroundKeepAspectRatio: backgroundKeepAspectRatio,
20631
20790
  backgroundScale: backgroundScale,
20632
20791
  backgroundOffsetX: backgroundOffsetX,
20633
- backgroundOffsetY: backgroundOffsetY
20792
+ backgroundOffsetY: backgroundOffsetY,
20793
+ backgroundPosition: backgroundPosition
20634
20794
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
20635
- } else context.highPerformanceSave(), context.fillStyle = background, context.fill(), context.highPerformanceRestore();
20795
+ } else context.highPerformanceSave(), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
20636
20796
  }
20637
20797
  }
20638
20798
  const defaultGroupBackgroundRenderContribution = new DefaultGroupBackgroundRenderContribution();
@@ -22114,9 +22274,17 @@
22114
22274
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
22115
22275
  var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
22116
22276
  const {
22277
+ backgroundOpacity = graphicAttribute.backgroundOpacity,
22278
+ opacity = graphicAttribute.opacity,
22117
22279
  backgroundMode = graphicAttribute.backgroundMode,
22118
22280
  backgroundFit = graphicAttribute.backgroundFit,
22119
- backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio
22281
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
22282
+ backgroundScale = graphicAttribute.backgroundScale,
22283
+ backgroundOffsetX = graphicAttribute.backgroundOffsetX,
22284
+ backgroundOffsetY = graphicAttribute.backgroundOffsetY,
22285
+ backgroundPosition = graphicAttribute.backgroundPosition,
22286
+ backgroundClip = graphicAttribute.backgroundClip,
22287
+ backgroundCornerRadius = graphicAttribute.backgroundCornerRadius
22120
22288
  } = graphic.attribute;
22121
22289
  let matrix,
22122
22290
  {
@@ -22128,18 +22296,18 @@
22128
22296
  };
22129
22297
  let b;
22130
22298
  "richtext" === graphic.type && (matrix = context.currentMatrix.clone(), context.restore(), context.save(), context.setTransformForCurrent());
22131
- const shouldReCalBounds = isObject$2(background) && background.background,
22299
+ const backgroundConfig = isObject$2(background) && background.background ? background : null,
22132
22300
  onlyTranslate = graphic.transMatrix.onlyTranslate();
22133
- if (shouldReCalBounds) {
22301
+ if (backgroundConfig) {
22134
22302
  const _b = graphic.AABBBounds,
22135
- x = (null !== (_a = background.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = background.dx) && void 0 !== _c ? _c : 0),
22136
- y = (null !== (_d = background.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = background.dy) && void 0 !== _e ? _e : 0),
22137
- w = null !== (_f = background.width) && void 0 !== _f ? _f : _b.width(),
22138
- h = null !== (_g = background.height) && void 0 !== _g ? _g : _b.height();
22139
- if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = background.background, !onlyTranslate) {
22303
+ x = (null !== (_a = backgroundConfig.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = backgroundConfig.dx) && void 0 !== _c ? _c : 0),
22304
+ y = (null !== (_d = backgroundConfig.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = backgroundConfig.dy) && void 0 !== _e ? _e : 0),
22305
+ w = null !== (_f = backgroundConfig.width) && void 0 !== _f ? _f : _b.width(),
22306
+ h = null !== (_g = backgroundConfig.height) && void 0 !== _g ? _g : _b.height();
22307
+ if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = backgroundConfig.background, !onlyTranslate) {
22140
22308
  const w = b.width(),
22141
22309
  h = b.height();
22142
- 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);
22310
+ 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);
22143
22311
  }
22144
22312
  } else b = graphic.AABBBounds, onlyTranslate || (b = getTextBounds(Object.assign(Object.assign({}, graphic.attribute), {
22145
22313
  angle: 0,
@@ -22152,20 +22320,18 @@
22152
22320
  })).clone());
22153
22321
  if (graphic.backgroundImg && graphic.resources) {
22154
22322
  const res = graphic.resources.get(background);
22155
- if ("success" !== res.state || !res.data) return void restore();
22156
- context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, {
22323
+ if (!res || "success" !== res.state || !res.data) return void restore();
22324
+ 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, {
22157
22325
  backgroundMode: backgroundMode,
22158
22326
  backgroundFit: backgroundFit,
22159
- backgroundKeepAspectRatio: backgroundKeepAspectRatio
22327
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
22328
+ backgroundScale: backgroundScale,
22329
+ backgroundOffsetX: backgroundOffsetX,
22330
+ backgroundOffsetY: backgroundOffsetY,
22331
+ backgroundPosition: backgroundPosition
22160
22332
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
22161
- } else {
22162
- const {
22163
- backgroundCornerRadius: backgroundCornerRadius,
22164
- backgroundOpacity = 1
22165
- } = graphic.attribute;
22166
- context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity, 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();
22167
- }
22168
- shouldReCalBounds && boundsAllocate.free(b), restore();
22333
+ } 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();
22334
+ backgroundConfig && boundsAllocate.free(b), restore();
22169
22335
  }
22170
22336
  }
22171
22337
  const defaultTextBackgroundRenderContribution = new DefaultTextBackgroundRenderContribution();
@@ -22592,6 +22758,92 @@
22592
22758
  };
22593
22759
  };
22594
22760
  const repeatStr = ["", "repeat-x", "repeat-y", "repeat"];
22761
+ function resolveImageMode({
22762
+ repeatX = "no-repeat",
22763
+ repeatY = "no-repeat",
22764
+ imageMode: imageMode
22765
+ }) {
22766
+ const repeatMode = resolveImageRepeatMode(repeatX, repeatY);
22767
+ return {
22768
+ repeatMode: repeatMode,
22769
+ sizingMode: "no-repeat" === repeatMode && null != imageMode ? imageMode : "fill"
22770
+ };
22771
+ }
22772
+ const IMAGE_MODE_TO_BACKGROUND_MODE = {
22773
+ cover: "no-repeat-cover",
22774
+ contain: "no-repeat-contain",
22775
+ fill: "no-repeat-fill",
22776
+ auto: "no-repeat-auto"
22777
+ };
22778
+ function resolveBackgroundParamsByImageSizing(sizingMode) {
22779
+ return {
22780
+ backgroundMode: IMAGE_MODE_TO_BACKGROUND_MODE[sizingMode],
22781
+ backgroundFit: !1,
22782
+ backgroundKeepAspectRatio: !1
22783
+ };
22784
+ }
22785
+ function resolveImageRepeatMode(repeatX, repeatY) {
22786
+ let repeat = 0;
22787
+ return "repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat ? repeatStr[repeat] : "no-repeat";
22788
+ }
22789
+ function shouldClipImageByLayout({
22790
+ repeatX = "no-repeat",
22791
+ repeatY = "no-repeat",
22792
+ imageMode: imageMode,
22793
+ imageScale = 1,
22794
+ imageOffsetX = 0,
22795
+ imageOffsetY = 0,
22796
+ imagePosition = "top-left"
22797
+ }) {
22798
+ const {
22799
+ repeatMode: repeatMode,
22800
+ sizingMode: sizingMode
22801
+ } = resolveImageMode({
22802
+ repeatX: repeatX,
22803
+ repeatY: repeatY,
22804
+ imageMode: imageMode
22805
+ });
22806
+ return "no-repeat" === repeatMode && ("cover" === sizingMode || "auto" === sizingMode || 1 !== imageScale || 0 !== imageOffsetX || 0 !== imageOffsetY);
22807
+ }
22808
+ function drawImageWithLayout(context, data, x, y, width, height, {
22809
+ repeatX = "no-repeat",
22810
+ repeatY = "no-repeat",
22811
+ imageMode: imageMode,
22812
+ imageScale = 1,
22813
+ imageOffsetX = 0,
22814
+ imageOffsetY = 0,
22815
+ imagePosition = "top-left"
22816
+ }) {
22817
+ const {
22818
+ repeatMode: repeatMode,
22819
+ sizingMode: sizingMode
22820
+ } = resolveImageMode({
22821
+ repeatX: repeatX,
22822
+ repeatY: repeatY,
22823
+ imageMode: imageMode
22824
+ }),
22825
+ imageBackgroundParams = "no-repeat" === repeatMode ? resolveBackgroundParamsByImageSizing(sizingMode) : {
22826
+ backgroundMode: repeatMode,
22827
+ backgroundFit: !1,
22828
+ backgroundKeepAspectRatio: !1
22829
+ };
22830
+ drawBackgroundImage(context, data, {
22831
+ x1: x,
22832
+ y1: y,
22833
+ x2: x + width,
22834
+ y2: y + height,
22835
+ width: () => width,
22836
+ height: () => height
22837
+ }, {
22838
+ backgroundMode: imageBackgroundParams.backgroundMode,
22839
+ backgroundFit: imageBackgroundParams.backgroundFit,
22840
+ backgroundKeepAspectRatio: imageBackgroundParams.backgroundKeepAspectRatio,
22841
+ backgroundScale: imageScale,
22842
+ backgroundOffsetX: imageOffsetX,
22843
+ backgroundOffsetY: imageOffsetY,
22844
+ backgroundPosition: imagePosition
22845
+ });
22846
+ }
22595
22847
  let DefaultCanvasImageRender = class extends BaseRender {
22596
22848
  constructor(graphicRenderContributions) {
22597
22849
  super(), this.graphicRenderContributions = graphicRenderContributions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution], this.init(graphicRenderContributions);
@@ -22606,6 +22858,11 @@
22606
22858
  cornerRadius = imageAttribute.cornerRadius,
22607
22859
  fillStrokeOrder = imageAttribute.fillStrokeOrder,
22608
22860
  cornerType = imageAttribute.cornerType,
22861
+ imageMode = imageAttribute.imageMode,
22862
+ imageScale = imageAttribute.imageScale,
22863
+ imageOffsetX = imageAttribute.imageOffsetX,
22864
+ imageOffsetY = imageAttribute.imageOffsetY,
22865
+ imagePosition = imageAttribute.imagePosition,
22609
22866
  image: url
22610
22867
  } = image.attribute,
22611
22868
  data = this.valid(image, imageAttribute, fillCb);
@@ -22622,22 +22879,33 @@
22622
22879
  const width = image.width,
22623
22880
  height = image.height;
22624
22881
  context.beginPath();
22625
- let needRestore = !1;
22626
- 0 === cornerRadius || isArray$1(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);
22882
+ let needCornerClip = !1;
22883
+ 0 === cornerRadius || isArray$1(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);
22627
22884
  const _runFill = () => {
22628
- if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
22629
- context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
22630
- let repeat = 0;
22631
- if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
22632
- const pattern = context.createPattern(res.data, repeatStr[repeat]);
22633
- context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
22634
- } else context.drawImage(res.data, x, y, width, height);
22635
- }
22885
+ doFill && (fillCb ? fillCb(context, image.attribute, imageAttribute) : fVisible && (context.setCommonStyle(image, image.attribute, x, y, imageAttribute), drawImageWithLayout(context, res.data, x, y, width, height, {
22886
+ repeatX: repeatX,
22887
+ repeatY: repeatY,
22888
+ imageMode: imageMode,
22889
+ imageScale: imageScale,
22890
+ imageOffsetX: imageOffsetX,
22891
+ imageOffsetY: imageOffsetY,
22892
+ imagePosition: imagePosition
22893
+ })));
22636
22894
  },
22637
22895
  _runStroke = () => {
22638
22896
  doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
22639
- };
22640
- 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);
22897
+ },
22898
+ needLayoutClip = shouldClipImageByLayout({
22899
+ repeatX: repeatX,
22900
+ repeatY: repeatY,
22901
+ imageMode: imageMode,
22902
+ imageScale: imageScale,
22903
+ imageOffsetX: imageOffsetX,
22904
+ imageOffsetY: imageOffsetY,
22905
+ imagePosition: imagePosition
22906
+ }),
22907
+ needClip = needCornerClip || needLayoutClip;
22908
+ 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);
22641
22909
  }
22642
22910
  draw(image, renderService, drawContext) {
22643
22911
  const {
@@ -23496,7 +23764,7 @@
23496
23764
  return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);
23497
23765
  }
23498
23766
  clearScreen(renderService, context, drawContext) {
23499
- var _a, _b, _c;
23767
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
23500
23768
  const {
23501
23769
  clear: clear,
23502
23770
  viewBox: viewBox
@@ -23506,9 +23774,20 @@
23506
23774
  if (clear) {
23507
23775
  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);
23508
23776
  const stage = null === (_b = renderService.drawParams) || void 0 === _b ? void 0 : _b.stage;
23509
- if (stage && (context.globalAlpha = null !== (_c = stage.attribute.opacity) && void 0 !== _c ? _c : 1), stage && stage.backgroundImg && stage.resources) {
23510
- const res = stage.resources.get(clear);
23511
- res && "success" === res.state && res.data && context.drawImage(res.data, 0, 0, width, height);
23777
+ 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) {
23778
+ const res = stage.resources.get(getBackgroundImage(clear));
23779
+ if (res && "success" === res.state && res.data) {
23780
+ const backgroundBounds = boundsAllocate.allocate(0, 0, 0 + width, 0 + height);
23781
+ drawBackgroundImage(context, res.data, backgroundBounds, {
23782
+ backgroundMode: null !== (_e = stage.attribute.backgroundMode) && void 0 !== _e ? _e : DefaultAttribute.backgroundMode,
23783
+ backgroundFit: null !== (_f = stage.attribute.backgroundFit) && void 0 !== _f ? _f : DefaultAttribute.backgroundFit,
23784
+ backgroundKeepAspectRatio: null !== (_g = stage.attribute.backgroundKeepAspectRatio) && void 0 !== _g ? _g : DefaultAttribute.backgroundKeepAspectRatio,
23785
+ backgroundScale: null !== (_h = stage.attribute.backgroundScale) && void 0 !== _h ? _h : DefaultAttribute.backgroundScale,
23786
+ backgroundOffsetX: null !== (_j = stage.attribute.backgroundOffsetX) && void 0 !== _j ? _j : DefaultAttribute.backgroundOffsetX,
23787
+ backgroundOffsetY: null !== (_k = stage.attribute.backgroundOffsetY) && void 0 !== _k ? _k : DefaultAttribute.backgroundOffsetY,
23788
+ backgroundPosition: null !== (_l = stage.attribute.backgroundPosition) && void 0 !== _l ? _l : DefaultAttribute.backgroundPosition
23789
+ }), boundsAllocate.free(backgroundBounds);
23790
+ }
23512
23791
  } else context.fillStyle = createColor(context, clear, {
23513
23792
  AABBBounds: {
23514
23793
  x1: 0,
@@ -24006,7 +24285,7 @@
24006
24285
  return null !== (_a = this._background) && void 0 !== _a ? _a : DefaultConfig.BACKGROUND;
24007
24286
  }
24008
24287
  set background(b) {
24009
- this._background = b;
24288
+ this._background = b, this.syncBackgroundImage(b);
24010
24289
  }
24011
24290
  get defaultLayer() {
24012
24291
  return this.at(0);
@@ -24020,6 +24299,18 @@
24020
24299
  set ticker(ticker) {
24021
24300
  ticker.bindStage(this), this._ticker && this._ticker.removeListener("tick", this.afterTickCb), ticker.addTimeline(this.timeline), this._ticker = ticker, this._ticker.on("tick", this.afterTickCb);
24022
24301
  }
24302
+ syncBackgroundImage(background) {
24303
+ var _a;
24304
+ const source = null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
24305
+ this.backgroundImg = !1, this.isImageBackgroundSource(source) && this.loadImage(source, !0);
24306
+ }
24307
+ isImageBackgroundSource(source) {
24308
+ if (!source) return !1;
24309
+ if ("string" == typeof source) return source.startsWith("<svg") || isValidUrl$1(source) || source.includes("/") || isBase64$1(source);
24310
+ if (!isObject$2(source)) return !1;
24311
+ const gradientSource = source;
24312
+ return "string" != typeof gradientSource.gradient || !Array.isArray(gradientSource.stops);
24313
+ }
24023
24314
  constructor(params = {}) {
24024
24315
  var _a, _b;
24025
24316
  super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
@@ -24058,9 +24349,7 @@
24058
24349
  main: !0
24059
24350
  })), 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 = {
24060
24351
  tickRenderMode: "effect"
24061
- }), this.optmize(params.optimize), params.background && isString$1(this._background) && this._background.includes("/") && this.setAttributes({
24062
- background: this._background
24063
- }), this.initAnimate(params), this.rafId = null !== (_b = params.rafId) && void 0 !== _b ? _b : Math.floor(6 * Math.random());
24352
+ }), 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());
24064
24353
  }
24065
24354
  initAnimate(params) {
24066
24355
  var _a;
@@ -35218,6 +35507,7 @@
35218
35507
  if (custom.prototype.constructor === custom) {
35219
35508
  const descriptor = Object.getOwnPropertyDescriptor(custom, "prototype");
35220
35509
  if (descriptor && !descriptor.writable) return 1;
35510
+ if (Object.getOwnPropertyNames(custom.prototype).length > 1) return 1;
35221
35511
  }
35222
35512
  return 2;
35223
35513
  }