@visactor/vtable-sheet 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.
@@ -7615,6 +7615,7 @@
7615
7615
  backgroundScale: 1,
7616
7616
  backgroundOffsetX: 0,
7617
7617
  backgroundOffsetY: 0,
7618
+ backgroundPosition: "top-left",
7618
7619
  blur: 0,
7619
7620
  filter: "",
7620
7621
  cursor: null,
@@ -7787,11 +7788,16 @@
7787
7788
  const DefaultImageAttribute = Object.assign(Object.assign({
7788
7789
  repeatX: "no-repeat",
7789
7790
  repeatY: "no-repeat",
7791
+ imageMode: void 0,
7790
7792
  image: "",
7791
7793
  width: 0,
7792
7794
  height: 0,
7793
7795
  maxWidth: 500,
7794
- maxHeight: 500
7796
+ maxHeight: 500,
7797
+ imagePosition: "top-left",
7798
+ imageScale: 1,
7799
+ imageOffsetX: 0,
7800
+ imageOffsetY: 0
7795
7801
  }, DefaultAttribute), {
7796
7802
  fill: !0,
7797
7803
  cornerRadius: 0,
@@ -12192,6 +12198,7 @@
12192
12198
  const tempConstantXYKey = ["x", "y"],
12193
12199
  tempConstantScaleXYKey = ["scaleX", "scaleY"],
12194
12200
  tempConstantAngleKey = ["angle"],
12201
+ builtinTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave"]),
12195
12202
  point = new Point();
12196
12203
  const NOWORK_ANIMATE_ATTR = {
12197
12204
  strokeSeg: 1,
@@ -12248,7 +12255,7 @@
12248
12255
  }
12249
12256
  constructor(params = {}) {
12250
12257
  var _a;
12251
- 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);
12258
+ 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);
12252
12259
  }
12253
12260
  getGraphicService() {
12254
12261
  var _a, _b;
@@ -12437,7 +12444,7 @@
12437
12444
  });
12438
12445
  }
12439
12446
  setAttributes(params, forceUpdateTag = !1, context) {
12440
- 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));
12447
+ 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));
12441
12448
  }
12442
12449
  _setAttributes(params, forceUpdateTag = !1, context) {
12443
12450
  const keys = Object.keys(params);
@@ -12452,7 +12459,7 @@
12452
12459
  const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
12453
12460
  [key]: value
12454
12461
  }, this.attribute, key, context);
12455
- 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);
12462
+ 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);
12456
12463
  }
12457
12464
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
12458
12465
  for (let i = 0; i < k.length; i++) {
@@ -12471,7 +12478,7 @@
12471
12478
  const context = {
12472
12479
  type: AttributeUpdateType.INIT
12473
12480
  };
12474
- 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);
12481
+ 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);
12475
12482
  }
12476
12483
  translate(x, y) {
12477
12484
  var _a, _b;
@@ -12804,7 +12811,8 @@
12804
12811
  return isString$2(path, !0) ? this.pathProxy = new CustomPath2D().fromString(path) : this.pathProxy = new CustomPath2D(), this.pathProxy;
12805
12812
  }
12806
12813
  loadImage(image, background = !1) {
12807
- if (!image || background && backgroundNotImage(image)) return;
12814
+ if (background && (null == image ? void 0 : image.background) && (image = image.background), background && (!image || backgroundNotImage(image))) return void (this.backgroundImg = !1);
12815
+ if (!image) return;
12808
12816
  const url = image;
12809
12817
  this.resources || (this.resources = new Map());
12810
12818
  const cache = {
@@ -12859,7 +12867,10 @@
12859
12867
  }
12860
12868
  }
12861
12869
  function backgroundNotImage(image) {
12862
- return !(!image.fill && !image.stroke);
12870
+ 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));
12871
+ }
12872
+ function isExternalTexture(texture) {
12873
+ return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$a(texture));
12863
12874
  }
12864
12875
  Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget$3);
12865
12876
 
@@ -14953,7 +14964,7 @@
14953
14964
  return [new Paragraph(text1, paragraph.newLine, paragraph.character, paragraph.ascentDescentMode), new Paragraph(text2, !0, paragraph.character, paragraph.ascentDescentMode)];
14954
14965
  }
14955
14966
 
14956
- const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", ...GRAPHIC_UPDATE_TAG_KEY];
14967
+ const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", "imageMode", "imagePosition", "imageScale", "imageOffsetX", "imageOffsetY", ...GRAPHIC_UPDATE_TAG_KEY];
14957
14968
  let Image$2 = class Image extends Graphic {
14958
14969
  constructor(params) {
14959
14970
  super(params), this.type = "image", this.numberType = IMAGE_NUMBER_TYPE, this.loadImage(this.attribute.image);
@@ -15058,6 +15069,7 @@
15058
15069
  };
15059
15070
  Image$2.NOWORK_ANIMATE_ATTR = Object.assign({
15060
15071
  image: 1,
15072
+ imageMode: 1,
15061
15073
  repeatX: 1,
15062
15074
  repeatY: 1
15063
15075
  }, NOWORK_ANIMATE_ATTR);
@@ -16034,11 +16046,12 @@
16034
16046
  backgroundScale = graphicAttribute.backgroundScale,
16035
16047
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
16036
16048
  backgroundOffsetY = graphicAttribute.backgroundOffsetY,
16037
- backgroundClip = graphicAttribute.backgroundClip
16049
+ backgroundClip = graphicAttribute.backgroundClip,
16050
+ backgroundPosition = graphicAttribute.backgroundPosition
16038
16051
  } = graphic.attribute;
16039
16052
  if (background) if (graphic.backgroundImg && graphic.resources) {
16040
- const res = graphic.resources.get(background);
16041
- if ("success" !== res.state || !res.data) return;
16053
+ const res = graphic.resources.get(getBackgroundImage(background));
16054
+ if (!res || "success" !== res.state || !res.data) return;
16042
16055
  if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
16043
16056
  const groupAttribute = getTheme(graphic.parent).group,
16044
16057
  {
@@ -16055,59 +16068,160 @@
16055
16068
  backgroundKeepAspectRatio: backgroundKeepAspectRatio,
16056
16069
  backgroundScale: backgroundScale,
16057
16070
  backgroundOffsetX: backgroundOffsetX,
16058
- backgroundOffsetY: backgroundOffsetY
16071
+ backgroundOffsetY: backgroundOffsetY,
16072
+ backgroundPosition: backgroundPosition
16059
16073
  }), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
16060
16074
  } else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
16061
16075
  }
16062
16076
  doDrawImage(context, data, b, params) {
16063
- const {
16064
- backgroundMode: backgroundMode,
16065
- backgroundFit: backgroundFit,
16066
- backgroundKeepAspectRatio: backgroundKeepAspectRatio,
16067
- backgroundScale = 1,
16068
- backgroundOffsetX = 0,
16069
- backgroundOffsetY = 0
16070
- } = params,
16071
- targetW = b.width(),
16072
- targetH = b.height();
16073
- let w = targetW,
16074
- h = targetH;
16075
- if ("no-repeat" === backgroundMode) {
16076
- if (backgroundFit) {
16077
- if (backgroundKeepAspectRatio) {
16078
- const maxScale = Math.max(targetW / data.width, targetH / data.height);
16079
- context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
16080
- } else context.drawImage(data, b.x1, b.y1, b.width(), b.height());
16081
- } else {
16082
- const resW = data.width * backgroundScale,
16083
- resH = data.height * backgroundScale;
16084
- context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
16085
- }
16086
- } else {
16087
- if (backgroundFit && "repeat" !== backgroundMode && (data.width || data.height)) {
16088
- const resW = data.width,
16089
- resH = data.height;
16090
- if ("repeat-x" === backgroundMode) {
16091
- w = resW * (targetH / resH), h = targetH;
16092
- } else if ("repeat-y" === backgroundMode) {
16093
- h = resH * (targetW / resW), w = targetW;
16094
- }
16095
- const dpr = context.dpr,
16096
- canvas = canvasAllocate.allocate({
16097
- width: w,
16098
- height: h,
16099
- dpr: dpr
16100
- }),
16101
- ctx = canvas.getContext("2d");
16102
- 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);
16103
- }
16104
- const dpr = context.dpr,
16105
- pattern = context.createPattern(data, backgroundMode);
16106
- 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);
16107
- }
16077
+ drawBackgroundImage(context, data, b, params);
16108
16078
  }
16109
16079
  }
16110
16080
  const defaultBaseBackgroundRenderContribution = new DefaultBaseBackgroundRenderContribution();
16081
+ const verticalPositionKeywords = new Set(["top", "center", "bottom"]);
16082
+ function getBackgroundImage(background) {
16083
+ var _a;
16084
+ return null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
16085
+ }
16086
+ function resolveBackgroundSizing({
16087
+ backgroundFit: backgroundFit,
16088
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
16089
+ }) {
16090
+ return backgroundFit ? backgroundKeepAspectRatio ? "cover" : "fill" : "auto";
16091
+ }
16092
+ const NO_REPEAT_SIZING_MAP = {
16093
+ "no-repeat-cover": "cover",
16094
+ "no-repeat-contain": "contain",
16095
+ "no-repeat-fill": "fill",
16096
+ "no-repeat-auto": "auto"
16097
+ };
16098
+ function resolveBackgroundDrawMode({
16099
+ backgroundMode: backgroundMode,
16100
+ backgroundFit: backgroundFit,
16101
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
16102
+ }) {
16103
+ const sizing = NO_REPEAT_SIZING_MAP[backgroundMode];
16104
+ return sizing ? {
16105
+ backgroundRepeatMode: "no-repeat",
16106
+ backgroundSizing: sizing
16107
+ } : {
16108
+ backgroundRepeatMode: backgroundMode,
16109
+ backgroundSizing: resolveBackgroundSizing({
16110
+ backgroundFit: backgroundFit,
16111
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
16112
+ })
16113
+ };
16114
+ }
16115
+ function isPercentageValue(value) {
16116
+ return /^-?\d+(\.\d+)?%$/.test(value);
16117
+ }
16118
+ function parsePositionToken(value, remainSpace, startKeyword, centerKeyword, endKeyword) {
16119
+ if ("number" == typeof value && Number.isFinite(value)) return value;
16120
+ const normalizedValue = `${null != value ? value : ""}`.trim().toLowerCase();
16121
+ if (!normalizedValue || normalizedValue === startKeyword) return 0;
16122
+ if (normalizedValue === centerKeyword) return remainSpace / 2;
16123
+ if (normalizedValue === endKeyword) return remainSpace;
16124
+ if (isPercentageValue(normalizedValue)) return remainSpace * parseFloat(normalizedValue) / 100;
16125
+ const parsedValue = Number(normalizedValue);
16126
+ return Number.isFinite(parsedValue) ? parsedValue : 0;
16127
+ }
16128
+ function normalizeBackgroundPosition(position) {
16129
+ var _a, _b;
16130
+ if (Array.isArray(position)) return [null !== (_a = position[0]) && void 0 !== _a ? _a : "left", null !== (_b = position[1]) && void 0 !== _b ? _b : "top"];
16131
+ const tokens = `${null != position ? position : "top-left"}`.trim().toLowerCase().replace(/-/g, " ").split(/\s+/).filter(Boolean);
16132
+ if (0 === tokens.length) return ["left", "top"];
16133
+ if (1 === tokens.length) {
16134
+ const token = tokens[0];
16135
+ return "center" === token ? ["center", "center"] : verticalPositionKeywords.has(token) ? ["center", token] : [token, "center"];
16136
+ }
16137
+ let horizontal, vertical;
16138
+ const genericTokens = [];
16139
+ for (let i = 0; i < 2; i++) {
16140
+ const token = tokens[i];
16141
+ "left" !== token && "right" !== token ? "top" !== token && "bottom" !== token ? genericTokens.push(token) : vertical = token : horizontal = token;
16142
+ }
16143
+ return null == horizontal && genericTokens.length && (horizontal = genericTokens.shift()), null == vertical && genericTokens.length && (vertical = genericTokens.shift()), [null != horizontal ? horizontal : "left", null != vertical ? vertical : "top"];
16144
+ }
16145
+ function resolveBackgroundPosition(position, remainWidth, remainHeight) {
16146
+ const [horizontalPosition, verticalPosition] = normalizeBackgroundPosition(position);
16147
+ return {
16148
+ x: parsePositionToken(horizontalPosition, remainWidth, "left", "center", "right"),
16149
+ y: parsePositionToken(verticalPosition, remainHeight, "top", "center", "bottom")
16150
+ };
16151
+ }
16152
+ function pickRenderableDimension(...values) {
16153
+ for (const value of values) if ("number" == typeof value && Number.isFinite(value) && value > 0) return value;
16154
+ return null;
16155
+ }
16156
+ function resolveRenderableImageSize(data) {
16157
+ if (!data) return null;
16158
+ const width = pickRenderableDimension(data.naturalWidth, data.videoWidth, data.width),
16159
+ height = pickRenderableDimension(data.naturalHeight, data.videoHeight, data.height);
16160
+ return null == width || null == height ? null : {
16161
+ width: width,
16162
+ height: height
16163
+ };
16164
+ }
16165
+ function drawBackgroundImage(context, data, b, params) {
16166
+ var _a, _b;
16167
+ const {
16168
+ backgroundMode: backgroundMode,
16169
+ backgroundFit: backgroundFit,
16170
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
16171
+ backgroundScale = 1,
16172
+ backgroundOffsetX = 0,
16173
+ backgroundOffsetY = 0,
16174
+ backgroundPosition = "top-left"
16175
+ } = params,
16176
+ targetW = b.width(),
16177
+ targetH = b.height(),
16178
+ sourceSize = resolveRenderableImageSize(data),
16179
+ {
16180
+ backgroundRepeatMode: backgroundRepeatMode,
16181
+ backgroundSizing: resolvedBackgroundSizing
16182
+ } = resolveBackgroundDrawMode({
16183
+ backgroundMode: backgroundMode,
16184
+ backgroundFit: backgroundFit,
16185
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
16186
+ });
16187
+ let w = targetW,
16188
+ h = targetH;
16189
+ if (targetW <= 0 || targetH <= 0) return;
16190
+ if ("no-repeat" === backgroundRepeatMode) {
16191
+ let drawWidth = null !== (_a = null == sourceSize ? void 0 : sourceSize.width) && void 0 !== _a ? _a : targetW,
16192
+ drawHeight = null !== (_b = null == sourceSize ? void 0 : sourceSize.height) && void 0 !== _b ? _b : targetH;
16193
+ if ("cover" !== resolvedBackgroundSizing && "contain" !== resolvedBackgroundSizing || !sourceSize) "fill" === resolvedBackgroundSizing && (drawWidth = targetW, drawHeight = targetH);else {
16194
+ const scale = "cover" === resolvedBackgroundSizing ? Math.max(targetW / sourceSize.width, targetH / sourceSize.height) : Math.min(targetW / sourceSize.width, targetH / sourceSize.height);
16195
+ drawWidth = sourceSize.width * scale, drawHeight = sourceSize.height * scale;
16196
+ }
16197
+ drawWidth *= backgroundScale, drawHeight *= backgroundScale;
16198
+ const {
16199
+ x: x,
16200
+ y: y
16201
+ } = resolveBackgroundPosition(backgroundPosition, targetW - drawWidth, targetH - drawHeight);
16202
+ return void context.drawImage(data, b.x1 + x + backgroundOffsetX, b.y1 + y + backgroundOffsetY, drawWidth, drawHeight);
16203
+ }
16204
+ if (backgroundFit && "repeat" !== backgroundRepeatMode && sourceSize) {
16205
+ const resW = sourceSize.width,
16206
+ resH = sourceSize.height;
16207
+ if ("repeat-x" === backgroundRepeatMode) {
16208
+ w = resW * (targetH / resH), h = targetH;
16209
+ } else if ("repeat-y" === backgroundRepeatMode) {
16210
+ h = resH * (targetW / resW), w = targetW;
16211
+ }
16212
+ const dpr = context.dpr,
16213
+ canvas = canvasAllocate.allocate({
16214
+ width: w,
16215
+ height: h,
16216
+ dpr: dpr
16217
+ }),
16218
+ ctx = canvas.getContext("2d");
16219
+ 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);
16220
+ }
16221
+ const dpr = context.dpr,
16222
+ pattern = context.createPattern(data, backgroundRepeatMode);
16223
+ 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);
16224
+ }
16111
16225
  let DefaultBaseInteractiveRenderContribution = class {
16112
16226
  constructor(subRenderContribitions) {
16113
16227
  this.subRenderContribitions = subRenderContribitions, this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
@@ -16153,6 +16267,7 @@
16153
16267
  }
16154
16268
  const defaultBaseClipRenderAfterContribution = new DefaultBaseClipRenderAfterContribution();
16155
16269
 
16270
+ const builtinProceduralTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid"]);
16156
16271
  function formatRatio(ratio) {
16157
16272
  return ratio <= .5 ? 4 * ratio - 1 : -4 * ratio + 3;
16158
16273
  }
@@ -16266,38 +16381,43 @@
16266
16381
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
16267
16382
  }
16268
16383
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
16269
- var _a;
16384
+ var _a, _b, _c, _d, _e, _f;
16270
16385
  const {
16271
16386
  textureRatio = graphicAttribute.textureRatio,
16272
16387
  textureOptions = null
16273
16388
  } = graphic.attribute;
16274
- let pattern = this.textureMap.get(texture);
16275
- if (!pattern) switch (texture) {
16276
- case "circle":
16277
- pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
16278
- break;
16279
- case "diamond":
16280
- pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
16281
- break;
16282
- case "rect":
16283
- pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
16284
- break;
16285
- case "vertical-line":
16286
- pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
16287
- break;
16288
- case "horizontal-line":
16289
- pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
16290
- break;
16291
- case "bias-lr":
16292
- pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
16293
- break;
16294
- case "bias-rl":
16295
- pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
16296
- break;
16297
- case "grid":
16298
- pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
16389
+ let pattern = null;
16390
+ const textureRadius = null !== (_a = null == textureOptions ? void 0 : textureOptions.radius) && void 0 !== _a ? _a : 0,
16391
+ patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr, textureRadius);
16392
+ if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
16393
+ if ("string" == typeof texture) switch (texture) {
16394
+ case "circle":
16395
+ pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
16396
+ break;
16397
+ case "diamond":
16398
+ pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
16399
+ break;
16400
+ case "rect":
16401
+ pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
16402
+ break;
16403
+ case "vertical-line":
16404
+ pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
16405
+ break;
16406
+ case "horizontal-line":
16407
+ pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
16408
+ break;
16409
+ case "bias-lr":
16410
+ pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
16411
+ break;
16412
+ case "bias-rl":
16413
+ pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
16414
+ break;
16415
+ case "grid":
16416
+ pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
16417
+ }
16418
+ pattern || (pattern = this.createResourcePattern(texture, graphic, context, texturePadding, textureRadius)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
16299
16419
  }
16300
- if (textureOptions && textureOptions.dynamicTexture) {
16420
+ if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
16301
16421
  const {
16302
16422
  gridConfig = {},
16303
16423
  useNewCanvas: useNewCanvas
@@ -16342,10 +16462,24 @@
16342
16462
  for (let i = 0; i < gridRows; i++) for (let j = 0; j < gridColumns; j++) {
16343
16463
  const _x = x + cellSize / 2 + j * cellSize,
16344
16464
  _y = y + cellSize / 2 + i * cellSize;
16345
- 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());
16465
+ 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());
16346
16466
  }
16347
16467
  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();
16348
- } else if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
16468
+ } else if (pattern) {
16469
+ if (pattern.setTransform) {
16470
+ const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
16471
+ alignOffsetX = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _c ? _c : 0,
16472
+ alignOffsetY = null !== (_d = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _d ? _d : 0;
16473
+ let translateX = 0,
16474
+ translateY = 0;
16475
+ if (alignToGraphic) {
16476
+ const m = context.currentMatrix;
16477
+ 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;
16478
+ } else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
16479
+ pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
16480
+ }
16481
+ context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
16482
+ } else if ("wave" === texture) {
16349
16483
  context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
16350
16484
  const b = graphic.AABBBounds;
16351
16485
  drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
@@ -16353,6 +16487,45 @@
16353
16487
  }), x + b.x1 - x, y + b.y1 - y), context.restore();
16354
16488
  }
16355
16489
  }
16490
+ getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr, textureRadius) {
16491
+ 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}`;
16492
+ }
16493
+ createResourcePattern(texture, graphic, context, texturePadding, textureRadius) {
16494
+ var _a;
16495
+ const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
16496
+ data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
16497
+ if (!data) return null;
16498
+ if (texturePadding > 0 || textureRadius > 0) {
16499
+ const w = data.naturalWidth || data.width,
16500
+ h = data.naturalHeight || data.height;
16501
+ if (w > 0 && h > 0) {
16502
+ const tileW = w + 2 * texturePadding,
16503
+ tileH = h + 2 * texturePadding,
16504
+ canvas = canvasAllocate.allocate({
16505
+ width: tileW,
16506
+ height: tileH,
16507
+ dpr: context.dpr
16508
+ }),
16509
+ ctx = canvas.getContext("2d");
16510
+ if (ctx) {
16511
+ if (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, tileW, tileH), textureRadius > 0) {
16512
+ const r = Math.max(0, Math.min(textureRadius, Math.min(w, h) / 2)),
16513
+ x0 = texturePadding,
16514
+ y0 = texturePadding,
16515
+ x1 = x0 + w,
16516
+ y1 = y0 + h;
16517
+ 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();
16518
+ }
16519
+ ctx.drawImage(data, texturePadding, texturePadding, w, h);
16520
+ const pattern = context.createPattern(canvas.nativeCanvas, "repeat");
16521
+ 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;
16522
+ }
16523
+ canvasAllocate.free(canvas);
16524
+ }
16525
+ }
16526
+ const pattern = context.createPattern(data, "repeat");
16527
+ return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
16528
+ }
16356
16529
  }
16357
16530
  const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();
16358
16531
 
@@ -16464,27 +16637,32 @@
16464
16637
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
16465
16638
  const {
16466
16639
  background: background,
16640
+ backgroundOpacity = graphicAttribute.backgroundOpacity,
16641
+ opacity = graphicAttribute.opacity,
16467
16642
  backgroundMode = graphicAttribute.backgroundMode,
16468
16643
  backgroundFit = graphicAttribute.backgroundFit,
16469
16644
  backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
16470
16645
  backgroundScale = graphicAttribute.backgroundScale,
16471
16646
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
16472
- backgroundOffsetY = graphicAttribute.backgroundOffsetY
16647
+ backgroundOffsetY = graphicAttribute.backgroundOffsetY,
16648
+ backgroundClip = graphicAttribute.backgroundClip,
16649
+ backgroundPosition = graphicAttribute.backgroundPosition
16473
16650
  } = graphic.attribute;
16474
16651
  if (background) if (graphic.backgroundImg && graphic.resources) {
16475
- const res = graphic.resources.get(background);
16476
- if ("success" !== res.state || !res.data) return;
16652
+ const res = graphic.resources.get(getBackgroundImage(background));
16653
+ if (!res || "success" !== res.state || !res.data) return;
16477
16654
  context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0);
16478
16655
  const b = graphic.AABBBounds;
16479
- this.doDrawImage(context, res.data, b, {
16656
+ context.globalAlpha = backgroundOpacity * opacity, backgroundClip && context.clip(), this.doDrawImage(context, res.data, b, {
16480
16657
  backgroundMode: backgroundMode,
16481
16658
  backgroundFit: backgroundFit,
16482
16659
  backgroundKeepAspectRatio: backgroundKeepAspectRatio,
16483
16660
  backgroundScale: backgroundScale,
16484
16661
  backgroundOffsetX: backgroundOffsetX,
16485
- backgroundOffsetY: backgroundOffsetY
16662
+ backgroundOffsetY: backgroundOffsetY,
16663
+ backgroundPosition: backgroundPosition
16486
16664
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
16487
- } else context.highPerformanceSave(), context.fillStyle = background, context.fill(), context.highPerformanceRestore();
16665
+ } else context.highPerformanceSave(), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
16488
16666
  }
16489
16667
  }
16490
16668
  const defaultGroupBackgroundRenderContribution = new DefaultGroupBackgroundRenderContribution();
@@ -17966,9 +18144,17 @@
17966
18144
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
17967
18145
  var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
17968
18146
  const {
18147
+ backgroundOpacity = graphicAttribute.backgroundOpacity,
18148
+ opacity = graphicAttribute.opacity,
17969
18149
  backgroundMode = graphicAttribute.backgroundMode,
17970
18150
  backgroundFit = graphicAttribute.backgroundFit,
17971
- backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio
18151
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
18152
+ backgroundScale = graphicAttribute.backgroundScale,
18153
+ backgroundOffsetX = graphicAttribute.backgroundOffsetX,
18154
+ backgroundOffsetY = graphicAttribute.backgroundOffsetY,
18155
+ backgroundPosition = graphicAttribute.backgroundPosition,
18156
+ backgroundClip = graphicAttribute.backgroundClip,
18157
+ backgroundCornerRadius = graphicAttribute.backgroundCornerRadius
17972
18158
  } = graphic.attribute;
17973
18159
  let matrix,
17974
18160
  {
@@ -17980,18 +18166,18 @@
17980
18166
  };
17981
18167
  let b;
17982
18168
  "richtext" === graphic.type && (matrix = context.currentMatrix.clone(), context.restore(), context.save(), context.setTransformForCurrent());
17983
- const shouldReCalBounds = isObject$a(background) && background.background,
18169
+ const backgroundConfig = isObject$a(background) && background.background ? background : null,
17984
18170
  onlyTranslate = graphic.transMatrix.onlyTranslate();
17985
- if (shouldReCalBounds) {
18171
+ if (backgroundConfig) {
17986
18172
  const _b = graphic.AABBBounds,
17987
- x = (null !== (_a = background.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = background.dx) && void 0 !== _c ? _c : 0),
17988
- y = (null !== (_d = background.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = background.dy) && void 0 !== _e ? _e : 0),
17989
- w = null !== (_f = background.width) && void 0 !== _f ? _f : _b.width(),
17990
- h = null !== (_g = background.height) && void 0 !== _g ? _g : _b.height();
17991
- if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = background.background, !onlyTranslate) {
18173
+ x = (null !== (_a = backgroundConfig.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = backgroundConfig.dx) && void 0 !== _c ? _c : 0),
18174
+ y = (null !== (_d = backgroundConfig.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = backgroundConfig.dy) && void 0 !== _e ? _e : 0),
18175
+ w = null !== (_f = backgroundConfig.width) && void 0 !== _f ? _f : _b.width(),
18176
+ h = null !== (_g = backgroundConfig.height) && void 0 !== _g ? _g : _b.height();
18177
+ if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = backgroundConfig.background, !onlyTranslate) {
17992
18178
  const w = b.width(),
17993
18179
  h = b.height();
17994
- 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);
18180
+ 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);
17995
18181
  }
17996
18182
  } else b = graphic.AABBBounds, onlyTranslate || (b = getTextBounds(Object.assign(Object.assign({}, graphic.attribute), {
17997
18183
  angle: 0,
@@ -18004,19 +18190,18 @@
18004
18190
  })).clone());
18005
18191
  if (graphic.backgroundImg && graphic.resources) {
18006
18192
  const res = graphic.resources.get(background);
18007
- if ("success" !== res.state || !res.data) return void restore();
18008
- context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, {
18193
+ if (!res || "success" !== res.state || !res.data) return void restore();
18194
+ 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, {
18009
18195
  backgroundMode: backgroundMode,
18010
18196
  backgroundFit: backgroundFit,
18011
- backgroundKeepAspectRatio: backgroundKeepAspectRatio
18197
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
18198
+ backgroundScale: backgroundScale,
18199
+ backgroundOffsetX: backgroundOffsetX,
18200
+ backgroundOffsetY: backgroundOffsetY,
18201
+ backgroundPosition: backgroundPosition
18012
18202
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
18013
- } else {
18014
- const {
18015
- backgroundCornerRadius: backgroundCornerRadius
18016
- } = graphic.attribute;
18017
- 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();
18018
- }
18019
- shouldReCalBounds && boundsAllocate.free(b), restore();
18203
+ } 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();
18204
+ backgroundConfig && boundsAllocate.free(b), restore();
18020
18205
  }
18021
18206
  }
18022
18207
  const defaultTextBackgroundRenderContribution = new DefaultTextBackgroundRenderContribution();
@@ -18443,6 +18628,92 @@
18443
18628
  };
18444
18629
  };
18445
18630
  const repeatStr = ["", "repeat-x", "repeat-y", "repeat"];
18631
+ function resolveImageMode({
18632
+ repeatX = "no-repeat",
18633
+ repeatY = "no-repeat",
18634
+ imageMode: imageMode
18635
+ }) {
18636
+ const repeatMode = resolveImageRepeatMode(repeatX, repeatY);
18637
+ return {
18638
+ repeatMode: repeatMode,
18639
+ sizingMode: "no-repeat" === repeatMode && null != imageMode ? imageMode : "fill"
18640
+ };
18641
+ }
18642
+ const IMAGE_MODE_TO_BACKGROUND_MODE = {
18643
+ cover: "no-repeat-cover",
18644
+ contain: "no-repeat-contain",
18645
+ fill: "no-repeat-fill",
18646
+ auto: "no-repeat-auto"
18647
+ };
18648
+ function resolveBackgroundParamsByImageSizing(sizingMode) {
18649
+ return {
18650
+ backgroundMode: IMAGE_MODE_TO_BACKGROUND_MODE[sizingMode],
18651
+ backgroundFit: !1,
18652
+ backgroundKeepAspectRatio: !1
18653
+ };
18654
+ }
18655
+ function resolveImageRepeatMode(repeatX, repeatY) {
18656
+ let repeat = 0;
18657
+ return "repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat ? repeatStr[repeat] : "no-repeat";
18658
+ }
18659
+ function shouldClipImageByLayout({
18660
+ repeatX = "no-repeat",
18661
+ repeatY = "no-repeat",
18662
+ imageMode: imageMode,
18663
+ imageScale = 1,
18664
+ imageOffsetX = 0,
18665
+ imageOffsetY = 0,
18666
+ imagePosition = "top-left"
18667
+ }) {
18668
+ const {
18669
+ repeatMode: repeatMode,
18670
+ sizingMode: sizingMode
18671
+ } = resolveImageMode({
18672
+ repeatX: repeatX,
18673
+ repeatY: repeatY,
18674
+ imageMode: imageMode
18675
+ });
18676
+ return "no-repeat" === repeatMode && ("cover" === sizingMode || "auto" === sizingMode || 1 !== imageScale || 0 !== imageOffsetX || 0 !== imageOffsetY);
18677
+ }
18678
+ function drawImageWithLayout(context, data, x, y, width, height, {
18679
+ repeatX = "no-repeat",
18680
+ repeatY = "no-repeat",
18681
+ imageMode: imageMode,
18682
+ imageScale = 1,
18683
+ imageOffsetX = 0,
18684
+ imageOffsetY = 0,
18685
+ imagePosition = "top-left"
18686
+ }) {
18687
+ const {
18688
+ repeatMode: repeatMode,
18689
+ sizingMode: sizingMode
18690
+ } = resolveImageMode({
18691
+ repeatX: repeatX,
18692
+ repeatY: repeatY,
18693
+ imageMode: imageMode
18694
+ }),
18695
+ imageBackgroundParams = "no-repeat" === repeatMode ? resolveBackgroundParamsByImageSizing(sizingMode) : {
18696
+ backgroundMode: repeatMode,
18697
+ backgroundFit: !1,
18698
+ backgroundKeepAspectRatio: !1
18699
+ };
18700
+ drawBackgroundImage(context, data, {
18701
+ x1: x,
18702
+ y1: y,
18703
+ x2: x + width,
18704
+ y2: y + height,
18705
+ width: () => width,
18706
+ height: () => height
18707
+ }, {
18708
+ backgroundMode: imageBackgroundParams.backgroundMode,
18709
+ backgroundFit: imageBackgroundParams.backgroundFit,
18710
+ backgroundKeepAspectRatio: imageBackgroundParams.backgroundKeepAspectRatio,
18711
+ backgroundScale: imageScale,
18712
+ backgroundOffsetX: imageOffsetX,
18713
+ backgroundOffsetY: imageOffsetY,
18714
+ backgroundPosition: imagePosition
18715
+ });
18716
+ }
18446
18717
  let DefaultCanvasImageRender = class extends BaseRender {
18447
18718
  constructor(graphicRenderContributions) {
18448
18719
  super(), this.graphicRenderContributions = graphicRenderContributions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution], this.init(graphicRenderContributions);
@@ -18457,6 +18728,11 @@
18457
18728
  cornerRadius = imageAttribute.cornerRadius,
18458
18729
  fillStrokeOrder = imageAttribute.fillStrokeOrder,
18459
18730
  cornerType = imageAttribute.cornerType,
18731
+ imageMode = imageAttribute.imageMode,
18732
+ imageScale = imageAttribute.imageScale,
18733
+ imageOffsetX = imageAttribute.imageOffsetX,
18734
+ imageOffsetY = imageAttribute.imageOffsetY,
18735
+ imagePosition = imageAttribute.imagePosition,
18460
18736
  image: url
18461
18737
  } = image.attribute,
18462
18738
  data = this.valid(image, imageAttribute, fillCb);
@@ -18473,22 +18749,33 @@
18473
18749
  const width = image.width,
18474
18750
  height = image.height;
18475
18751
  context.beginPath();
18476
- let needRestore = !1;
18477
- 0 === cornerRadius || isArray$8(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);
18752
+ let needCornerClip = !1;
18753
+ 0 === cornerRadius || isArray$8(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);
18478
18754
  const _runFill = () => {
18479
- if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
18480
- context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
18481
- let repeat = 0;
18482
- if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
18483
- const pattern = context.createPattern(res.data, repeatStr[repeat]);
18484
- context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
18485
- } else context.drawImage(res.data, x, y, width, height);
18486
- }
18755
+ doFill && (fillCb ? fillCb(context, image.attribute, imageAttribute) : fVisible && (context.setCommonStyle(image, image.attribute, x, y, imageAttribute), drawImageWithLayout(context, res.data, x, y, width, height, {
18756
+ repeatX: repeatX,
18757
+ repeatY: repeatY,
18758
+ imageMode: imageMode,
18759
+ imageScale: imageScale,
18760
+ imageOffsetX: imageOffsetX,
18761
+ imageOffsetY: imageOffsetY,
18762
+ imagePosition: imagePosition
18763
+ })));
18487
18764
  },
18488
18765
  _runStroke = () => {
18489
18766
  doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
18490
- };
18491
- 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);
18767
+ },
18768
+ needLayoutClip = shouldClipImageByLayout({
18769
+ repeatX: repeatX,
18770
+ repeatY: repeatY,
18771
+ imageMode: imageMode,
18772
+ imageScale: imageScale,
18773
+ imageOffsetX: imageOffsetX,
18774
+ imageOffsetY: imageOffsetY,
18775
+ imagePosition: imagePosition
18776
+ }),
18777
+ needClip = needCornerClip || needLayoutClip;
18778
+ 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);
18492
18779
  }
18493
18780
  draw(image, renderService, drawContext) {
18494
18781
  const {
@@ -19342,7 +19629,7 @@
19342
19629
  return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);
19343
19630
  }
19344
19631
  clearScreen(renderService, context, drawContext) {
19345
- var _a, _b, _c;
19632
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19346
19633
  const {
19347
19634
  clear: clear,
19348
19635
  viewBox: viewBox
@@ -19352,9 +19639,20 @@
19352
19639
  if (clear) {
19353
19640
  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);
19354
19641
  const stage = null === (_b = renderService.drawParams) || void 0 === _b ? void 0 : _b.stage;
19355
- if (stage && (context.globalAlpha = null !== (_c = stage.attribute.opacity) && void 0 !== _c ? _c : 1), stage && stage.backgroundImg && stage.resources) {
19356
- const res = stage.resources.get(clear);
19357
- res && "success" === res.state && res.data && context.drawImage(res.data, 0, 0, width, height);
19642
+ 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) {
19643
+ const res = stage.resources.get(getBackgroundImage(clear));
19644
+ if (res && "success" === res.state && res.data) {
19645
+ const backgroundBounds = boundsAllocate.allocate(0, 0, 0 + width, 0 + height);
19646
+ drawBackgroundImage(context, res.data, backgroundBounds, {
19647
+ backgroundMode: null !== (_e = stage.attribute.backgroundMode) && void 0 !== _e ? _e : DefaultAttribute.backgroundMode,
19648
+ backgroundFit: null !== (_f = stage.attribute.backgroundFit) && void 0 !== _f ? _f : DefaultAttribute.backgroundFit,
19649
+ backgroundKeepAspectRatio: null !== (_g = stage.attribute.backgroundKeepAspectRatio) && void 0 !== _g ? _g : DefaultAttribute.backgroundKeepAspectRatio,
19650
+ backgroundScale: null !== (_h = stage.attribute.backgroundScale) && void 0 !== _h ? _h : DefaultAttribute.backgroundScale,
19651
+ backgroundOffsetX: null !== (_j = stage.attribute.backgroundOffsetX) && void 0 !== _j ? _j : DefaultAttribute.backgroundOffsetX,
19652
+ backgroundOffsetY: null !== (_k = stage.attribute.backgroundOffsetY) && void 0 !== _k ? _k : DefaultAttribute.backgroundOffsetY,
19653
+ backgroundPosition: null !== (_l = stage.attribute.backgroundPosition) && void 0 !== _l ? _l : DefaultAttribute.backgroundPosition
19654
+ }), boundsAllocate.free(backgroundBounds);
19655
+ }
19358
19656
  } else context.fillStyle = createColor(context, clear, {
19359
19657
  AABBBounds: {
19360
19658
  x1: 0,
@@ -19857,7 +20155,7 @@
19857
20155
  return null !== (_a = this._background) && void 0 !== _a ? _a : DefaultConfig.BACKGROUND;
19858
20156
  }
19859
20157
  set background(b) {
19860
- this._background = b;
20158
+ this._background = b, this.syncBackgroundImage(b);
19861
20159
  }
19862
20160
  get defaultLayer() {
19863
20161
  return this.at(0);
@@ -19871,6 +20169,18 @@
19871
20169
  set ticker(ticker) {
19872
20170
  ticker.bindStage(this), this._ticker && this._ticker.removeListener("tick", this.afterTickCb), ticker.addTimeline(this.timeline), this._ticker = ticker, this._ticker.on("tick", this.afterTickCb);
19873
20171
  }
20172
+ syncBackgroundImage(background) {
20173
+ var _a;
20174
+ const source = null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
20175
+ this.backgroundImg = !1, this.isImageBackgroundSource(source) && this.loadImage(source, !0);
20176
+ }
20177
+ isImageBackgroundSource(source) {
20178
+ if (!source) return !1;
20179
+ if ("string" == typeof source) return source.startsWith("<svg") || isValidUrl$1(source) || source.includes("/") || isBase64$1(source);
20180
+ if (!isObject$a(source)) return !1;
20181
+ const gradientSource = source;
20182
+ return "string" != typeof gradientSource.gradient || !Array.isArray(gradientSource.stops);
20183
+ }
19874
20184
  constructor(params = {}) {
19875
20185
  var _a, _b;
19876
20186
  super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
@@ -19909,9 +20219,7 @@
19909
20219
  main: !0
19910
20220
  })), 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 = {
19911
20221
  tickRenderMode: "effect"
19912
- }), this.optmize(params.optimize), params.background && isString$2(this._background) && this._background.includes("/") && this.setAttributes({
19913
- background: this._background
19914
- }), this.initAnimate(params), this.rafId = null !== (_b = params.rafId) && void 0 !== _b ? _b : Math.floor(6 * Math.random());
20222
+ }), 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());
19915
20223
  }
19916
20224
  initAnimate(params) {
19917
20225
  var _a;
@@ -27301,6 +27609,7 @@
27301
27609
  if (custom.prototype.constructor === custom) {
27302
27610
  const descriptor = Object.getOwnPropertyDescriptor(custom, "prototype");
27303
27611
  if (descriptor && !descriptor.writable) return 1;
27612
+ if (Object.getOwnPropertyNames(custom.prototype).length > 1) return 1;
27304
27613
  }
27305
27614
  return 2;
27306
27615
  }
@@ -35460,7 +35769,31 @@
35460
35769
  return graphicCreator.symbol(style);
35461
35770
  }
35462
35771
  _renderHandlerText(value, position) {
35463
- var _a, _b, _c;
35772
+ return graphicCreator.text(this._getHandlerTextAttributes(value, position));
35773
+ }
35774
+ _getHandlerPosition(isStart) {
35775
+ return this.attribute.range && isStart ? "start" : "end";
35776
+ }
35777
+ _getHandlerTextStyle(value, position) {
35778
+ const {
35779
+ align: align,
35780
+ handlerSize = 14,
35781
+ handlerText = {},
35782
+ railHeight: railHeight,
35783
+ railWidth: railWidth,
35784
+ slidable: slidable
35785
+ } = this.attribute;
35786
+ return isFunction$4(handlerText.style) ? handlerText.style(value, position, {
35787
+ layout: this.attribute.layout,
35788
+ align: align,
35789
+ railWidth: railWidth,
35790
+ railHeight: railHeight,
35791
+ handlerSize: handlerSize,
35792
+ slidable: slidable
35793
+ }) : handlerText.style;
35794
+ }
35795
+ _getHandlerTextAttributes(value, position) {
35796
+ var _a, _b;
35464
35797
  const {
35465
35798
  align: align,
35466
35799
  handlerSize = 14,
@@ -35472,13 +35805,13 @@
35472
35805
  isHorizontal = this._isHorizontal,
35473
35806
  pos = this.calculatePosByValue(value, position),
35474
35807
  textSpace = null !== (_a = handlerText.space) && void 0 !== _a ? _a : 4,
35808
+ handlerTextStyle = this._getHandlerTextStyle(value, position),
35475
35809
  textStyle = {
35476
35810
  text: handlerText.formatter ? handlerText.formatter(value) : value.toFixed(null !== (_b = handlerText.precision) && void 0 !== _b ? _b : 0),
35477
- lineHeight: null === (_c = handlerText.style) || void 0 === _c ? void 0 : _c.lineHeight,
35811
+ lineHeight: null == handlerTextStyle ? void 0 : handlerTextStyle.lineHeight,
35478
35812
  cursor: !1 === slidable ? "default" : getDefaultCursor(isHorizontal)
35479
35813
  };
35480
- 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);
35481
- return graphicCreator.text(Object.assign(Object.assign({}, textStyle), handlerText.style));
35814
+ 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);
35482
35815
  }
35483
35816
  _renderTooltip() {
35484
35817
  var _a;
@@ -35606,31 +35939,19 @@
35606
35939
  }
35607
35940
  }
35608
35941
  _updateHandler(handler, position, value) {
35609
- var _a;
35610
35942
  const isHorizontal = this._isHorizontal;
35611
35943
  handler.setAttribute(isHorizontal ? "x" : "y", position);
35612
35944
  const updateHandlerText = handler.name === SLIDER_ELEMENT_NAME.startHandler ? this._startHandlerText : this._endHandlerText;
35613
35945
  if (updateHandlerText) {
35614
- const {
35615
- handlerText = {}
35616
- } = this.attribute;
35617
- updateHandlerText.setAttributes({
35618
- text: handlerText.formatter ? handlerText.formatter(value) : value.toFixed(null !== (_a = handlerText.precision) && void 0 !== _a ? _a : 0),
35619
- [isHorizontal ? "x" : "y"]: position
35620
- });
35946
+ const handlerPosition = this._getHandlerPosition(handler.name === SLIDER_ELEMENT_NAME.startHandler);
35947
+ updateHandlerText.setAttributes(this._getHandlerTextAttributes(value, handlerPosition));
35621
35948
  }
35622
35949
  handler.name === SLIDER_ELEMENT_NAME.startHandler ? (this._currentValue.startValue = value, this._currentValue.startPos = position) : (this._currentValue.endValue = value, this._currentValue.endPos = position);
35623
35950
  }
35624
35951
  _updateHandlerText(handlerText, position, value) {
35625
- var _a;
35626
35952
  const isHorizontal = this._isHorizontal,
35627
- {
35628
- handlerText: handlerTextAttr = {}
35629
- } = this.attribute;
35630
- handlerText.setAttributes({
35631
- [isHorizontal ? "x" : "y"]: position,
35632
- text: handlerTextAttr.formatter ? handlerTextAttr.formatter(value) : value.toFixed(null !== (_a = handlerTextAttr.precision) && void 0 !== _a ? _a : 0)
35633
- });
35953
+ handlerPosition = this._getHandlerPosition(handlerText.name === SLIDER_ELEMENT_NAME.startHandlerText);
35954
+ handlerText.setAttributes(this._getHandlerTextAttributes(value, handlerPosition));
35634
35955
  const updateHandler = handlerText.name === SLIDER_ELEMENT_NAME.startHandlerText ? this._startHandler : this._endHandler;
35635
35956
  updateHandler && updateHandler.setAttributes({
35636
35957
  [isHorizontal ? "x" : "y"]: position
@@ -60380,7 +60701,7 @@
60380
60701
  }
60381
60702
  constructor(container, options = {}) {
60382
60703
  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;
60383
- 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$1.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");
60704
+ 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$1.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");
60384
60705
  this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
60385
60706
  options: options,
60386
60707
  container: container
@@ -91480,7 +91801,7 @@
91480
91801
  importStyle();
91481
91802
  }
91482
91803
 
91483
- const version = "1.22.13-alpha.10";
91804
+ const version = "1.22.13-alpha.11";
91484
91805
  importStyles();
91485
91806
 
91486
91807
  exports.TYPES = index;