@visactor/vchart 2.0.22-alpha.0 → 2.0.22-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/es5/index.js +1 -1
- package/build/index.es.js +398 -108
- package/build/index.js +398 -108
- package/build/index.min.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/animation/callback-disappear.js +2 -1
- package/cjs/compile/state-manager.js +1 -2
- package/cjs/constant/gradient.js +1 -2
- package/cjs/constant/scroll-bar.js +2 -1
- package/cjs/constant/sunburst.js +1 -1
- package/cjs/constant/waterfall.js +1 -1
- package/cjs/constant/word-cloud.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/instance-manager.js +1 -1
- package/cjs/core/interface.js +1 -1
- package/cjs/core/util.js +1 -1
- package/cjs/core/vchart.js +1 -1
- package/cjs/data/initialize.js +1 -1
- package/cjs/data/register.js +1 -1
- package/esm/animation/callback-disappear.js +2 -1
- package/esm/compile/state-manager.js +1 -2
- package/esm/constant/gradient.js +1 -2
- package/esm/constant/scroll-bar.js +2 -1
- package/esm/constant/sunburst.js +1 -1
- package/esm/constant/waterfall.js +1 -1
- package/esm/constant/word-cloud.js +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/instance-manager.js +1 -1
- package/esm/core/interface.js +1 -1
- package/esm/core/util.js +1 -1
- package/esm/core/vchart.js +1 -1
- package/esm/data/initialize.js +1 -1
- package/esm/data/register.js +1 -1
- package/package.json +8 -8
package/build/index.es.js
CHANGED
|
@@ -11430,7 +11430,9 @@ const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({
|
|
|
11430
11430
|
background: null,
|
|
11431
11431
|
autoAnimateTexture: !1,
|
|
11432
11432
|
textureRatio: 1,
|
|
11433
|
-
textureOptions:
|
|
11433
|
+
textureOptions: {
|
|
11434
|
+
alignToGraphic: !0
|
|
11435
|
+
},
|
|
11434
11436
|
backgroundOpacity: 1,
|
|
11435
11437
|
backgroundCornerRadius: 0,
|
|
11436
11438
|
texture: null,
|
|
@@ -11444,6 +11446,7 @@ const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({
|
|
|
11444
11446
|
backgroundScale: 1,
|
|
11445
11447
|
backgroundOffsetX: 0,
|
|
11446
11448
|
backgroundOffsetY: 0,
|
|
11449
|
+
backgroundPosition: "top-left",
|
|
11447
11450
|
blur: 0,
|
|
11448
11451
|
filter: "",
|
|
11449
11452
|
cursor: null,
|
|
@@ -11616,11 +11619,16 @@ const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, D
|
|
|
11616
11619
|
const DefaultImageAttribute = Object.assign(Object.assign({
|
|
11617
11620
|
repeatX: "no-repeat",
|
|
11618
11621
|
repeatY: "no-repeat",
|
|
11622
|
+
imageMode: void 0,
|
|
11619
11623
|
image: "",
|
|
11620
11624
|
width: 0,
|
|
11621
11625
|
height: 0,
|
|
11622
11626
|
maxWidth: 500,
|
|
11623
|
-
maxHeight: 500
|
|
11627
|
+
maxHeight: 500,
|
|
11628
|
+
imagePosition: "top-left",
|
|
11629
|
+
imageScale: 1,
|
|
11630
|
+
imageOffsetX: 0,
|
|
11631
|
+
imageOffsetY: 0
|
|
11624
11632
|
}, DefaultAttribute), {
|
|
11625
11633
|
fill: !0,
|
|
11626
11634
|
cornerRadius: 0,
|
|
@@ -16672,7 +16680,8 @@ class Graphic extends Node {
|
|
|
16672
16680
|
return isString$1(path, !0) ? this.pathProxy = new CustomPath2D().fromString(path) : this.pathProxy = new CustomPath2D(), this.pathProxy;
|
|
16673
16681
|
}
|
|
16674
16682
|
loadImage(image, background = !1) {
|
|
16675
|
-
if (
|
|
16683
|
+
if (background && (null == image ? void 0 : image.background) && (image = image.background), background && (!image || backgroundNotImage(image))) return void (this.backgroundImg = !1);
|
|
16684
|
+
if (!image) return;
|
|
16676
16685
|
const url = image;
|
|
16677
16686
|
this.resources || (this.resources = new Map());
|
|
16678
16687
|
const cache = {
|
|
@@ -16727,7 +16736,7 @@ class Graphic extends Node {
|
|
|
16727
16736
|
}
|
|
16728
16737
|
}
|
|
16729
16738
|
function backgroundNotImage(image) {
|
|
16730
|
-
return !(!image.fill && !image.stroke);
|
|
16739
|
+
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));
|
|
16731
16740
|
}
|
|
16732
16741
|
function isExternalTexture(texture) {
|
|
16733
16742
|
return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$2(texture));
|
|
@@ -18863,7 +18872,7 @@ function seperateParagraph(paragraph, index) {
|
|
|
18863
18872
|
return [new Paragraph(text1, paragraph.newLine, paragraph.character, paragraph.ascentDescentMode), new Paragraph(text2, !0, paragraph.character, paragraph.ascentDescentMode)];
|
|
18864
18873
|
}
|
|
18865
18874
|
|
|
18866
|
-
const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
18875
|
+
const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", "imageMode", "imagePosition", "imageScale", "imageOffsetX", "imageOffsetY", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
18867
18876
|
class Image extends Graphic {
|
|
18868
18877
|
constructor(params) {
|
|
18869
18878
|
super(params), this.type = "image", this.numberType = IMAGE_NUMBER_TYPE, this.loadImage(this.attribute.image);
|
|
@@ -18968,6 +18977,7 @@ class Image extends Graphic {
|
|
|
18968
18977
|
}
|
|
18969
18978
|
Image.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
18970
18979
|
image: 1,
|
|
18980
|
+
imageMode: 1,
|
|
18971
18981
|
repeatX: 1,
|
|
18972
18982
|
repeatY: 1
|
|
18973
18983
|
}, NOWORK_ANIMATE_ATTR);
|
|
@@ -20161,11 +20171,12 @@ class DefaultBaseBackgroundRenderContribution {
|
|
|
20161
20171
|
backgroundScale = graphicAttribute.backgroundScale,
|
|
20162
20172
|
backgroundOffsetX = graphicAttribute.backgroundOffsetX,
|
|
20163
20173
|
backgroundOffsetY = graphicAttribute.backgroundOffsetY,
|
|
20164
|
-
backgroundClip = graphicAttribute.backgroundClip
|
|
20174
|
+
backgroundClip = graphicAttribute.backgroundClip,
|
|
20175
|
+
backgroundPosition = graphicAttribute.backgroundPosition
|
|
20165
20176
|
} = graphic.attribute;
|
|
20166
20177
|
if (background) if (graphic.backgroundImg && graphic.resources) {
|
|
20167
|
-
const res = graphic.resources.get(background);
|
|
20168
|
-
if ("success" !== res.state || !res.data) return;
|
|
20178
|
+
const res = graphic.resources.get(getBackgroundImage(background));
|
|
20179
|
+
if (!res || "success" !== res.state || !res.data) return;
|
|
20169
20180
|
if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
|
|
20170
20181
|
const groupAttribute = getTheme$1(graphic.parent).group,
|
|
20171
20182
|
{
|
|
@@ -20182,59 +20193,160 @@ class DefaultBaseBackgroundRenderContribution {
|
|
|
20182
20193
|
backgroundKeepAspectRatio: backgroundKeepAspectRatio,
|
|
20183
20194
|
backgroundScale: backgroundScale,
|
|
20184
20195
|
backgroundOffsetX: backgroundOffsetX,
|
|
20185
|
-
backgroundOffsetY: backgroundOffsetY
|
|
20196
|
+
backgroundOffsetY: backgroundOffsetY,
|
|
20197
|
+
backgroundPosition: backgroundPosition
|
|
20186
20198
|
}), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
|
|
20187
20199
|
} else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
|
|
20188
20200
|
}
|
|
20189
20201
|
doDrawImage(context, data, b, params) {
|
|
20190
|
-
|
|
20191
|
-
backgroundMode: backgroundMode,
|
|
20192
|
-
backgroundFit: backgroundFit,
|
|
20193
|
-
backgroundKeepAspectRatio: backgroundKeepAspectRatio,
|
|
20194
|
-
backgroundScale = 1,
|
|
20195
|
-
backgroundOffsetX = 0,
|
|
20196
|
-
backgroundOffsetY = 0
|
|
20197
|
-
} = params,
|
|
20198
|
-
targetW = b.width(),
|
|
20199
|
-
targetH = b.height();
|
|
20200
|
-
let w = targetW,
|
|
20201
|
-
h = targetH;
|
|
20202
|
-
if ("no-repeat" === backgroundMode) {
|
|
20203
|
-
if (backgroundFit) {
|
|
20204
|
-
if (backgroundKeepAspectRatio) {
|
|
20205
|
-
const maxScale = Math.max(targetW / data.width, targetH / data.height);
|
|
20206
|
-
context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
|
|
20207
|
-
} else context.drawImage(data, b.x1, b.y1, b.width(), b.height());
|
|
20208
|
-
} else {
|
|
20209
|
-
const resW = data.width * backgroundScale,
|
|
20210
|
-
resH = data.height * backgroundScale;
|
|
20211
|
-
context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
|
|
20212
|
-
}
|
|
20213
|
-
} else {
|
|
20214
|
-
if (backgroundFit && "repeat" !== backgroundMode && (data.width || data.height)) {
|
|
20215
|
-
const resW = data.width,
|
|
20216
|
-
resH = data.height;
|
|
20217
|
-
if ("repeat-x" === backgroundMode) {
|
|
20218
|
-
w = resW * (targetH / resH), h = targetH;
|
|
20219
|
-
} else if ("repeat-y" === backgroundMode) {
|
|
20220
|
-
h = resH * (targetW / resW), w = targetW;
|
|
20221
|
-
}
|
|
20222
|
-
const dpr = context.dpr,
|
|
20223
|
-
canvas = canvasAllocate.allocate({
|
|
20224
|
-
width: w,
|
|
20225
|
-
height: h,
|
|
20226
|
-
dpr: dpr
|
|
20227
|
-
}),
|
|
20228
|
-
ctx = canvas.getContext("2d");
|
|
20229
|
-
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);
|
|
20230
|
-
}
|
|
20231
|
-
const dpr = context.dpr,
|
|
20232
|
-
pattern = context.createPattern(data, backgroundMode);
|
|
20233
|
-
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);
|
|
20234
|
-
}
|
|
20202
|
+
drawBackgroundImage(context, data, b, params);
|
|
20235
20203
|
}
|
|
20236
20204
|
}
|
|
20237
20205
|
const defaultBaseBackgroundRenderContribution = new DefaultBaseBackgroundRenderContribution();
|
|
20206
|
+
const verticalPositionKeywords = new Set(["top", "center", "bottom"]);
|
|
20207
|
+
function getBackgroundImage(background) {
|
|
20208
|
+
var _a;
|
|
20209
|
+
return null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
|
|
20210
|
+
}
|
|
20211
|
+
function resolveBackgroundSizing({
|
|
20212
|
+
backgroundFit: backgroundFit,
|
|
20213
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio
|
|
20214
|
+
}) {
|
|
20215
|
+
return backgroundFit ? backgroundKeepAspectRatio ? "cover" : "fill" : "auto";
|
|
20216
|
+
}
|
|
20217
|
+
const NO_REPEAT_SIZING_MAP = {
|
|
20218
|
+
"no-repeat-cover": "cover",
|
|
20219
|
+
"no-repeat-contain": "contain",
|
|
20220
|
+
"no-repeat-fill": "fill",
|
|
20221
|
+
"no-repeat-auto": "auto"
|
|
20222
|
+
};
|
|
20223
|
+
function resolveBackgroundDrawMode({
|
|
20224
|
+
backgroundMode: backgroundMode,
|
|
20225
|
+
backgroundFit: backgroundFit,
|
|
20226
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio
|
|
20227
|
+
}) {
|
|
20228
|
+
const sizing = NO_REPEAT_SIZING_MAP[backgroundMode];
|
|
20229
|
+
return sizing ? {
|
|
20230
|
+
backgroundRepeatMode: "no-repeat",
|
|
20231
|
+
backgroundSizing: sizing
|
|
20232
|
+
} : {
|
|
20233
|
+
backgroundRepeatMode: backgroundMode,
|
|
20234
|
+
backgroundSizing: resolveBackgroundSizing({
|
|
20235
|
+
backgroundFit: backgroundFit,
|
|
20236
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio
|
|
20237
|
+
})
|
|
20238
|
+
};
|
|
20239
|
+
}
|
|
20240
|
+
function isPercentageValue(value) {
|
|
20241
|
+
return /^-?\d+(\.\d+)?%$/.test(value);
|
|
20242
|
+
}
|
|
20243
|
+
function parsePositionToken(value, remainSpace, startKeyword, centerKeyword, endKeyword) {
|
|
20244
|
+
if ("number" == typeof value && Number.isFinite(value)) return value;
|
|
20245
|
+
const normalizedValue = `${null != value ? value : ""}`.trim().toLowerCase();
|
|
20246
|
+
if (!normalizedValue || normalizedValue === startKeyword) return 0;
|
|
20247
|
+
if (normalizedValue === centerKeyword) return remainSpace / 2;
|
|
20248
|
+
if (normalizedValue === endKeyword) return remainSpace;
|
|
20249
|
+
if (isPercentageValue(normalizedValue)) return remainSpace * parseFloat(normalizedValue) / 100;
|
|
20250
|
+
const parsedValue = Number(normalizedValue);
|
|
20251
|
+
return Number.isFinite(parsedValue) ? parsedValue : 0;
|
|
20252
|
+
}
|
|
20253
|
+
function normalizeBackgroundPosition(position) {
|
|
20254
|
+
var _a, _b;
|
|
20255
|
+
if (Array.isArray(position)) return [null !== (_a = position[0]) && void 0 !== _a ? _a : "left", null !== (_b = position[1]) && void 0 !== _b ? _b : "top"];
|
|
20256
|
+
const tokens = `${null != position ? position : "top-left"}`.trim().toLowerCase().replace(/-/g, " ").split(/\s+/).filter(Boolean);
|
|
20257
|
+
if (0 === tokens.length) return ["left", "top"];
|
|
20258
|
+
if (1 === tokens.length) {
|
|
20259
|
+
const token = tokens[0];
|
|
20260
|
+
return "center" === token ? ["center", "center"] : verticalPositionKeywords.has(token) ? ["center", token] : [token, "center"];
|
|
20261
|
+
}
|
|
20262
|
+
let horizontal, vertical;
|
|
20263
|
+
const genericTokens = [];
|
|
20264
|
+
for (let i = 0; i < 2; i++) {
|
|
20265
|
+
const token = tokens[i];
|
|
20266
|
+
"left" !== token && "right" !== token ? "top" !== token && "bottom" !== token ? genericTokens.push(token) : vertical = token : horizontal = token;
|
|
20267
|
+
}
|
|
20268
|
+
return null == horizontal && genericTokens.length && (horizontal = genericTokens.shift()), null == vertical && genericTokens.length && (vertical = genericTokens.shift()), [null != horizontal ? horizontal : "left", null != vertical ? vertical : "top"];
|
|
20269
|
+
}
|
|
20270
|
+
function resolveBackgroundPosition(position, remainWidth, remainHeight) {
|
|
20271
|
+
const [horizontalPosition, verticalPosition] = normalizeBackgroundPosition(position);
|
|
20272
|
+
return {
|
|
20273
|
+
x: parsePositionToken(horizontalPosition, remainWidth, "left", "center", "right"),
|
|
20274
|
+
y: parsePositionToken(verticalPosition, remainHeight, "top", "center", "bottom")
|
|
20275
|
+
};
|
|
20276
|
+
}
|
|
20277
|
+
function pickRenderableDimension(...values) {
|
|
20278
|
+
for (const value of values) if ("number" == typeof value && Number.isFinite(value) && value > 0) return value;
|
|
20279
|
+
return null;
|
|
20280
|
+
}
|
|
20281
|
+
function resolveRenderableImageSize(data) {
|
|
20282
|
+
if (!data) return null;
|
|
20283
|
+
const width = pickRenderableDimension(data.naturalWidth, data.videoWidth, data.width),
|
|
20284
|
+
height = pickRenderableDimension(data.naturalHeight, data.videoHeight, data.height);
|
|
20285
|
+
return null == width || null == height ? null : {
|
|
20286
|
+
width: width,
|
|
20287
|
+
height: height
|
|
20288
|
+
};
|
|
20289
|
+
}
|
|
20290
|
+
function drawBackgroundImage(context, data, b, params) {
|
|
20291
|
+
var _a, _b;
|
|
20292
|
+
const {
|
|
20293
|
+
backgroundMode: backgroundMode,
|
|
20294
|
+
backgroundFit: backgroundFit,
|
|
20295
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio,
|
|
20296
|
+
backgroundScale = 1,
|
|
20297
|
+
backgroundOffsetX = 0,
|
|
20298
|
+
backgroundOffsetY = 0,
|
|
20299
|
+
backgroundPosition = "top-left"
|
|
20300
|
+
} = params,
|
|
20301
|
+
targetW = b.width(),
|
|
20302
|
+
targetH = b.height(),
|
|
20303
|
+
sourceSize = resolveRenderableImageSize(data),
|
|
20304
|
+
{
|
|
20305
|
+
backgroundRepeatMode: backgroundRepeatMode,
|
|
20306
|
+
backgroundSizing: resolvedBackgroundSizing
|
|
20307
|
+
} = resolveBackgroundDrawMode({
|
|
20308
|
+
backgroundMode: backgroundMode,
|
|
20309
|
+
backgroundFit: backgroundFit,
|
|
20310
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio
|
|
20311
|
+
});
|
|
20312
|
+
let w = targetW,
|
|
20313
|
+
h = targetH;
|
|
20314
|
+
if (targetW <= 0 || targetH <= 0) return;
|
|
20315
|
+
if ("no-repeat" === backgroundRepeatMode) {
|
|
20316
|
+
let drawWidth = null !== (_a = null == sourceSize ? void 0 : sourceSize.width) && void 0 !== _a ? _a : targetW,
|
|
20317
|
+
drawHeight = null !== (_b = null == sourceSize ? void 0 : sourceSize.height) && void 0 !== _b ? _b : targetH;
|
|
20318
|
+
if ("cover" !== resolvedBackgroundSizing && "contain" !== resolvedBackgroundSizing || !sourceSize) "fill" === resolvedBackgroundSizing && (drawWidth = targetW, drawHeight = targetH);else {
|
|
20319
|
+
const scale = "cover" === resolvedBackgroundSizing ? Math.max(targetW / sourceSize.width, targetH / sourceSize.height) : Math.min(targetW / sourceSize.width, targetH / sourceSize.height);
|
|
20320
|
+
drawWidth = sourceSize.width * scale, drawHeight = sourceSize.height * scale;
|
|
20321
|
+
}
|
|
20322
|
+
drawWidth *= backgroundScale, drawHeight *= backgroundScale;
|
|
20323
|
+
const {
|
|
20324
|
+
x: x,
|
|
20325
|
+
y: y
|
|
20326
|
+
} = resolveBackgroundPosition(backgroundPosition, targetW - drawWidth, targetH - drawHeight);
|
|
20327
|
+
return void context.drawImage(data, b.x1 + x + backgroundOffsetX, b.y1 + y + backgroundOffsetY, drawWidth, drawHeight);
|
|
20328
|
+
}
|
|
20329
|
+
if (backgroundFit && "repeat" !== backgroundRepeatMode && sourceSize) {
|
|
20330
|
+
const resW = sourceSize.width,
|
|
20331
|
+
resH = sourceSize.height;
|
|
20332
|
+
if ("repeat-x" === backgroundRepeatMode) {
|
|
20333
|
+
w = resW * (targetH / resH), h = targetH;
|
|
20334
|
+
} else if ("repeat-y" === backgroundRepeatMode) {
|
|
20335
|
+
h = resH * (targetW / resW), w = targetW;
|
|
20336
|
+
}
|
|
20337
|
+
const dpr = context.dpr,
|
|
20338
|
+
canvas = canvasAllocate.allocate({
|
|
20339
|
+
width: w,
|
|
20340
|
+
height: h,
|
|
20341
|
+
dpr: dpr
|
|
20342
|
+
}),
|
|
20343
|
+
ctx = canvas.getContext("2d");
|
|
20344
|
+
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);
|
|
20345
|
+
}
|
|
20346
|
+
const dpr = context.dpr,
|
|
20347
|
+
pattern = context.createPattern(data, backgroundRepeatMode);
|
|
20348
|
+
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);
|
|
20349
|
+
}
|
|
20238
20350
|
let DefaultBaseInteractiveRenderContribution = class {
|
|
20239
20351
|
constructor(subRenderContribitions) {
|
|
20240
20352
|
this.subRenderContribitions = subRenderContribitions, this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
|
|
@@ -20393,13 +20505,14 @@ class DefaultBaseTextureRenderContribution {
|
|
|
20393
20505
|
texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
|
|
20394
20506
|
}
|
|
20395
20507
|
drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
|
|
20396
|
-
var _a;
|
|
20508
|
+
var _a, _b, _c, _d, _e, _f;
|
|
20397
20509
|
const {
|
|
20398
20510
|
textureRatio = graphicAttribute.textureRatio,
|
|
20399
20511
|
textureOptions = null
|
|
20400
20512
|
} = graphic.attribute;
|
|
20401
20513
|
let pattern = null;
|
|
20402
|
-
const
|
|
20514
|
+
const textureRadius = null !== (_a = null == textureOptions ? void 0 : textureOptions.radius) && void 0 !== _a ? _a : 0,
|
|
20515
|
+
patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr, textureRadius);
|
|
20403
20516
|
if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
|
|
20404
20517
|
if ("string" == typeof texture) switch (texture) {
|
|
20405
20518
|
case "circle":
|
|
@@ -20426,7 +20539,7 @@ class DefaultBaseTextureRenderContribution {
|
|
|
20426
20539
|
case "grid":
|
|
20427
20540
|
pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
|
|
20428
20541
|
}
|
|
20429
|
-
pattern || (pattern = this.createResourcePattern(texture, graphic, context)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
|
|
20542
|
+
pattern || (pattern = this.createResourcePattern(texture, graphic, context, texturePadding, textureRadius)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
|
|
20430
20543
|
}
|
|
20431
20544
|
if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
|
|
20432
20545
|
const {
|
|
@@ -20473,10 +20586,24 @@ class DefaultBaseTextureRenderContribution {
|
|
|
20473
20586
|
for (let i = 0; i < gridRows; i++) for (let j = 0; j < gridColumns; j++) {
|
|
20474
20587
|
const _x = x + cellSize / 2 + j * cellSize,
|
|
20475
20588
|
_y = y + cellSize / 2 + i * cellSize;
|
|
20476
|
-
null === (
|
|
20589
|
+
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());
|
|
20477
20590
|
}
|
|
20478
20591
|
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();
|
|
20479
|
-
} else if (pattern)
|
|
20592
|
+
} else if (pattern) {
|
|
20593
|
+
if (pattern.setTransform) {
|
|
20594
|
+
const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
|
|
20595
|
+
alignOffsetX = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _c ? _c : 0,
|
|
20596
|
+
alignOffsetY = null !== (_d = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _d ? _d : 0;
|
|
20597
|
+
let translateX = 0,
|
|
20598
|
+
translateY = 0;
|
|
20599
|
+
if (alignToGraphic) {
|
|
20600
|
+
const m = context.currentMatrix;
|
|
20601
|
+
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;
|
|
20602
|
+
} else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
|
|
20603
|
+
pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
|
|
20604
|
+
}
|
|
20605
|
+
context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
|
|
20606
|
+
} else if ("wave" === texture) {
|
|
20480
20607
|
context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
|
|
20481
20608
|
const b = graphic.AABBBounds;
|
|
20482
20609
|
drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
|
|
@@ -20484,14 +20611,42 @@ class DefaultBaseTextureRenderContribution {
|
|
|
20484
20611
|
}), x + b.x1 - x, y + b.y1 - y), context.restore();
|
|
20485
20612
|
}
|
|
20486
20613
|
}
|
|
20487
|
-
getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr) {
|
|
20488
|
-
return "string" != typeof texture ? texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
|
|
20614
|
+
getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr, textureRadius) {
|
|
20615
|
+
return "string" != typeof texture ? texturePadding > 0 || textureRadius > 0 ? null : texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
|
|
20489
20616
|
}
|
|
20490
|
-
createResourcePattern(texture, graphic, context) {
|
|
20617
|
+
createResourcePattern(texture, graphic, context, texturePadding, textureRadius) {
|
|
20491
20618
|
var _a;
|
|
20492
20619
|
const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
|
|
20493
20620
|
data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
|
|
20494
20621
|
if (!data) return null;
|
|
20622
|
+
if (texturePadding > 0 || textureRadius > 0) {
|
|
20623
|
+
const w = data.naturalWidth || data.width,
|
|
20624
|
+
h = data.naturalHeight || data.height;
|
|
20625
|
+
if (w > 0 && h > 0) {
|
|
20626
|
+
const tileW = w + 2 * texturePadding,
|
|
20627
|
+
tileH = h + 2 * texturePadding,
|
|
20628
|
+
canvas = canvasAllocate.allocate({
|
|
20629
|
+
width: tileW,
|
|
20630
|
+
height: tileH,
|
|
20631
|
+
dpr: context.dpr
|
|
20632
|
+
}),
|
|
20633
|
+
ctx = canvas.getContext("2d");
|
|
20634
|
+
if (ctx) {
|
|
20635
|
+
if (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, tileW, tileH), textureRadius > 0) {
|
|
20636
|
+
const r = Math.max(0, Math.min(textureRadius, Math.min(w, h) / 2)),
|
|
20637
|
+
x0 = texturePadding,
|
|
20638
|
+
y0 = texturePadding,
|
|
20639
|
+
x1 = x0 + w,
|
|
20640
|
+
y1 = y0 + h;
|
|
20641
|
+
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();
|
|
20642
|
+
}
|
|
20643
|
+
ctx.drawImage(data, texturePadding, texturePadding, w, h);
|
|
20644
|
+
const pattern = context.createPattern(canvas.nativeCanvas, "repeat");
|
|
20645
|
+
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;
|
|
20646
|
+
}
|
|
20647
|
+
canvasAllocate.free(canvas);
|
|
20648
|
+
}
|
|
20649
|
+
}
|
|
20495
20650
|
const pattern = context.createPattern(data, "repeat");
|
|
20496
20651
|
return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
|
|
20497
20652
|
}
|
|
@@ -20606,27 +20761,32 @@ class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgroundRend
|
|
|
20606
20761
|
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
|
|
20607
20762
|
const {
|
|
20608
20763
|
background: background,
|
|
20764
|
+
backgroundOpacity = graphicAttribute.backgroundOpacity,
|
|
20765
|
+
opacity = graphicAttribute.opacity,
|
|
20609
20766
|
backgroundMode = graphicAttribute.backgroundMode,
|
|
20610
20767
|
backgroundFit = graphicAttribute.backgroundFit,
|
|
20611
20768
|
backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
|
|
20612
20769
|
backgroundScale = graphicAttribute.backgroundScale,
|
|
20613
20770
|
backgroundOffsetX = graphicAttribute.backgroundOffsetX,
|
|
20614
|
-
backgroundOffsetY = graphicAttribute.backgroundOffsetY
|
|
20771
|
+
backgroundOffsetY = graphicAttribute.backgroundOffsetY,
|
|
20772
|
+
backgroundClip = graphicAttribute.backgroundClip,
|
|
20773
|
+
backgroundPosition = graphicAttribute.backgroundPosition
|
|
20615
20774
|
} = graphic.attribute;
|
|
20616
20775
|
if (background) if (graphic.backgroundImg && graphic.resources) {
|
|
20617
|
-
const res = graphic.resources.get(background);
|
|
20618
|
-
if ("success" !== res.state || !res.data) return;
|
|
20776
|
+
const res = graphic.resources.get(getBackgroundImage(background));
|
|
20777
|
+
if (!res || "success" !== res.state || !res.data) return;
|
|
20619
20778
|
context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0);
|
|
20620
20779
|
const b = graphic.AABBBounds;
|
|
20621
|
-
this.doDrawImage(context, res.data, b, {
|
|
20780
|
+
context.globalAlpha = backgroundOpacity * opacity, backgroundClip && context.clip(), this.doDrawImage(context, res.data, b, {
|
|
20622
20781
|
backgroundMode: backgroundMode,
|
|
20623
20782
|
backgroundFit: backgroundFit,
|
|
20624
20783
|
backgroundKeepAspectRatio: backgroundKeepAspectRatio,
|
|
20625
20784
|
backgroundScale: backgroundScale,
|
|
20626
20785
|
backgroundOffsetX: backgroundOffsetX,
|
|
20627
|
-
backgroundOffsetY: backgroundOffsetY
|
|
20786
|
+
backgroundOffsetY: backgroundOffsetY,
|
|
20787
|
+
backgroundPosition: backgroundPosition
|
|
20628
20788
|
}), context.highPerformanceRestore(), context.setTransformForCurrent();
|
|
20629
|
-
} else context.highPerformanceSave(), context.fillStyle = background, context.fill(), context.highPerformanceRestore();
|
|
20789
|
+
} else context.highPerformanceSave(), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
|
|
20630
20790
|
}
|
|
20631
20791
|
}
|
|
20632
20792
|
const defaultGroupBackgroundRenderContribution = new DefaultGroupBackgroundRenderContribution();
|
|
@@ -22108,9 +22268,17 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
|
|
|
22108
22268
|
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
|
|
22109
22269
|
var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
22110
22270
|
const {
|
|
22271
|
+
backgroundOpacity = graphicAttribute.backgroundOpacity,
|
|
22272
|
+
opacity = graphicAttribute.opacity,
|
|
22111
22273
|
backgroundMode = graphicAttribute.backgroundMode,
|
|
22112
22274
|
backgroundFit = graphicAttribute.backgroundFit,
|
|
22113
|
-
backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio
|
|
22275
|
+
backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
|
|
22276
|
+
backgroundScale = graphicAttribute.backgroundScale,
|
|
22277
|
+
backgroundOffsetX = graphicAttribute.backgroundOffsetX,
|
|
22278
|
+
backgroundOffsetY = graphicAttribute.backgroundOffsetY,
|
|
22279
|
+
backgroundPosition = graphicAttribute.backgroundPosition,
|
|
22280
|
+
backgroundClip = graphicAttribute.backgroundClip,
|
|
22281
|
+
backgroundCornerRadius = graphicAttribute.backgroundCornerRadius
|
|
22114
22282
|
} = graphic.attribute;
|
|
22115
22283
|
let matrix,
|
|
22116
22284
|
{
|
|
@@ -22122,18 +22290,18 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
|
|
|
22122
22290
|
};
|
|
22123
22291
|
let b;
|
|
22124
22292
|
"richtext" === graphic.type && (matrix = context.currentMatrix.clone(), context.restore(), context.save(), context.setTransformForCurrent());
|
|
22125
|
-
const
|
|
22293
|
+
const backgroundConfig = isObject$2(background) && background.background ? background : null,
|
|
22126
22294
|
onlyTranslate = graphic.transMatrix.onlyTranslate();
|
|
22127
|
-
if (
|
|
22295
|
+
if (backgroundConfig) {
|
|
22128
22296
|
const _b = graphic.AABBBounds,
|
|
22129
|
-
x = (null !== (_a =
|
|
22130
|
-
y = (null !== (_d =
|
|
22131
|
-
w = null !== (_f =
|
|
22132
|
-
h = null !== (_g =
|
|
22133
|
-
if (b = boundsAllocate.allocate(x, y, x + w, y + h), background =
|
|
22297
|
+
x = (null !== (_a = backgroundConfig.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = backgroundConfig.dx) && void 0 !== _c ? _c : 0),
|
|
22298
|
+
y = (null !== (_d = backgroundConfig.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = backgroundConfig.dy) && void 0 !== _e ? _e : 0),
|
|
22299
|
+
w = null !== (_f = backgroundConfig.width) && void 0 !== _f ? _f : _b.width(),
|
|
22300
|
+
h = null !== (_g = backgroundConfig.height) && void 0 !== _g ? _g : _b.height();
|
|
22301
|
+
if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = backgroundConfig.background, !onlyTranslate) {
|
|
22134
22302
|
const w = b.width(),
|
|
22135
22303
|
h = b.height();
|
|
22136
|
-
b.set((null !== (_h =
|
|
22304
|
+
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);
|
|
22137
22305
|
}
|
|
22138
22306
|
} else b = graphic.AABBBounds, onlyTranslate || (b = getTextBounds(Object.assign(Object.assign({}, graphic.attribute), {
|
|
22139
22307
|
angle: 0,
|
|
@@ -22146,20 +22314,18 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
|
|
|
22146
22314
|
})).clone());
|
|
22147
22315
|
if (graphic.backgroundImg && graphic.resources) {
|
|
22148
22316
|
const res = graphic.resources.get(background);
|
|
22149
|
-
if ("success" !== res.state || !res.data) return void restore();
|
|
22150
|
-
context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.
|
|
22317
|
+
if (!res || "success" !== res.state || !res.data) return void restore();
|
|
22318
|
+
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, {
|
|
22151
22319
|
backgroundMode: backgroundMode,
|
|
22152
22320
|
backgroundFit: backgroundFit,
|
|
22153
|
-
backgroundKeepAspectRatio: backgroundKeepAspectRatio
|
|
22321
|
+
backgroundKeepAspectRatio: backgroundKeepAspectRatio,
|
|
22322
|
+
backgroundScale: backgroundScale,
|
|
22323
|
+
backgroundOffsetX: backgroundOffsetX,
|
|
22324
|
+
backgroundOffsetY: backgroundOffsetY,
|
|
22325
|
+
backgroundPosition: backgroundPosition
|
|
22154
22326
|
}), context.highPerformanceRestore(), context.setTransformForCurrent();
|
|
22155
|
-
} else
|
|
22156
|
-
|
|
22157
|
-
backgroundCornerRadius: backgroundCornerRadius,
|
|
22158
|
-
backgroundOpacity = 1
|
|
22159
|
-
} = graphic.attribute;
|
|
22160
|
-
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();
|
|
22161
|
-
}
|
|
22162
|
-
shouldReCalBounds && boundsAllocate.free(b), restore();
|
|
22327
|
+
} 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();
|
|
22328
|
+
backgroundConfig && boundsAllocate.free(b), restore();
|
|
22163
22329
|
}
|
|
22164
22330
|
}
|
|
22165
22331
|
const defaultTextBackgroundRenderContribution = new DefaultTextBackgroundRenderContribution();
|
|
@@ -22586,6 +22752,92 @@ var __decorate$1h = undefined && undefined.__decorate || function (decorators, t
|
|
|
22586
22752
|
};
|
|
22587
22753
|
};
|
|
22588
22754
|
const repeatStr = ["", "repeat-x", "repeat-y", "repeat"];
|
|
22755
|
+
function resolveImageMode({
|
|
22756
|
+
repeatX = "no-repeat",
|
|
22757
|
+
repeatY = "no-repeat",
|
|
22758
|
+
imageMode: imageMode
|
|
22759
|
+
}) {
|
|
22760
|
+
const repeatMode = resolveImageRepeatMode(repeatX, repeatY);
|
|
22761
|
+
return {
|
|
22762
|
+
repeatMode: repeatMode,
|
|
22763
|
+
sizingMode: "no-repeat" === repeatMode && null != imageMode ? imageMode : "fill"
|
|
22764
|
+
};
|
|
22765
|
+
}
|
|
22766
|
+
const IMAGE_MODE_TO_BACKGROUND_MODE = {
|
|
22767
|
+
cover: "no-repeat-cover",
|
|
22768
|
+
contain: "no-repeat-contain",
|
|
22769
|
+
fill: "no-repeat-fill",
|
|
22770
|
+
auto: "no-repeat-auto"
|
|
22771
|
+
};
|
|
22772
|
+
function resolveBackgroundParamsByImageSizing(sizingMode) {
|
|
22773
|
+
return {
|
|
22774
|
+
backgroundMode: IMAGE_MODE_TO_BACKGROUND_MODE[sizingMode],
|
|
22775
|
+
backgroundFit: !1,
|
|
22776
|
+
backgroundKeepAspectRatio: !1
|
|
22777
|
+
};
|
|
22778
|
+
}
|
|
22779
|
+
function resolveImageRepeatMode(repeatX, repeatY) {
|
|
22780
|
+
let repeat = 0;
|
|
22781
|
+
return "repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat ? repeatStr[repeat] : "no-repeat";
|
|
22782
|
+
}
|
|
22783
|
+
function shouldClipImageByLayout({
|
|
22784
|
+
repeatX = "no-repeat",
|
|
22785
|
+
repeatY = "no-repeat",
|
|
22786
|
+
imageMode: imageMode,
|
|
22787
|
+
imageScale = 1,
|
|
22788
|
+
imageOffsetX = 0,
|
|
22789
|
+
imageOffsetY = 0,
|
|
22790
|
+
imagePosition = "top-left"
|
|
22791
|
+
}) {
|
|
22792
|
+
const {
|
|
22793
|
+
repeatMode: repeatMode,
|
|
22794
|
+
sizingMode: sizingMode
|
|
22795
|
+
} = resolveImageMode({
|
|
22796
|
+
repeatX: repeatX,
|
|
22797
|
+
repeatY: repeatY,
|
|
22798
|
+
imageMode: imageMode
|
|
22799
|
+
});
|
|
22800
|
+
return "no-repeat" === repeatMode && ("cover" === sizingMode || "auto" === sizingMode || 1 !== imageScale || 0 !== imageOffsetX || 0 !== imageOffsetY);
|
|
22801
|
+
}
|
|
22802
|
+
function drawImageWithLayout(context, data, x, y, width, height, {
|
|
22803
|
+
repeatX = "no-repeat",
|
|
22804
|
+
repeatY = "no-repeat",
|
|
22805
|
+
imageMode: imageMode,
|
|
22806
|
+
imageScale = 1,
|
|
22807
|
+
imageOffsetX = 0,
|
|
22808
|
+
imageOffsetY = 0,
|
|
22809
|
+
imagePosition = "top-left"
|
|
22810
|
+
}) {
|
|
22811
|
+
const {
|
|
22812
|
+
repeatMode: repeatMode,
|
|
22813
|
+
sizingMode: sizingMode
|
|
22814
|
+
} = resolveImageMode({
|
|
22815
|
+
repeatX: repeatX,
|
|
22816
|
+
repeatY: repeatY,
|
|
22817
|
+
imageMode: imageMode
|
|
22818
|
+
}),
|
|
22819
|
+
imageBackgroundParams = "no-repeat" === repeatMode ? resolveBackgroundParamsByImageSizing(sizingMode) : {
|
|
22820
|
+
backgroundMode: repeatMode,
|
|
22821
|
+
backgroundFit: !1,
|
|
22822
|
+
backgroundKeepAspectRatio: !1
|
|
22823
|
+
};
|
|
22824
|
+
drawBackgroundImage(context, data, {
|
|
22825
|
+
x1: x,
|
|
22826
|
+
y1: y,
|
|
22827
|
+
x2: x + width,
|
|
22828
|
+
y2: y + height,
|
|
22829
|
+
width: () => width,
|
|
22830
|
+
height: () => height
|
|
22831
|
+
}, {
|
|
22832
|
+
backgroundMode: imageBackgroundParams.backgroundMode,
|
|
22833
|
+
backgroundFit: imageBackgroundParams.backgroundFit,
|
|
22834
|
+
backgroundKeepAspectRatio: imageBackgroundParams.backgroundKeepAspectRatio,
|
|
22835
|
+
backgroundScale: imageScale,
|
|
22836
|
+
backgroundOffsetX: imageOffsetX,
|
|
22837
|
+
backgroundOffsetY: imageOffsetY,
|
|
22838
|
+
backgroundPosition: imagePosition
|
|
22839
|
+
});
|
|
22840
|
+
}
|
|
22589
22841
|
let DefaultCanvasImageRender = class extends BaseRender {
|
|
22590
22842
|
constructor(graphicRenderContributions) {
|
|
22591
22843
|
super(), this.graphicRenderContributions = graphicRenderContributions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution], this.init(graphicRenderContributions);
|
|
@@ -22600,6 +22852,11 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
22600
22852
|
cornerRadius = imageAttribute.cornerRadius,
|
|
22601
22853
|
fillStrokeOrder = imageAttribute.fillStrokeOrder,
|
|
22602
22854
|
cornerType = imageAttribute.cornerType,
|
|
22855
|
+
imageMode = imageAttribute.imageMode,
|
|
22856
|
+
imageScale = imageAttribute.imageScale,
|
|
22857
|
+
imageOffsetX = imageAttribute.imageOffsetX,
|
|
22858
|
+
imageOffsetY = imageAttribute.imageOffsetY,
|
|
22859
|
+
imagePosition = imageAttribute.imagePosition,
|
|
22603
22860
|
image: url
|
|
22604
22861
|
} = image.attribute,
|
|
22605
22862
|
data = this.valid(image, imageAttribute, fillCb);
|
|
@@ -22616,22 +22873,33 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
22616
22873
|
const width = image.width,
|
|
22617
22874
|
height = image.height;
|
|
22618
22875
|
context.beginPath();
|
|
22619
|
-
let
|
|
22620
|
-
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),
|
|
22876
|
+
let needCornerClip = !1;
|
|
22877
|
+
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);
|
|
22621
22878
|
const _runFill = () => {
|
|
22622
|
-
|
|
22623
|
-
|
|
22624
|
-
|
|
22625
|
-
|
|
22626
|
-
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
22879
|
+
doFill && (fillCb ? fillCb(context, image.attribute, imageAttribute) : fVisible && (context.setCommonStyle(image, image.attribute, x, y, imageAttribute), drawImageWithLayout(context, res.data, x, y, width, height, {
|
|
22880
|
+
repeatX: repeatX,
|
|
22881
|
+
repeatY: repeatY,
|
|
22882
|
+
imageMode: imageMode,
|
|
22883
|
+
imageScale: imageScale,
|
|
22884
|
+
imageOffsetX: imageOffsetX,
|
|
22885
|
+
imageOffsetY: imageOffsetY,
|
|
22886
|
+
imagePosition: imagePosition
|
|
22887
|
+
})));
|
|
22630
22888
|
},
|
|
22631
22889
|
_runStroke = () => {
|
|
22632
22890
|
doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
|
|
22633
|
-
}
|
|
22634
|
-
|
|
22891
|
+
},
|
|
22892
|
+
needLayoutClip = shouldClipImageByLayout({
|
|
22893
|
+
repeatX: repeatX,
|
|
22894
|
+
repeatY: repeatY,
|
|
22895
|
+
imageMode: imageMode,
|
|
22896
|
+
imageScale: imageScale,
|
|
22897
|
+
imageOffsetX: imageOffsetX,
|
|
22898
|
+
imageOffsetY: imageOffsetY,
|
|
22899
|
+
imagePosition: imagePosition
|
|
22900
|
+
}),
|
|
22901
|
+
needClip = needCornerClip || needLayoutClip;
|
|
22902
|
+
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);
|
|
22635
22903
|
}
|
|
22636
22904
|
draw(image, renderService, drawContext) {
|
|
22637
22905
|
const {
|
|
@@ -23490,7 +23758,7 @@ let DefaultDrawContribution = class {
|
|
|
23490
23758
|
return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);
|
|
23491
23759
|
}
|
|
23492
23760
|
clearScreen(renderService, context, drawContext) {
|
|
23493
|
-
var _a, _b, _c;
|
|
23761
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
23494
23762
|
const {
|
|
23495
23763
|
clear: clear,
|
|
23496
23764
|
viewBox: viewBox
|
|
@@ -23500,9 +23768,20 @@ let DefaultDrawContribution = class {
|
|
|
23500
23768
|
if (clear) {
|
|
23501
23769
|
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);
|
|
23502
23770
|
const stage = null === (_b = renderService.drawParams) || void 0 === _b ? void 0 : _b.stage;
|
|
23503
|
-
if (stage && (context.globalAlpha = null !== (_c = stage.attribute.opacity) && void 0 !== _c ? _c : 1), stage && stage.backgroundImg && stage.resources) {
|
|
23504
|
-
const res = stage.resources.get(clear);
|
|
23505
|
-
res && "success" === res.state && res.data
|
|
23771
|
+
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) {
|
|
23772
|
+
const res = stage.resources.get(getBackgroundImage(clear));
|
|
23773
|
+
if (res && "success" === res.state && res.data) {
|
|
23774
|
+
const backgroundBounds = boundsAllocate.allocate(0, 0, 0 + width, 0 + height);
|
|
23775
|
+
drawBackgroundImage(context, res.data, backgroundBounds, {
|
|
23776
|
+
backgroundMode: null !== (_e = stage.attribute.backgroundMode) && void 0 !== _e ? _e : DefaultAttribute.backgroundMode,
|
|
23777
|
+
backgroundFit: null !== (_f = stage.attribute.backgroundFit) && void 0 !== _f ? _f : DefaultAttribute.backgroundFit,
|
|
23778
|
+
backgroundKeepAspectRatio: null !== (_g = stage.attribute.backgroundKeepAspectRatio) && void 0 !== _g ? _g : DefaultAttribute.backgroundKeepAspectRatio,
|
|
23779
|
+
backgroundScale: null !== (_h = stage.attribute.backgroundScale) && void 0 !== _h ? _h : DefaultAttribute.backgroundScale,
|
|
23780
|
+
backgroundOffsetX: null !== (_j = stage.attribute.backgroundOffsetX) && void 0 !== _j ? _j : DefaultAttribute.backgroundOffsetX,
|
|
23781
|
+
backgroundOffsetY: null !== (_k = stage.attribute.backgroundOffsetY) && void 0 !== _k ? _k : DefaultAttribute.backgroundOffsetY,
|
|
23782
|
+
backgroundPosition: null !== (_l = stage.attribute.backgroundPosition) && void 0 !== _l ? _l : DefaultAttribute.backgroundPosition
|
|
23783
|
+
}), boundsAllocate.free(backgroundBounds);
|
|
23784
|
+
}
|
|
23506
23785
|
} else context.fillStyle = createColor(context, clear, {
|
|
23507
23786
|
AABBBounds: {
|
|
23508
23787
|
x1: 0,
|
|
@@ -24000,7 +24279,7 @@ class Stage extends Group$1 {
|
|
|
24000
24279
|
return null !== (_a = this._background) && void 0 !== _a ? _a : DefaultConfig.BACKGROUND;
|
|
24001
24280
|
}
|
|
24002
24281
|
set background(b) {
|
|
24003
|
-
this._background = b;
|
|
24282
|
+
this._background = b, this.syncBackgroundImage(b);
|
|
24004
24283
|
}
|
|
24005
24284
|
get defaultLayer() {
|
|
24006
24285
|
return this.at(0);
|
|
@@ -24014,6 +24293,18 @@ class Stage extends Group$1 {
|
|
|
24014
24293
|
set ticker(ticker) {
|
|
24015
24294
|
ticker.bindStage(this), this._ticker && this._ticker.removeListener("tick", this.afterTickCb), ticker.addTimeline(this.timeline), this._ticker = ticker, this._ticker.on("tick", this.afterTickCb);
|
|
24016
24295
|
}
|
|
24296
|
+
syncBackgroundImage(background) {
|
|
24297
|
+
var _a;
|
|
24298
|
+
const source = null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
|
|
24299
|
+
this.backgroundImg = !1, this.isImageBackgroundSource(source) && this.loadImage(source, !0);
|
|
24300
|
+
}
|
|
24301
|
+
isImageBackgroundSource(source) {
|
|
24302
|
+
if (!source) return !1;
|
|
24303
|
+
if ("string" == typeof source) return source.startsWith("<svg") || isValidUrl$1(source) || source.includes("/") || isBase64$1(source);
|
|
24304
|
+
if (!isObject$2(source)) return !1;
|
|
24305
|
+
const gradientSource = source;
|
|
24306
|
+
return "string" != typeof gradientSource.gradient || !Array.isArray(gradientSource.stops);
|
|
24307
|
+
}
|
|
24017
24308
|
constructor(params = {}) {
|
|
24018
24309
|
var _a, _b;
|
|
24019
24310
|
super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
|
|
@@ -24052,9 +24343,7 @@ class Stage extends Group$1 {
|
|
|
24052
24343
|
main: !0
|
|
24053
24344
|
})), 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 = {
|
|
24054
24345
|
tickRenderMode: "effect"
|
|
24055
|
-
}), this.optmize(params.optimize), params.background &&
|
|
24056
|
-
background: this._background
|
|
24057
|
-
}), this.initAnimate(params), this.rafId = null !== (_b = params.rafId) && void 0 !== _b ? _b : Math.floor(6 * Math.random());
|
|
24346
|
+
}), 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());
|
|
24058
24347
|
}
|
|
24059
24348
|
initAnimate(params) {
|
|
24060
24349
|
var _a;
|
|
@@ -35212,6 +35501,7 @@ function getCustomType(custom) {
|
|
|
35212
35501
|
if (custom.prototype.constructor === custom) {
|
|
35213
35502
|
const descriptor = Object.getOwnPropertyDescriptor(custom, "prototype");
|
|
35214
35503
|
if (descriptor && !descriptor.writable) return 1;
|
|
35504
|
+
if (Object.getOwnPropertyNames(custom.prototype).length > 1) return 1;
|
|
35215
35505
|
}
|
|
35216
35506
|
return 2;
|
|
35217
35507
|
}
|