@visactor/react-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 +398 -108
- package/build/index.min.js +3 -3
- package/cjs/charts/Histogram3dChart.js +1 -2
- package/cjs/charts/HistogramChart.js +2 -1
- package/cjs/charts/ScatterChart.js +1 -2
- package/cjs/charts/SequenceChart.js +2 -1
- package/cjs/components/MarkArea.js +2 -1
- package/cjs/components/Region.js +1 -2
- package/esm/charts/Histogram3dChart.js +1 -2
- package/esm/charts/HistogramChart.js +2 -1
- package/esm/charts/ScatterChart.js +1 -2
- package/esm/charts/SequenceChart.js +2 -1
- package/esm/components/MarkArea.js +2 -1
- package/esm/components/Region.js +1 -2
- package/package.json +5 -5
package/build/index.js
CHANGED
|
@@ -9936,7 +9936,9 @@
|
|
|
9936
9936
|
background: null,
|
|
9937
9937
|
autoAnimateTexture: !1,
|
|
9938
9938
|
textureRatio: 1,
|
|
9939
|
-
textureOptions:
|
|
9939
|
+
textureOptions: {
|
|
9940
|
+
alignToGraphic: !0
|
|
9941
|
+
},
|
|
9940
9942
|
backgroundOpacity: 1,
|
|
9941
9943
|
backgroundCornerRadius: 0,
|
|
9942
9944
|
texture: null,
|
|
@@ -9950,6 +9952,7 @@
|
|
|
9950
9952
|
backgroundScale: 1,
|
|
9951
9953
|
backgroundOffsetX: 0,
|
|
9952
9954
|
backgroundOffsetY: 0,
|
|
9955
|
+
backgroundPosition: "top-left",
|
|
9953
9956
|
blur: 0,
|
|
9954
9957
|
filter: "",
|
|
9955
9958
|
cursor: null,
|
|
@@ -10122,11 +10125,16 @@
|
|
|
10122
10125
|
const DefaultImageAttribute = Object.assign(Object.assign({
|
|
10123
10126
|
repeatX: "no-repeat",
|
|
10124
10127
|
repeatY: "no-repeat",
|
|
10128
|
+
imageMode: void 0,
|
|
10125
10129
|
image: "",
|
|
10126
10130
|
width: 0,
|
|
10127
10131
|
height: 0,
|
|
10128
10132
|
maxWidth: 500,
|
|
10129
|
-
maxHeight: 500
|
|
10133
|
+
maxHeight: 500,
|
|
10134
|
+
imagePosition: "top-left",
|
|
10135
|
+
imageScale: 1,
|
|
10136
|
+
imageOffsetX: 0,
|
|
10137
|
+
imageOffsetY: 0
|
|
10130
10138
|
}, DefaultAttribute), {
|
|
10131
10139
|
fill: !0,
|
|
10132
10140
|
cornerRadius: 0,
|
|
@@ -15178,7 +15186,8 @@
|
|
|
15178
15186
|
return isString$1(path, !0) ? this.pathProxy = new CustomPath2D().fromString(path) : this.pathProxy = new CustomPath2D(), this.pathProxy;
|
|
15179
15187
|
}
|
|
15180
15188
|
loadImage(image, background = !1) {
|
|
15181
|
-
if (
|
|
15189
|
+
if (background && (null == image ? void 0 : image.background) && (image = image.background), background && (!image || backgroundNotImage(image))) return void (this.backgroundImg = !1);
|
|
15190
|
+
if (!image) return;
|
|
15182
15191
|
const url = image;
|
|
15183
15192
|
this.resources || (this.resources = new Map());
|
|
15184
15193
|
const cache = {
|
|
@@ -15233,7 +15242,7 @@
|
|
|
15233
15242
|
}
|
|
15234
15243
|
}
|
|
15235
15244
|
function backgroundNotImage(image) {
|
|
15236
|
-
return !(!image.fill && !image.stroke);
|
|
15245
|
+
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));
|
|
15237
15246
|
}
|
|
15238
15247
|
function isExternalTexture(texture) {
|
|
15239
15248
|
return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$2(texture));
|
|
@@ -17369,7 +17378,7 @@
|
|
|
17369
17378
|
return [new Paragraph(text1, paragraph.newLine, paragraph.character, paragraph.ascentDescentMode), new Paragraph(text2, !0, paragraph.character, paragraph.ascentDescentMode)];
|
|
17370
17379
|
}
|
|
17371
17380
|
|
|
17372
|
-
const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
17381
|
+
const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", "imageMode", "imagePosition", "imageScale", "imageOffsetX", "imageOffsetY", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
17373
17382
|
class Image extends Graphic {
|
|
17374
17383
|
constructor(params) {
|
|
17375
17384
|
super(params), this.type = "image", this.numberType = IMAGE_NUMBER_TYPE, this.loadImage(this.attribute.image);
|
|
@@ -17474,6 +17483,7 @@
|
|
|
17474
17483
|
}
|
|
17475
17484
|
Image.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
17476
17485
|
image: 1,
|
|
17486
|
+
imageMode: 1,
|
|
17477
17487
|
repeatX: 1,
|
|
17478
17488
|
repeatY: 1
|
|
17479
17489
|
}, NOWORK_ANIMATE_ATTR);
|
|
@@ -18667,11 +18677,12 @@
|
|
|
18667
18677
|
backgroundScale = graphicAttribute.backgroundScale,
|
|
18668
18678
|
backgroundOffsetX = graphicAttribute.backgroundOffsetX,
|
|
18669
18679
|
backgroundOffsetY = graphicAttribute.backgroundOffsetY,
|
|
18670
|
-
backgroundClip = graphicAttribute.backgroundClip
|
|
18680
|
+
backgroundClip = graphicAttribute.backgroundClip,
|
|
18681
|
+
backgroundPosition = graphicAttribute.backgroundPosition
|
|
18671
18682
|
} = graphic.attribute;
|
|
18672
18683
|
if (background) if (graphic.backgroundImg && graphic.resources) {
|
|
18673
|
-
const res = graphic.resources.get(background);
|
|
18674
|
-
if ("success" !== res.state || !res.data) return;
|
|
18684
|
+
const res = graphic.resources.get(getBackgroundImage(background));
|
|
18685
|
+
if (!res || "success" !== res.state || !res.data) return;
|
|
18675
18686
|
if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
|
|
18676
18687
|
const groupAttribute = getTheme$1(graphic.parent).group,
|
|
18677
18688
|
{
|
|
@@ -18688,59 +18699,160 @@
|
|
|
18688
18699
|
backgroundKeepAspectRatio: backgroundKeepAspectRatio,
|
|
18689
18700
|
backgroundScale: backgroundScale,
|
|
18690
18701
|
backgroundOffsetX: backgroundOffsetX,
|
|
18691
|
-
backgroundOffsetY: backgroundOffsetY
|
|
18702
|
+
backgroundOffsetY: backgroundOffsetY,
|
|
18703
|
+
backgroundPosition: backgroundPosition
|
|
18692
18704
|
}), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
|
|
18693
18705
|
} else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
|
|
18694
18706
|
}
|
|
18695
18707
|
doDrawImage(context, data, b, params) {
|
|
18696
|
-
|
|
18697
|
-
backgroundMode: backgroundMode,
|
|
18698
|
-
backgroundFit: backgroundFit,
|
|
18699
|
-
backgroundKeepAspectRatio: backgroundKeepAspectRatio,
|
|
18700
|
-
backgroundScale = 1,
|
|
18701
|
-
backgroundOffsetX = 0,
|
|
18702
|
-
backgroundOffsetY = 0
|
|
18703
|
-
} = params,
|
|
18704
|
-
targetW = b.width(),
|
|
18705
|
-
targetH = b.height();
|
|
18706
|
-
let w = targetW,
|
|
18707
|
-
h = targetH;
|
|
18708
|
-
if ("no-repeat" === backgroundMode) {
|
|
18709
|
-
if (backgroundFit) {
|
|
18710
|
-
if (backgroundKeepAspectRatio) {
|
|
18711
|
-
const maxScale = Math.max(targetW / data.width, targetH / data.height);
|
|
18712
|
-
context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
|
|
18713
|
-
} else context.drawImage(data, b.x1, b.y1, b.width(), b.height());
|
|
18714
|
-
} else {
|
|
18715
|
-
const resW = data.width * backgroundScale,
|
|
18716
|
-
resH = data.height * backgroundScale;
|
|
18717
|
-
context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
|
|
18718
|
-
}
|
|
18719
|
-
} else {
|
|
18720
|
-
if (backgroundFit && "repeat" !== backgroundMode && (data.width || data.height)) {
|
|
18721
|
-
const resW = data.width,
|
|
18722
|
-
resH = data.height;
|
|
18723
|
-
if ("repeat-x" === backgroundMode) {
|
|
18724
|
-
w = resW * (targetH / resH), h = targetH;
|
|
18725
|
-
} else if ("repeat-y" === backgroundMode) {
|
|
18726
|
-
h = resH * (targetW / resW), w = targetW;
|
|
18727
|
-
}
|
|
18728
|
-
const dpr = context.dpr,
|
|
18729
|
-
canvas = canvasAllocate.allocate({
|
|
18730
|
-
width: w,
|
|
18731
|
-
height: h,
|
|
18732
|
-
dpr: dpr
|
|
18733
|
-
}),
|
|
18734
|
-
ctx = canvas.getContext("2d");
|
|
18735
|
-
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);
|
|
18736
|
-
}
|
|
18737
|
-
const dpr = context.dpr,
|
|
18738
|
-
pattern = context.createPattern(data, backgroundMode);
|
|
18739
|
-
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);
|
|
18740
|
-
}
|
|
18708
|
+
drawBackgroundImage(context, data, b, params);
|
|
18741
18709
|
}
|
|
18742
18710
|
}
|
|
18743
18711
|
const defaultBaseBackgroundRenderContribution = new DefaultBaseBackgroundRenderContribution();
|
|
18712
|
+
const verticalPositionKeywords = new Set(["top", "center", "bottom"]);
|
|
18713
|
+
function getBackgroundImage(background) {
|
|
18714
|
+
var _a;
|
|
18715
|
+
return null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
|
|
18716
|
+
}
|
|
18717
|
+
function resolveBackgroundSizing({
|
|
18718
|
+
backgroundFit: backgroundFit,
|
|
18719
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio
|
|
18720
|
+
}) {
|
|
18721
|
+
return backgroundFit ? backgroundKeepAspectRatio ? "cover" : "fill" : "auto";
|
|
18722
|
+
}
|
|
18723
|
+
const NO_REPEAT_SIZING_MAP = {
|
|
18724
|
+
"no-repeat-cover": "cover",
|
|
18725
|
+
"no-repeat-contain": "contain",
|
|
18726
|
+
"no-repeat-fill": "fill",
|
|
18727
|
+
"no-repeat-auto": "auto"
|
|
18728
|
+
};
|
|
18729
|
+
function resolveBackgroundDrawMode({
|
|
18730
|
+
backgroundMode: backgroundMode,
|
|
18731
|
+
backgroundFit: backgroundFit,
|
|
18732
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio
|
|
18733
|
+
}) {
|
|
18734
|
+
const sizing = NO_REPEAT_SIZING_MAP[backgroundMode];
|
|
18735
|
+
return sizing ? {
|
|
18736
|
+
backgroundRepeatMode: "no-repeat",
|
|
18737
|
+
backgroundSizing: sizing
|
|
18738
|
+
} : {
|
|
18739
|
+
backgroundRepeatMode: backgroundMode,
|
|
18740
|
+
backgroundSizing: resolveBackgroundSizing({
|
|
18741
|
+
backgroundFit: backgroundFit,
|
|
18742
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio
|
|
18743
|
+
})
|
|
18744
|
+
};
|
|
18745
|
+
}
|
|
18746
|
+
function isPercentageValue(value) {
|
|
18747
|
+
return /^-?\d+(\.\d+)?%$/.test(value);
|
|
18748
|
+
}
|
|
18749
|
+
function parsePositionToken(value, remainSpace, startKeyword, centerKeyword, endKeyword) {
|
|
18750
|
+
if ("number" == typeof value && Number.isFinite(value)) return value;
|
|
18751
|
+
const normalizedValue = `${null != value ? value : ""}`.trim().toLowerCase();
|
|
18752
|
+
if (!normalizedValue || normalizedValue === startKeyword) return 0;
|
|
18753
|
+
if (normalizedValue === centerKeyword) return remainSpace / 2;
|
|
18754
|
+
if (normalizedValue === endKeyword) return remainSpace;
|
|
18755
|
+
if (isPercentageValue(normalizedValue)) return remainSpace * parseFloat(normalizedValue) / 100;
|
|
18756
|
+
const parsedValue = Number(normalizedValue);
|
|
18757
|
+
return Number.isFinite(parsedValue) ? parsedValue : 0;
|
|
18758
|
+
}
|
|
18759
|
+
function normalizeBackgroundPosition(position) {
|
|
18760
|
+
var _a, _b;
|
|
18761
|
+
if (Array.isArray(position)) return [null !== (_a = position[0]) && void 0 !== _a ? _a : "left", null !== (_b = position[1]) && void 0 !== _b ? _b : "top"];
|
|
18762
|
+
const tokens = `${null != position ? position : "top-left"}`.trim().toLowerCase().replace(/-/g, " ").split(/\s+/).filter(Boolean);
|
|
18763
|
+
if (0 === tokens.length) return ["left", "top"];
|
|
18764
|
+
if (1 === tokens.length) {
|
|
18765
|
+
const token = tokens[0];
|
|
18766
|
+
return "center" === token ? ["center", "center"] : verticalPositionKeywords.has(token) ? ["center", token] : [token, "center"];
|
|
18767
|
+
}
|
|
18768
|
+
let horizontal, vertical;
|
|
18769
|
+
const genericTokens = [];
|
|
18770
|
+
for (let i = 0; i < 2; i++) {
|
|
18771
|
+
const token = tokens[i];
|
|
18772
|
+
"left" !== token && "right" !== token ? "top" !== token && "bottom" !== token ? genericTokens.push(token) : vertical = token : horizontal = token;
|
|
18773
|
+
}
|
|
18774
|
+
return null == horizontal && genericTokens.length && (horizontal = genericTokens.shift()), null == vertical && genericTokens.length && (vertical = genericTokens.shift()), [null != horizontal ? horizontal : "left", null != vertical ? vertical : "top"];
|
|
18775
|
+
}
|
|
18776
|
+
function resolveBackgroundPosition(position, remainWidth, remainHeight) {
|
|
18777
|
+
const [horizontalPosition, verticalPosition] = normalizeBackgroundPosition(position);
|
|
18778
|
+
return {
|
|
18779
|
+
x: parsePositionToken(horizontalPosition, remainWidth, "left", "center", "right"),
|
|
18780
|
+
y: parsePositionToken(verticalPosition, remainHeight, "top", "center", "bottom")
|
|
18781
|
+
};
|
|
18782
|
+
}
|
|
18783
|
+
function pickRenderableDimension(...values) {
|
|
18784
|
+
for (const value of values) if ("number" == typeof value && Number.isFinite(value) && value > 0) return value;
|
|
18785
|
+
return null;
|
|
18786
|
+
}
|
|
18787
|
+
function resolveRenderableImageSize(data) {
|
|
18788
|
+
if (!data) return null;
|
|
18789
|
+
const width = pickRenderableDimension(data.naturalWidth, data.videoWidth, data.width),
|
|
18790
|
+
height = pickRenderableDimension(data.naturalHeight, data.videoHeight, data.height);
|
|
18791
|
+
return null == width || null == height ? null : {
|
|
18792
|
+
width: width,
|
|
18793
|
+
height: height
|
|
18794
|
+
};
|
|
18795
|
+
}
|
|
18796
|
+
function drawBackgroundImage(context, data, b, params) {
|
|
18797
|
+
var _a, _b;
|
|
18798
|
+
const {
|
|
18799
|
+
backgroundMode: backgroundMode,
|
|
18800
|
+
backgroundFit: backgroundFit,
|
|
18801
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio,
|
|
18802
|
+
backgroundScale = 1,
|
|
18803
|
+
backgroundOffsetX = 0,
|
|
18804
|
+
backgroundOffsetY = 0,
|
|
18805
|
+
backgroundPosition = "top-left"
|
|
18806
|
+
} = params,
|
|
18807
|
+
targetW = b.width(),
|
|
18808
|
+
targetH = b.height(),
|
|
18809
|
+
sourceSize = resolveRenderableImageSize(data),
|
|
18810
|
+
{
|
|
18811
|
+
backgroundRepeatMode: backgroundRepeatMode,
|
|
18812
|
+
backgroundSizing: resolvedBackgroundSizing
|
|
18813
|
+
} = resolveBackgroundDrawMode({
|
|
18814
|
+
backgroundMode: backgroundMode,
|
|
18815
|
+
backgroundFit: backgroundFit,
|
|
18816
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio
|
|
18817
|
+
});
|
|
18818
|
+
let w = targetW,
|
|
18819
|
+
h = targetH;
|
|
18820
|
+
if (targetW <= 0 || targetH <= 0) return;
|
|
18821
|
+
if ("no-repeat" === backgroundRepeatMode) {
|
|
18822
|
+
let drawWidth = null !== (_a = null == sourceSize ? void 0 : sourceSize.width) && void 0 !== _a ? _a : targetW,
|
|
18823
|
+
drawHeight = null !== (_b = null == sourceSize ? void 0 : sourceSize.height) && void 0 !== _b ? _b : targetH;
|
|
18824
|
+
if ("cover" !== resolvedBackgroundSizing && "contain" !== resolvedBackgroundSizing || !sourceSize) "fill" === resolvedBackgroundSizing && (drawWidth = targetW, drawHeight = targetH);else {
|
|
18825
|
+
const scale = "cover" === resolvedBackgroundSizing ? Math.max(targetW / sourceSize.width, targetH / sourceSize.height) : Math.min(targetW / sourceSize.width, targetH / sourceSize.height);
|
|
18826
|
+
drawWidth = sourceSize.width * scale, drawHeight = sourceSize.height * scale;
|
|
18827
|
+
}
|
|
18828
|
+
drawWidth *= backgroundScale, drawHeight *= backgroundScale;
|
|
18829
|
+
const {
|
|
18830
|
+
x: x,
|
|
18831
|
+
y: y
|
|
18832
|
+
} = resolveBackgroundPosition(backgroundPosition, targetW - drawWidth, targetH - drawHeight);
|
|
18833
|
+
return void context.drawImage(data, b.x1 + x + backgroundOffsetX, b.y1 + y + backgroundOffsetY, drawWidth, drawHeight);
|
|
18834
|
+
}
|
|
18835
|
+
if (backgroundFit && "repeat" !== backgroundRepeatMode && sourceSize) {
|
|
18836
|
+
const resW = sourceSize.width,
|
|
18837
|
+
resH = sourceSize.height;
|
|
18838
|
+
if ("repeat-x" === backgroundRepeatMode) {
|
|
18839
|
+
w = resW * (targetH / resH), h = targetH;
|
|
18840
|
+
} else if ("repeat-y" === backgroundRepeatMode) {
|
|
18841
|
+
h = resH * (targetW / resW), w = targetW;
|
|
18842
|
+
}
|
|
18843
|
+
const dpr = context.dpr,
|
|
18844
|
+
canvas = canvasAllocate.allocate({
|
|
18845
|
+
width: w,
|
|
18846
|
+
height: h,
|
|
18847
|
+
dpr: dpr
|
|
18848
|
+
}),
|
|
18849
|
+
ctx = canvas.getContext("2d");
|
|
18850
|
+
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);
|
|
18851
|
+
}
|
|
18852
|
+
const dpr = context.dpr,
|
|
18853
|
+
pattern = context.createPattern(data, backgroundRepeatMode);
|
|
18854
|
+
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);
|
|
18855
|
+
}
|
|
18744
18856
|
let DefaultBaseInteractiveRenderContribution = class {
|
|
18745
18857
|
constructor(subRenderContribitions) {
|
|
18746
18858
|
this.subRenderContribitions = subRenderContribitions, this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
|
|
@@ -18899,13 +19011,14 @@
|
|
|
18899
19011
|
texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
|
|
18900
19012
|
}
|
|
18901
19013
|
drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
|
|
18902
|
-
var _a;
|
|
19014
|
+
var _a, _b, _c, _d, _e, _f;
|
|
18903
19015
|
const {
|
|
18904
19016
|
textureRatio = graphicAttribute.textureRatio,
|
|
18905
19017
|
textureOptions = null
|
|
18906
19018
|
} = graphic.attribute;
|
|
18907
19019
|
let pattern = null;
|
|
18908
|
-
const
|
|
19020
|
+
const textureRadius = null !== (_a = null == textureOptions ? void 0 : textureOptions.radius) && void 0 !== _a ? _a : 0,
|
|
19021
|
+
patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr, textureRadius);
|
|
18909
19022
|
if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
|
|
18910
19023
|
if ("string" == typeof texture) switch (texture) {
|
|
18911
19024
|
case "circle":
|
|
@@ -18932,7 +19045,7 @@
|
|
|
18932
19045
|
case "grid":
|
|
18933
19046
|
pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
|
|
18934
19047
|
}
|
|
18935
|
-
pattern || (pattern = this.createResourcePattern(texture, graphic, context)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
|
|
19048
|
+
pattern || (pattern = this.createResourcePattern(texture, graphic, context, texturePadding, textureRadius)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
|
|
18936
19049
|
}
|
|
18937
19050
|
if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
|
|
18938
19051
|
const {
|
|
@@ -18979,10 +19092,24 @@
|
|
|
18979
19092
|
for (let i = 0; i < gridRows; i++) for (let j = 0; j < gridColumns; j++) {
|
|
18980
19093
|
const _x = x + cellSize / 2 + j * cellSize,
|
|
18981
19094
|
_y = y + cellSize / 2 + i * cellSize;
|
|
18982
|
-
null === (
|
|
19095
|
+
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());
|
|
18983
19096
|
}
|
|
18984
19097
|
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();
|
|
18985
|
-
} else if (pattern)
|
|
19098
|
+
} else if (pattern) {
|
|
19099
|
+
if (pattern.setTransform) {
|
|
19100
|
+
const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
|
|
19101
|
+
alignOffsetX = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _c ? _c : 0,
|
|
19102
|
+
alignOffsetY = null !== (_d = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _d ? _d : 0;
|
|
19103
|
+
let translateX = 0,
|
|
19104
|
+
translateY = 0;
|
|
19105
|
+
if (alignToGraphic) {
|
|
19106
|
+
const m = context.currentMatrix;
|
|
19107
|
+
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;
|
|
19108
|
+
} else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
|
|
19109
|
+
pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
|
|
19110
|
+
}
|
|
19111
|
+
context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
|
|
19112
|
+
} else if ("wave" === texture) {
|
|
18986
19113
|
context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
|
|
18987
19114
|
const b = graphic.AABBBounds;
|
|
18988
19115
|
drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
|
|
@@ -18990,14 +19117,42 @@
|
|
|
18990
19117
|
}), x + b.x1 - x, y + b.y1 - y), context.restore();
|
|
18991
19118
|
}
|
|
18992
19119
|
}
|
|
18993
|
-
getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr) {
|
|
18994
|
-
return "string" != typeof texture ? texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
|
|
19120
|
+
getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr, textureRadius) {
|
|
19121
|
+
return "string" != typeof texture ? texturePadding > 0 || textureRadius > 0 ? null : texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
|
|
18995
19122
|
}
|
|
18996
|
-
createResourcePattern(texture, graphic, context) {
|
|
19123
|
+
createResourcePattern(texture, graphic, context, texturePadding, textureRadius) {
|
|
18997
19124
|
var _a;
|
|
18998
19125
|
const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
|
|
18999
19126
|
data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
|
|
19000
19127
|
if (!data) return null;
|
|
19128
|
+
if (texturePadding > 0 || textureRadius > 0) {
|
|
19129
|
+
const w = data.naturalWidth || data.width,
|
|
19130
|
+
h = data.naturalHeight || data.height;
|
|
19131
|
+
if (w > 0 && h > 0) {
|
|
19132
|
+
const tileW = w + 2 * texturePadding,
|
|
19133
|
+
tileH = h + 2 * texturePadding,
|
|
19134
|
+
canvas = canvasAllocate.allocate({
|
|
19135
|
+
width: tileW,
|
|
19136
|
+
height: tileH,
|
|
19137
|
+
dpr: context.dpr
|
|
19138
|
+
}),
|
|
19139
|
+
ctx = canvas.getContext("2d");
|
|
19140
|
+
if (ctx) {
|
|
19141
|
+
if (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, tileW, tileH), textureRadius > 0) {
|
|
19142
|
+
const r = Math.max(0, Math.min(textureRadius, Math.min(w, h) / 2)),
|
|
19143
|
+
x0 = texturePadding,
|
|
19144
|
+
y0 = texturePadding,
|
|
19145
|
+
x1 = x0 + w,
|
|
19146
|
+
y1 = y0 + h;
|
|
19147
|
+
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();
|
|
19148
|
+
}
|
|
19149
|
+
ctx.drawImage(data, texturePadding, texturePadding, w, h);
|
|
19150
|
+
const pattern = context.createPattern(canvas.nativeCanvas, "repeat");
|
|
19151
|
+
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;
|
|
19152
|
+
}
|
|
19153
|
+
canvasAllocate.free(canvas);
|
|
19154
|
+
}
|
|
19155
|
+
}
|
|
19001
19156
|
const pattern = context.createPattern(data, "repeat");
|
|
19002
19157
|
return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
|
|
19003
19158
|
}
|
|
@@ -19112,27 +19267,32 @@
|
|
|
19112
19267
|
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
|
|
19113
19268
|
const {
|
|
19114
19269
|
background: background,
|
|
19270
|
+
backgroundOpacity = graphicAttribute.backgroundOpacity,
|
|
19271
|
+
opacity = graphicAttribute.opacity,
|
|
19115
19272
|
backgroundMode = graphicAttribute.backgroundMode,
|
|
19116
19273
|
backgroundFit = graphicAttribute.backgroundFit,
|
|
19117
19274
|
backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
|
|
19118
19275
|
backgroundScale = graphicAttribute.backgroundScale,
|
|
19119
19276
|
backgroundOffsetX = graphicAttribute.backgroundOffsetX,
|
|
19120
|
-
backgroundOffsetY = graphicAttribute.backgroundOffsetY
|
|
19277
|
+
backgroundOffsetY = graphicAttribute.backgroundOffsetY,
|
|
19278
|
+
backgroundClip = graphicAttribute.backgroundClip,
|
|
19279
|
+
backgroundPosition = graphicAttribute.backgroundPosition
|
|
19121
19280
|
} = graphic.attribute;
|
|
19122
19281
|
if (background) if (graphic.backgroundImg && graphic.resources) {
|
|
19123
|
-
const res = graphic.resources.get(background);
|
|
19124
|
-
if ("success" !== res.state || !res.data) return;
|
|
19282
|
+
const res = graphic.resources.get(getBackgroundImage(background));
|
|
19283
|
+
if (!res || "success" !== res.state || !res.data) return;
|
|
19125
19284
|
context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0);
|
|
19126
19285
|
const b = graphic.AABBBounds;
|
|
19127
|
-
this.doDrawImage(context, res.data, b, {
|
|
19286
|
+
context.globalAlpha = backgroundOpacity * opacity, backgroundClip && context.clip(), this.doDrawImage(context, res.data, b, {
|
|
19128
19287
|
backgroundMode: backgroundMode,
|
|
19129
19288
|
backgroundFit: backgroundFit,
|
|
19130
19289
|
backgroundKeepAspectRatio: backgroundKeepAspectRatio,
|
|
19131
19290
|
backgroundScale: backgroundScale,
|
|
19132
19291
|
backgroundOffsetX: backgroundOffsetX,
|
|
19133
|
-
backgroundOffsetY: backgroundOffsetY
|
|
19292
|
+
backgroundOffsetY: backgroundOffsetY,
|
|
19293
|
+
backgroundPosition: backgroundPosition
|
|
19134
19294
|
}), context.highPerformanceRestore(), context.setTransformForCurrent();
|
|
19135
|
-
} else context.highPerformanceSave(), context.fillStyle = background, context.fill(), context.highPerformanceRestore();
|
|
19295
|
+
} else context.highPerformanceSave(), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
|
|
19136
19296
|
}
|
|
19137
19297
|
}
|
|
19138
19298
|
const defaultGroupBackgroundRenderContribution = new DefaultGroupBackgroundRenderContribution();
|
|
@@ -20614,9 +20774,17 @@
|
|
|
20614
20774
|
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
|
|
20615
20775
|
var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
20616
20776
|
const {
|
|
20777
|
+
backgroundOpacity = graphicAttribute.backgroundOpacity,
|
|
20778
|
+
opacity = graphicAttribute.opacity,
|
|
20617
20779
|
backgroundMode = graphicAttribute.backgroundMode,
|
|
20618
20780
|
backgroundFit = graphicAttribute.backgroundFit,
|
|
20619
|
-
backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio
|
|
20781
|
+
backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
|
|
20782
|
+
backgroundScale = graphicAttribute.backgroundScale,
|
|
20783
|
+
backgroundOffsetX = graphicAttribute.backgroundOffsetX,
|
|
20784
|
+
backgroundOffsetY = graphicAttribute.backgroundOffsetY,
|
|
20785
|
+
backgroundPosition = graphicAttribute.backgroundPosition,
|
|
20786
|
+
backgroundClip = graphicAttribute.backgroundClip,
|
|
20787
|
+
backgroundCornerRadius = graphicAttribute.backgroundCornerRadius
|
|
20620
20788
|
} = graphic.attribute;
|
|
20621
20789
|
let matrix,
|
|
20622
20790
|
{
|
|
@@ -20628,18 +20796,18 @@
|
|
|
20628
20796
|
};
|
|
20629
20797
|
let b;
|
|
20630
20798
|
"richtext" === graphic.type && (matrix = context.currentMatrix.clone(), context.restore(), context.save(), context.setTransformForCurrent());
|
|
20631
|
-
const
|
|
20799
|
+
const backgroundConfig = isObject$2(background) && background.background ? background : null,
|
|
20632
20800
|
onlyTranslate = graphic.transMatrix.onlyTranslate();
|
|
20633
|
-
if (
|
|
20801
|
+
if (backgroundConfig) {
|
|
20634
20802
|
const _b = graphic.AABBBounds,
|
|
20635
|
-
x = (null !== (_a =
|
|
20636
|
-
y = (null !== (_d =
|
|
20637
|
-
w = null !== (_f =
|
|
20638
|
-
h = null !== (_g =
|
|
20639
|
-
if (b = boundsAllocate.allocate(x, y, x + w, y + h), background =
|
|
20803
|
+
x = (null !== (_a = backgroundConfig.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = backgroundConfig.dx) && void 0 !== _c ? _c : 0),
|
|
20804
|
+
y = (null !== (_d = backgroundConfig.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = backgroundConfig.dy) && void 0 !== _e ? _e : 0),
|
|
20805
|
+
w = null !== (_f = backgroundConfig.width) && void 0 !== _f ? _f : _b.width(),
|
|
20806
|
+
h = null !== (_g = backgroundConfig.height) && void 0 !== _g ? _g : _b.height();
|
|
20807
|
+
if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = backgroundConfig.background, !onlyTranslate) {
|
|
20640
20808
|
const w = b.width(),
|
|
20641
20809
|
h = b.height();
|
|
20642
|
-
b.set((null !== (_h =
|
|
20810
|
+
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);
|
|
20643
20811
|
}
|
|
20644
20812
|
} else b = graphic.AABBBounds, onlyTranslate || (b = getTextBounds(Object.assign(Object.assign({}, graphic.attribute), {
|
|
20645
20813
|
angle: 0,
|
|
@@ -20652,20 +20820,18 @@
|
|
|
20652
20820
|
})).clone());
|
|
20653
20821
|
if (graphic.backgroundImg && graphic.resources) {
|
|
20654
20822
|
const res = graphic.resources.get(background);
|
|
20655
|
-
if ("success" !== res.state || !res.data) return void restore();
|
|
20656
|
-
context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.
|
|
20823
|
+
if (!res || "success" !== res.state || !res.data) return void restore();
|
|
20824
|
+
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, {
|
|
20657
20825
|
backgroundMode: backgroundMode,
|
|
20658
20826
|
backgroundFit: backgroundFit,
|
|
20659
|
-
backgroundKeepAspectRatio: backgroundKeepAspectRatio
|
|
20827
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio,
|
|
20828
|
+
backgroundScale: backgroundScale,
|
|
20829
|
+
backgroundOffsetX: backgroundOffsetX,
|
|
20830
|
+
backgroundOffsetY: backgroundOffsetY,
|
|
20831
|
+
backgroundPosition: backgroundPosition
|
|
20660
20832
|
}), context.highPerformanceRestore(), context.setTransformForCurrent();
|
|
20661
|
-
} else
|
|
20662
|
-
|
|
20663
|
-
backgroundCornerRadius: backgroundCornerRadius,
|
|
20664
|
-
backgroundOpacity = 1
|
|
20665
|
-
} = graphic.attribute;
|
|
20666
|
-
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();
|
|
20667
|
-
}
|
|
20668
|
-
shouldReCalBounds && boundsAllocate.free(b), restore();
|
|
20833
|
+
} 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();
|
|
20834
|
+
backgroundConfig && boundsAllocate.free(b), restore();
|
|
20669
20835
|
}
|
|
20670
20836
|
}
|
|
20671
20837
|
const defaultTextBackgroundRenderContribution = new DefaultTextBackgroundRenderContribution();
|
|
@@ -21092,6 +21258,92 @@
|
|
|
21092
21258
|
};
|
|
21093
21259
|
};
|
|
21094
21260
|
const repeatStr = ["", "repeat-x", "repeat-y", "repeat"];
|
|
21261
|
+
function resolveImageMode({
|
|
21262
|
+
repeatX = "no-repeat",
|
|
21263
|
+
repeatY = "no-repeat",
|
|
21264
|
+
imageMode: imageMode
|
|
21265
|
+
}) {
|
|
21266
|
+
const repeatMode = resolveImageRepeatMode(repeatX, repeatY);
|
|
21267
|
+
return {
|
|
21268
|
+
repeatMode: repeatMode,
|
|
21269
|
+
sizingMode: "no-repeat" === repeatMode && null != imageMode ? imageMode : "fill"
|
|
21270
|
+
};
|
|
21271
|
+
}
|
|
21272
|
+
const IMAGE_MODE_TO_BACKGROUND_MODE = {
|
|
21273
|
+
cover: "no-repeat-cover",
|
|
21274
|
+
contain: "no-repeat-contain",
|
|
21275
|
+
fill: "no-repeat-fill",
|
|
21276
|
+
auto: "no-repeat-auto"
|
|
21277
|
+
};
|
|
21278
|
+
function resolveBackgroundParamsByImageSizing(sizingMode) {
|
|
21279
|
+
return {
|
|
21280
|
+
backgroundMode: IMAGE_MODE_TO_BACKGROUND_MODE[sizingMode],
|
|
21281
|
+
backgroundFit: !1,
|
|
21282
|
+
backgroundKeepAspectRatio: !1
|
|
21283
|
+
};
|
|
21284
|
+
}
|
|
21285
|
+
function resolveImageRepeatMode(repeatX, repeatY) {
|
|
21286
|
+
let repeat = 0;
|
|
21287
|
+
return "repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat ? repeatStr[repeat] : "no-repeat";
|
|
21288
|
+
}
|
|
21289
|
+
function shouldClipImageByLayout({
|
|
21290
|
+
repeatX = "no-repeat",
|
|
21291
|
+
repeatY = "no-repeat",
|
|
21292
|
+
imageMode: imageMode,
|
|
21293
|
+
imageScale = 1,
|
|
21294
|
+
imageOffsetX = 0,
|
|
21295
|
+
imageOffsetY = 0,
|
|
21296
|
+
imagePosition = "top-left"
|
|
21297
|
+
}) {
|
|
21298
|
+
const {
|
|
21299
|
+
repeatMode: repeatMode,
|
|
21300
|
+
sizingMode: sizingMode
|
|
21301
|
+
} = resolveImageMode({
|
|
21302
|
+
repeatX: repeatX,
|
|
21303
|
+
repeatY: repeatY,
|
|
21304
|
+
imageMode: imageMode
|
|
21305
|
+
});
|
|
21306
|
+
return "no-repeat" === repeatMode && ("cover" === sizingMode || "auto" === sizingMode || 1 !== imageScale || 0 !== imageOffsetX || 0 !== imageOffsetY);
|
|
21307
|
+
}
|
|
21308
|
+
function drawImageWithLayout(context, data, x, y, width, height, {
|
|
21309
|
+
repeatX = "no-repeat",
|
|
21310
|
+
repeatY = "no-repeat",
|
|
21311
|
+
imageMode: imageMode,
|
|
21312
|
+
imageScale = 1,
|
|
21313
|
+
imageOffsetX = 0,
|
|
21314
|
+
imageOffsetY = 0,
|
|
21315
|
+
imagePosition = "top-left"
|
|
21316
|
+
}) {
|
|
21317
|
+
const {
|
|
21318
|
+
repeatMode: repeatMode,
|
|
21319
|
+
sizingMode: sizingMode
|
|
21320
|
+
} = resolveImageMode({
|
|
21321
|
+
repeatX: repeatX,
|
|
21322
|
+
repeatY: repeatY,
|
|
21323
|
+
imageMode: imageMode
|
|
21324
|
+
}),
|
|
21325
|
+
imageBackgroundParams = "no-repeat" === repeatMode ? resolveBackgroundParamsByImageSizing(sizingMode) : {
|
|
21326
|
+
backgroundMode: repeatMode,
|
|
21327
|
+
backgroundFit: !1,
|
|
21328
|
+
backgroundKeepAspectRatio: !1
|
|
21329
|
+
};
|
|
21330
|
+
drawBackgroundImage(context, data, {
|
|
21331
|
+
x1: x,
|
|
21332
|
+
y1: y,
|
|
21333
|
+
x2: x + width,
|
|
21334
|
+
y2: y + height,
|
|
21335
|
+
width: () => width,
|
|
21336
|
+
height: () => height
|
|
21337
|
+
}, {
|
|
21338
|
+
backgroundMode: imageBackgroundParams.backgroundMode,
|
|
21339
|
+
backgroundFit: imageBackgroundParams.backgroundFit,
|
|
21340
|
+
backgroundKeepAspectRatio: imageBackgroundParams.backgroundKeepAspectRatio,
|
|
21341
|
+
backgroundScale: imageScale,
|
|
21342
|
+
backgroundOffsetX: imageOffsetX,
|
|
21343
|
+
backgroundOffsetY: imageOffsetY,
|
|
21344
|
+
backgroundPosition: imagePosition
|
|
21345
|
+
});
|
|
21346
|
+
}
|
|
21095
21347
|
let DefaultCanvasImageRender = class extends BaseRender {
|
|
21096
21348
|
constructor(graphicRenderContributions) {
|
|
21097
21349
|
super(), this.graphicRenderContributions = graphicRenderContributions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution], this.init(graphicRenderContributions);
|
|
@@ -21106,6 +21358,11 @@
|
|
|
21106
21358
|
cornerRadius = imageAttribute.cornerRadius,
|
|
21107
21359
|
fillStrokeOrder = imageAttribute.fillStrokeOrder,
|
|
21108
21360
|
cornerType = imageAttribute.cornerType,
|
|
21361
|
+
imageMode = imageAttribute.imageMode,
|
|
21362
|
+
imageScale = imageAttribute.imageScale,
|
|
21363
|
+
imageOffsetX = imageAttribute.imageOffsetX,
|
|
21364
|
+
imageOffsetY = imageAttribute.imageOffsetY,
|
|
21365
|
+
imagePosition = imageAttribute.imagePosition,
|
|
21109
21366
|
image: url
|
|
21110
21367
|
} = image.attribute,
|
|
21111
21368
|
data = this.valid(image, imageAttribute, fillCb);
|
|
@@ -21122,22 +21379,33 @@
|
|
|
21122
21379
|
const width = image.width,
|
|
21123
21380
|
height = image.height;
|
|
21124
21381
|
context.beginPath();
|
|
21125
|
-
let
|
|
21126
|
-
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),
|
|
21382
|
+
let needCornerClip = !1;
|
|
21383
|
+
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);
|
|
21127
21384
|
const _runFill = () => {
|
|
21128
|
-
|
|
21129
|
-
|
|
21130
|
-
|
|
21131
|
-
|
|
21132
|
-
|
|
21133
|
-
|
|
21134
|
-
|
|
21135
|
-
|
|
21385
|
+
doFill && (fillCb ? fillCb(context, image.attribute, imageAttribute) : fVisible && (context.setCommonStyle(image, image.attribute, x, y, imageAttribute), drawImageWithLayout(context, res.data, x, y, width, height, {
|
|
21386
|
+
repeatX: repeatX,
|
|
21387
|
+
repeatY: repeatY,
|
|
21388
|
+
imageMode: imageMode,
|
|
21389
|
+
imageScale: imageScale,
|
|
21390
|
+
imageOffsetX: imageOffsetX,
|
|
21391
|
+
imageOffsetY: imageOffsetY,
|
|
21392
|
+
imagePosition: imagePosition
|
|
21393
|
+
})));
|
|
21136
21394
|
},
|
|
21137
21395
|
_runStroke = () => {
|
|
21138
21396
|
doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
|
|
21139
|
-
}
|
|
21140
|
-
|
|
21397
|
+
},
|
|
21398
|
+
needLayoutClip = shouldClipImageByLayout({
|
|
21399
|
+
repeatX: repeatX,
|
|
21400
|
+
repeatY: repeatY,
|
|
21401
|
+
imageMode: imageMode,
|
|
21402
|
+
imageScale: imageScale,
|
|
21403
|
+
imageOffsetX: imageOffsetX,
|
|
21404
|
+
imageOffsetY: imageOffsetY,
|
|
21405
|
+
imagePosition: imagePosition
|
|
21406
|
+
}),
|
|
21407
|
+
needClip = needCornerClip || needLayoutClip;
|
|
21408
|
+
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);
|
|
21141
21409
|
}
|
|
21142
21410
|
draw(image, renderService, drawContext) {
|
|
21143
21411
|
const {
|
|
@@ -21996,7 +22264,7 @@
|
|
|
21996
22264
|
return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);
|
|
21997
22265
|
}
|
|
21998
22266
|
clearScreen(renderService, context, drawContext) {
|
|
21999
|
-
var _a, _b, _c;
|
|
22267
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
22000
22268
|
const {
|
|
22001
22269
|
clear: clear,
|
|
22002
22270
|
viewBox: viewBox
|
|
@@ -22006,9 +22274,20 @@
|
|
|
22006
22274
|
if (clear) {
|
|
22007
22275
|
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);
|
|
22008
22276
|
const stage = null === (_b = renderService.drawParams) || void 0 === _b ? void 0 : _b.stage;
|
|
22009
|
-
if (stage && (context.globalAlpha = null !== (_c = stage.attribute.opacity) && void 0 !== _c ? _c : 1), stage && stage.backgroundImg && stage.resources) {
|
|
22010
|
-
const res = stage.resources.get(clear);
|
|
22011
|
-
res && "success" === res.state && res.data
|
|
22277
|
+
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) {
|
|
22278
|
+
const res = stage.resources.get(getBackgroundImage(clear));
|
|
22279
|
+
if (res && "success" === res.state && res.data) {
|
|
22280
|
+
const backgroundBounds = boundsAllocate.allocate(0, 0, 0 + width, 0 + height);
|
|
22281
|
+
drawBackgroundImage(context, res.data, backgroundBounds, {
|
|
22282
|
+
backgroundMode: null !== (_e = stage.attribute.backgroundMode) && void 0 !== _e ? _e : DefaultAttribute.backgroundMode,
|
|
22283
|
+
backgroundFit: null !== (_f = stage.attribute.backgroundFit) && void 0 !== _f ? _f : DefaultAttribute.backgroundFit,
|
|
22284
|
+
backgroundKeepAspectRatio: null !== (_g = stage.attribute.backgroundKeepAspectRatio) && void 0 !== _g ? _g : DefaultAttribute.backgroundKeepAspectRatio,
|
|
22285
|
+
backgroundScale: null !== (_h = stage.attribute.backgroundScale) && void 0 !== _h ? _h : DefaultAttribute.backgroundScale,
|
|
22286
|
+
backgroundOffsetX: null !== (_j = stage.attribute.backgroundOffsetX) && void 0 !== _j ? _j : DefaultAttribute.backgroundOffsetX,
|
|
22287
|
+
backgroundOffsetY: null !== (_k = stage.attribute.backgroundOffsetY) && void 0 !== _k ? _k : DefaultAttribute.backgroundOffsetY,
|
|
22288
|
+
backgroundPosition: null !== (_l = stage.attribute.backgroundPosition) && void 0 !== _l ? _l : DefaultAttribute.backgroundPosition
|
|
22289
|
+
}), boundsAllocate.free(backgroundBounds);
|
|
22290
|
+
}
|
|
22012
22291
|
} else context.fillStyle = createColor(context, clear, {
|
|
22013
22292
|
AABBBounds: {
|
|
22014
22293
|
x1: 0,
|
|
@@ -22506,7 +22785,7 @@
|
|
|
22506
22785
|
return null !== (_a = this._background) && void 0 !== _a ? _a : DefaultConfig.BACKGROUND;
|
|
22507
22786
|
}
|
|
22508
22787
|
set background(b) {
|
|
22509
|
-
this._background = b;
|
|
22788
|
+
this._background = b, this.syncBackgroundImage(b);
|
|
22510
22789
|
}
|
|
22511
22790
|
get defaultLayer() {
|
|
22512
22791
|
return this.at(0);
|
|
@@ -22520,6 +22799,18 @@
|
|
|
22520
22799
|
set ticker(ticker) {
|
|
22521
22800
|
ticker.bindStage(this), this._ticker && this._ticker.removeListener("tick", this.afterTickCb), ticker.addTimeline(this.timeline), this._ticker = ticker, this._ticker.on("tick", this.afterTickCb);
|
|
22522
22801
|
}
|
|
22802
|
+
syncBackgroundImage(background) {
|
|
22803
|
+
var _a;
|
|
22804
|
+
const source = null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
|
|
22805
|
+
this.backgroundImg = !1, this.isImageBackgroundSource(source) && this.loadImage(source, !0);
|
|
22806
|
+
}
|
|
22807
|
+
isImageBackgroundSource(source) {
|
|
22808
|
+
if (!source) return !1;
|
|
22809
|
+
if ("string" == typeof source) return source.startsWith("<svg") || isValidUrl$1(source) || source.includes("/") || isBase64$1(source);
|
|
22810
|
+
if (!isObject$2(source)) return !1;
|
|
22811
|
+
const gradientSource = source;
|
|
22812
|
+
return "string" != typeof gradientSource.gradient || !Array.isArray(gradientSource.stops);
|
|
22813
|
+
}
|
|
22523
22814
|
constructor(params = {}) {
|
|
22524
22815
|
var _a, _b;
|
|
22525
22816
|
super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
|
|
@@ -22558,9 +22849,7 @@
|
|
|
22558
22849
|
main: !0
|
|
22559
22850
|
})), 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 = {
|
|
22560
22851
|
tickRenderMode: "effect"
|
|
22561
|
-
}), this.optmize(params.optimize), params.background &&
|
|
22562
|
-
background: this._background
|
|
22563
|
-
}), this.initAnimate(params), this.rafId = null !== (_b = params.rafId) && void 0 !== _b ? _b : Math.floor(6 * Math.random());
|
|
22852
|
+
}), 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());
|
|
22564
22853
|
}
|
|
22565
22854
|
initAnimate(params) {
|
|
22566
22855
|
var _a;
|
|
@@ -31234,6 +31523,7 @@
|
|
|
31234
31523
|
if (custom.prototype.constructor === custom) {
|
|
31235
31524
|
const descriptor = Object.getOwnPropertyDescriptor(custom, "prototype");
|
|
31236
31525
|
if (descriptor && !descriptor.writable) return 1;
|
|
31526
|
+
if (Object.getOwnPropertyNames(custom.prototype).length > 1) return 1;
|
|
31237
31527
|
}
|
|
31238
31528
|
return 2;
|
|
31239
31529
|
}
|