@leafer-draw/miniapp 2.0.0 → 2.0.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/dist/miniapp.cjs +63 -35
- package/dist/miniapp.esm.js +51 -37
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +122 -68
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +7 -9
- package/src/index.ts +2 -2
- package/types/index.d.ts +1 -8
- package/src/core.ts +0 -143
package/dist/miniapp.module.js
CHANGED
|
@@ -1727,7 +1727,7 @@ const Platform = {
|
|
|
1727
1727
|
resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
|
|
1728
1728
|
const realWidth = max$2(floor(width + (xGap || 0)), 1), realHeight = max$2(floor(height + (yGap || 0)), 1);
|
|
1729
1729
|
let interlaceX, interlaceY, interlaceOffset;
|
|
1730
|
-
if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset,
|
|
1730
|
+
if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, interlace.type === "x" ? width : height))) interlace.type === "x" ? interlaceX = true : interlaceY = true;
|
|
1731
1731
|
const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
|
|
1732
1732
|
const ctx = canvas.getContext("2d");
|
|
1733
1733
|
if (opacity) ctx.globalAlpha = opacity;
|
|
@@ -1897,7 +1897,10 @@ const UICreator = {
|
|
|
1897
1897
|
list$1[tag] = UI;
|
|
1898
1898
|
},
|
|
1899
1899
|
get(tag, data, x, y, width, height) {
|
|
1900
|
-
if (!list$1[tag])
|
|
1900
|
+
if (!list$1[tag]) {
|
|
1901
|
+
debug$d.warn("not register " + tag);
|
|
1902
|
+
return undefined;
|
|
1903
|
+
}
|
|
1901
1904
|
const ui = new list$1[tag](data);
|
|
1902
1905
|
if (!isUndefined(x)) {
|
|
1903
1906
|
ui.x = x;
|
|
@@ -3317,10 +3320,10 @@ const PathCommandDataHelper = {
|
|
|
3317
3320
|
data.push(O$2, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
|
|
3318
3321
|
}
|
|
3319
3322
|
},
|
|
3320
|
-
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
|
|
3323
|
+
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY, fullRadius) {
|
|
3321
3324
|
if (!isUndefined(lastX)) {
|
|
3322
|
-
const
|
|
3323
|
-
radius = min(radius, min(
|
|
3325
|
+
const r = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / (fullRadius ? 1 : 2);
|
|
3326
|
+
radius = min(radius, min(r, r * abs$2(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
|
|
3324
3327
|
}
|
|
3325
3328
|
data.push(U$2, x1, y1, x2, y2, radius);
|
|
3326
3329
|
},
|
|
@@ -3664,7 +3667,7 @@ const PathCorner = {
|
|
|
3664
3667
|
let command, lastCommand, commandLen;
|
|
3665
3668
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3666
3669
|
if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
|
|
3667
|
-
const len = data.length;
|
|
3670
|
+
const len = data.length, three = len === 9;
|
|
3668
3671
|
const smooth = [];
|
|
3669
3672
|
while (i < len) {
|
|
3670
3673
|
command = data[i];
|
|
@@ -3676,7 +3679,7 @@ const PathCorner = {
|
|
|
3676
3679
|
if (data[i] === L$1) {
|
|
3677
3680
|
secondX = data[i + 1];
|
|
3678
3681
|
secondY = data[i + 2];
|
|
3679
|
-
smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
|
|
3682
|
+
three ? smooth.push(M, startX, startY) : smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
|
|
3680
3683
|
} else {
|
|
3681
3684
|
smooth.push(M, startX, startY);
|
|
3682
3685
|
}
|
|
@@ -3688,11 +3691,11 @@ const PathCorner = {
|
|
|
3688
3691
|
i += 3;
|
|
3689
3692
|
switch (data[i]) {
|
|
3690
3693
|
case L$1:
|
|
3691
|
-
arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
|
|
3694
|
+
arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY, three);
|
|
3692
3695
|
break;
|
|
3693
3696
|
|
|
3694
3697
|
case Z:
|
|
3695
|
-
arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
|
|
3698
|
+
arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
|
|
3696
3699
|
break;
|
|
3697
3700
|
|
|
3698
3701
|
default:
|
|
@@ -3704,7 +3707,7 @@ const PathCorner = {
|
|
|
3704
3707
|
|
|
3705
3708
|
case Z:
|
|
3706
3709
|
if (lastCommand !== Z) {
|
|
3707
|
-
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3710
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY, three);
|
|
3708
3711
|
smooth.push(Z);
|
|
3709
3712
|
}
|
|
3710
3713
|
i += 1;
|
|
@@ -3754,10 +3757,10 @@ function canvasPatch(drawer) {
|
|
|
3754
3757
|
const FileHelper = {
|
|
3755
3758
|
alphaPixelTypes: [ "png", "webp", "svg" ],
|
|
3756
3759
|
upperCaseTypeMap: {},
|
|
3757
|
-
|
|
3758
|
-
if (!type || type.startsWith(
|
|
3760
|
+
mimeType(type, base = "image") {
|
|
3761
|
+
if (!type || type.startsWith(base)) return type;
|
|
3759
3762
|
if (type === "jpg") type = "jpeg";
|
|
3760
|
-
return "
|
|
3763
|
+
return base + "/" + type;
|
|
3761
3764
|
},
|
|
3762
3765
|
fileType(filename) {
|
|
3763
3766
|
const l = filename.split(".");
|
|
@@ -3790,6 +3793,8 @@ const FileHelper = {
|
|
|
3790
3793
|
|
|
3791
3794
|
const F = FileHelper;
|
|
3792
3795
|
|
|
3796
|
+
F.mineType = F.mimeType;
|
|
3797
|
+
|
|
3793
3798
|
F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3794
3799
|
|
|
3795
3800
|
const debug$8 = Debug.get("TaskProcessor");
|
|
@@ -4034,6 +4039,9 @@ const debug$7 = Debug.get("Resource");
|
|
|
4034
4039
|
|
|
4035
4040
|
const Resource = {
|
|
4036
4041
|
tasker: new TaskProcessor,
|
|
4042
|
+
queue: new TaskProcessor({
|
|
4043
|
+
parallel: 1
|
|
4044
|
+
}),
|
|
4037
4045
|
map: {},
|
|
4038
4046
|
get isComplete() {
|
|
4039
4047
|
return R.tasker.isComplete;
|
|
@@ -4070,6 +4078,12 @@ const Resource = {
|
|
|
4070
4078
|
R.set(key, value);
|
|
4071
4079
|
return value;
|
|
4072
4080
|
},
|
|
4081
|
+
loadFilm(_key, _format) {
|
|
4082
|
+
return undefined;
|
|
4083
|
+
},
|
|
4084
|
+
loadVideo(_key, _format) {
|
|
4085
|
+
return undefined;
|
|
4086
|
+
},
|
|
4073
4087
|
destroy() {
|
|
4074
4088
|
R.map = {};
|
|
4075
4089
|
}
|
|
@@ -4080,12 +4094,10 @@ const R = Resource;
|
|
|
4080
4094
|
const ImageManager = {
|
|
4081
4095
|
maxRecycled: 10,
|
|
4082
4096
|
recycledList: [],
|
|
4083
|
-
patternTasker:
|
|
4084
|
-
|
|
4085
|
-
}),
|
|
4086
|
-
get(config) {
|
|
4097
|
+
patternTasker: Resource.queue,
|
|
4098
|
+
get(config, type) {
|
|
4087
4099
|
let image = Resource.get(config.url);
|
|
4088
|
-
if (!image) Resource.set(config.url, image = Creator.image(config));
|
|
4100
|
+
if (!image) Resource.set(config.url, image = type === "film" ? Creator.film(config) : Creator.image(config));
|
|
4089
4101
|
image.use++;
|
|
4090
4102
|
return image;
|
|
4091
4103
|
},
|
|
@@ -4120,7 +4132,7 @@ const ImageManager = {
|
|
|
4120
4132
|
if (config.format) return config.format === format;
|
|
4121
4133
|
const {url: url} = config;
|
|
4122
4134
|
if (url.startsWith("data:")) {
|
|
4123
|
-
if (url.startsWith("data:" + FileHelper.
|
|
4135
|
+
if (url.startsWith("data:" + FileHelper.mimeType(format))) return true;
|
|
4124
4136
|
} else {
|
|
4125
4137
|
if (url.includes("." + format) || url.includes("." + FileHelper.upperCaseTypeMap[format])) return true; else if (format === "png" && !url.includes(".")) return true;
|
|
4126
4138
|
}
|
|
@@ -4136,6 +4148,9 @@ const I = ImageManager;
|
|
|
4136
4148
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
4137
4149
|
|
|
4138
4150
|
class LeaferImage {
|
|
4151
|
+
get tag() {
|
|
4152
|
+
return "Image";
|
|
4153
|
+
}
|
|
4139
4154
|
get url() {
|
|
4140
4155
|
return this.config.url;
|
|
4141
4156
|
}
|
|
@@ -4164,7 +4179,7 @@ class LeaferImage {
|
|
|
4164
4179
|
if (!this.loading) {
|
|
4165
4180
|
this.loading = true;
|
|
4166
4181
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
4167
|
-
return yield Platform.origin.
|
|
4182
|
+
return yield Platform.origin["load" + this.tag](this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
|
|
4168
4183
|
if (thumbSize) this.setThumbView(img);
|
|
4169
4184
|
this.setView(img);
|
|
4170
4185
|
}).catch(e => {
|
|
@@ -4238,6 +4253,9 @@ class LeaferImage {
|
|
|
4238
4253
|
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4239
4254
|
return pattern;
|
|
4240
4255
|
}
|
|
4256
|
+
render(canvas, x, y, width, height, _leaf, _paint, _imageScaleX, _imageScaleY) {
|
|
4257
|
+
canvas.drawImage(this.view, x, y, width, height);
|
|
4258
|
+
}
|
|
4241
4259
|
getLoadUrl(_thumbSize) {
|
|
4242
4260
|
return this.url;
|
|
4243
4261
|
}
|
|
@@ -4264,6 +4282,18 @@ class LeaferImage {
|
|
|
4264
4282
|
}
|
|
4265
4283
|
}
|
|
4266
4284
|
|
|
4285
|
+
class LeaferFilm extends LeaferImage {
|
|
4286
|
+
get tag() {
|
|
4287
|
+
return "Film";
|
|
4288
|
+
}
|
|
4289
|
+
}
|
|
4290
|
+
|
|
4291
|
+
class LeaferVideo extends LeaferImage {
|
|
4292
|
+
get tag() {
|
|
4293
|
+
return "Video";
|
|
4294
|
+
}
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4267
4297
|
function defineKey(target, key, descriptor, noConfigurable) {
|
|
4268
4298
|
if (!noConfigurable) descriptor.configurable = descriptor.enumerable = true;
|
|
4269
4299
|
Object.defineProperty(target, key, descriptor);
|
|
@@ -6152,9 +6182,11 @@ const BranchRender = {
|
|
|
6152
6182
|
if (this.__hasMask) {
|
|
6153
6183
|
this.__renderMask(canvas, options);
|
|
6154
6184
|
} else {
|
|
6185
|
+
let child;
|
|
6155
6186
|
const {children: children} = this;
|
|
6156
6187
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
6157
|
-
|
|
6188
|
+
child = children[i];
|
|
6189
|
+
excludeRenderBounds$1(child, options) || (child.__.complex ? child.__renderComplex(canvas, options) : child.__render(canvas, options));
|
|
6158
6190
|
}
|
|
6159
6191
|
}
|
|
6160
6192
|
},
|
|
@@ -6635,6 +6667,7 @@ let Leaf = class Leaf {
|
|
|
6635
6667
|
__drawHitPath(_canvas) {}
|
|
6636
6668
|
__updateHitCanvas() {}
|
|
6637
6669
|
__render(_canvas, _options) {}
|
|
6670
|
+
__renderComplex(_canvas, _options) {}
|
|
6638
6671
|
__drawFast(_canvas, _options) {}
|
|
6639
6672
|
__draw(_canvas, _options, _originCanvas) {}
|
|
6640
6673
|
__clip(_canvas, _options) {}
|
|
@@ -6754,6 +6787,7 @@ let Branch = class Branch extends Leaf {
|
|
|
6754
6787
|
this.add(item, index);
|
|
6755
6788
|
noIndex || index++;
|
|
6756
6789
|
}); else child = UICreator.get(child.tag, child);
|
|
6790
|
+
if (!child) return;
|
|
6757
6791
|
}
|
|
6758
6792
|
if (child.parent) child.parent.remove(child);
|
|
6759
6793
|
child.parent = this;
|
|
@@ -6979,7 +7013,7 @@ class LeafLevelList {
|
|
|
6979
7013
|
}
|
|
6980
7014
|
}
|
|
6981
7015
|
|
|
6982
|
-
const version = "2.0.
|
|
7016
|
+
const version = "2.0.2";
|
|
6983
7017
|
|
|
6984
7018
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6985
7019
|
get allowBackgroundColor() {
|
|
@@ -7084,8 +7118,6 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
7084
7118
|
}
|
|
7085
7119
|
}
|
|
7086
7120
|
|
|
7087
|
-
const {mineType: mineType, fileType: fileType} = FileHelper;
|
|
7088
|
-
|
|
7089
7121
|
Object.assign(Creator, {
|
|
7090
7122
|
canvas: (options, manager) => new LeaferCanvas(options, manager),
|
|
7091
7123
|
image: options => new LeaferImage(options)
|
|
@@ -7101,12 +7133,12 @@ function useCanvas(_canvasType, app) {
|
|
|
7101
7133
|
};
|
|
7102
7134
|
return app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
|
|
7103
7135
|
},
|
|
7104
|
-
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(
|
|
7136
|
+
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(FileHelper.mimeType(type), quality),
|
|
7105
7137
|
canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, {
|
|
7106
7138
|
quality: quality
|
|
7107
7139
|
}),
|
|
7108
7140
|
canvasSaveAs: (canvas, filePath, quality) => {
|
|
7109
|
-
let data = canvas.toDataURL(
|
|
7141
|
+
let data = canvas.toDataURL(FileHelper.mimeType(FileHelper.fileType(filePath)), quality);
|
|
7110
7142
|
data = data.substring(data.indexOf("64,") + 3);
|
|
7111
7143
|
return Platform.origin.download(data, filePath);
|
|
7112
7144
|
},
|
|
@@ -7140,7 +7172,7 @@ function useCanvas(_canvasType, app) {
|
|
|
7140
7172
|
});
|
|
7141
7173
|
});
|
|
7142
7174
|
},
|
|
7143
|
-
loadImage(src) {
|
|
7175
|
+
loadImage(src, _crossOrigin, _leaferImage) {
|
|
7144
7176
|
return new Promise((resolve, reject) => {
|
|
7145
7177
|
const img = Platform.canvas.view.createImage();
|
|
7146
7178
|
img.onload = () => {
|
|
@@ -7152,6 +7184,14 @@ function useCanvas(_canvasType, app) {
|
|
|
7152
7184
|
img.src = Platform.image.getRealURL(src);
|
|
7153
7185
|
});
|
|
7154
7186
|
},
|
|
7187
|
+
loadContent(url, responseType = "text") {
|
|
7188
|
+
return new Promise((resolve, reject) => app.request({
|
|
7189
|
+
url: url,
|
|
7190
|
+
responseType: responseType === "arrayBuffer" ? "arraybuffer" : "text",
|
|
7191
|
+
success: res => resolve(responseType === "json" && typeof res.data === "string" ? JSON.parse(res.data) : res.data),
|
|
7192
|
+
fail: reject
|
|
7193
|
+
}));
|
|
7194
|
+
},
|
|
7155
7195
|
noRepeat: "repeat-x"
|
|
7156
7196
|
};
|
|
7157
7197
|
Platform.miniapp = {
|
|
@@ -7703,7 +7743,7 @@ class Renderer {
|
|
|
7703
7743
|
getCellList() {
|
|
7704
7744
|
return undefined;
|
|
7705
7745
|
}
|
|
7706
|
-
addBlock(block) {
|
|
7746
|
+
addBlock(block, _leafList) {
|
|
7707
7747
|
if (!this.updateBlocks) this.updateBlocks = [];
|
|
7708
7748
|
this.updateBlocks.push(block);
|
|
7709
7749
|
}
|
|
@@ -7751,7 +7791,8 @@ class Renderer {
|
|
|
7751
7791
|
__onLayoutEnd(event) {
|
|
7752
7792
|
if (event.data) event.data.map(item => {
|
|
7753
7793
|
let empty;
|
|
7754
|
-
|
|
7794
|
+
const {updatedList: updatedList} = item;
|
|
7795
|
+
if (updatedList) updatedList.list.some(leaf => {
|
|
7755
7796
|
empty = !leaf.__world.width || !leaf.__world.height;
|
|
7756
7797
|
if (empty) {
|
|
7757
7798
|
if (!leaf.isLeafer) debug$2.tip(leaf.innerName, ": empty");
|
|
@@ -7759,7 +7800,7 @@ class Renderer {
|
|
|
7759
7800
|
}
|
|
7760
7801
|
return empty;
|
|
7761
7802
|
});
|
|
7762
|
-
this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
|
|
7803
|
+
this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
|
|
7763
7804
|
});
|
|
7764
7805
|
}
|
|
7765
7806
|
emitRender(type, bounds, options) {
|
|
@@ -7946,16 +7987,16 @@ class UIData extends LeafData {
|
|
|
7946
7987
|
return t.fill || t.stroke;
|
|
7947
7988
|
}
|
|
7948
7989
|
get __autoWidth() {
|
|
7949
|
-
return
|
|
7990
|
+
return this._width == null;
|
|
7950
7991
|
}
|
|
7951
7992
|
get __autoHeight() {
|
|
7952
|
-
return
|
|
7993
|
+
return this._height == null;
|
|
7953
7994
|
}
|
|
7954
7995
|
get __autoSide() {
|
|
7955
|
-
return
|
|
7996
|
+
return this._width == null || this._height == null;
|
|
7956
7997
|
}
|
|
7957
7998
|
get __autoSize() {
|
|
7958
|
-
return
|
|
7999
|
+
return this._width == null && this._height == null;
|
|
7959
8000
|
}
|
|
7960
8001
|
setVisible(value) {
|
|
7961
8002
|
this._visible = value;
|
|
@@ -8167,13 +8208,16 @@ class TextData extends UIData {
|
|
|
8167
8208
|
}
|
|
8168
8209
|
|
|
8169
8210
|
class ImageData extends RectData {
|
|
8211
|
+
get __urlType() {
|
|
8212
|
+
return "image";
|
|
8213
|
+
}
|
|
8170
8214
|
setUrl(value) {
|
|
8171
8215
|
this.__setImageFill(value);
|
|
8172
8216
|
this._url = value;
|
|
8173
8217
|
}
|
|
8174
8218
|
__setImageFill(value) {
|
|
8175
8219
|
this.fill = value ? {
|
|
8176
|
-
type:
|
|
8220
|
+
type: this.__urlType,
|
|
8177
8221
|
mode: "stretch",
|
|
8178
8222
|
url: value
|
|
8179
8223
|
} : undefined;
|
|
@@ -8673,7 +8717,10 @@ let Group = class Group extends UI {
|
|
|
8673
8717
|
}
|
|
8674
8718
|
toJSON(options) {
|
|
8675
8719
|
const data = super.toJSON(options);
|
|
8676
|
-
if (!this.childlessJSON)
|
|
8720
|
+
if (!this.childlessJSON) {
|
|
8721
|
+
const children = data.children = [];
|
|
8722
|
+
this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)));
|
|
8723
|
+
}
|
|
8677
8724
|
return data;
|
|
8678
8725
|
}
|
|
8679
8726
|
pick(_hitPoint, _options) {
|
|
@@ -8822,12 +8869,12 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8822
8869
|
this.emitLeafer(LeaferEvent.STOP);
|
|
8823
8870
|
}
|
|
8824
8871
|
}
|
|
8825
|
-
unlockLayout() {
|
|
8872
|
+
unlockLayout(updateLayout = true) {
|
|
8826
8873
|
this.layouter.start();
|
|
8827
|
-
this.updateLayout();
|
|
8874
|
+
if (updateLayout) this.updateLayout();
|
|
8828
8875
|
}
|
|
8829
|
-
lockLayout() {
|
|
8830
|
-
this.updateLayout();
|
|
8876
|
+
lockLayout(updateLayout = true) {
|
|
8877
|
+
if (updateLayout) this.updateLayout();
|
|
8831
8878
|
this.layouter.stop();
|
|
8832
8879
|
}
|
|
8833
8880
|
resize(size) {
|
|
@@ -10010,11 +10057,14 @@ function compute(attrName, ui) {
|
|
|
10010
10057
|
function getLeafPaint(attrName, paint, ui) {
|
|
10011
10058
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
10012
10059
|
let leafPaint;
|
|
10013
|
-
const {boxBounds: boxBounds} = ui.__layout;
|
|
10014
|
-
switch (
|
|
10060
|
+
const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
|
|
10061
|
+
switch (type) {
|
|
10015
10062
|
case "image":
|
|
10063
|
+
case "film":
|
|
10064
|
+
case "video":
|
|
10016
10065
|
if (!paint.url) return undefined;
|
|
10017
10066
|
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
10067
|
+
if (type !== "image") PaintImage[type](leafPaint);
|
|
10018
10068
|
break;
|
|
10019
10069
|
|
|
10020
10070
|
case "linear":
|
|
@@ -10030,7 +10080,7 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
10030
10080
|
break;
|
|
10031
10081
|
|
|
10032
10082
|
case "solid":
|
|
10033
|
-
const {
|
|
10083
|
+
const {color: color, opacity: opacity} = paint;
|
|
10034
10084
|
leafPaint = {
|
|
10035
10085
|
type: type,
|
|
10036
10086
|
style: ColorConvert.string(color, opacity)
|
|
@@ -10074,7 +10124,7 @@ const {isSame: isSame} = BoundsHelper;
|
|
|
10074
10124
|
|
|
10075
10125
|
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
10076
10126
|
let leafPaint, event;
|
|
10077
|
-
const image = ImageManager.get(paint);
|
|
10127
|
+
const image = ImageManager.get(paint, paint.type);
|
|
10078
10128
|
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
10079
10129
|
leafPaint = cache.leafPaint;
|
|
10080
10130
|
} else {
|
|
@@ -10135,8 +10185,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
10135
10185
|
}
|
|
10136
10186
|
|
|
10137
10187
|
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
10138
|
-
|
|
10139
|
-
|
|
10188
|
+
const data = ui.__;
|
|
10189
|
+
if (attrName === "fill" && !data.__naturalWidth) {
|
|
10140
10190
|
data.__naturalWidth = image.width / data.pixelRatio;
|
|
10141
10191
|
data.__naturalHeight = image.height / data.pixelRatio;
|
|
10142
10192
|
if (data.__autoSide) {
|
|
@@ -10148,7 +10198,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
10148
10198
|
return false;
|
|
10149
10199
|
}
|
|
10150
10200
|
}
|
|
10151
|
-
if (!leafPaint.data)
|
|
10201
|
+
if (!leafPaint.data) {
|
|
10202
|
+
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
10203
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
|
|
10204
|
+
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
10205
|
+
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
10206
|
+
}
|
|
10152
10207
|
return true;
|
|
10153
10208
|
}
|
|
10154
10209
|
|
|
@@ -10191,7 +10246,7 @@ function getPatternData(paint, box, image) {
|
|
|
10191
10246
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
10192
10247
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
10193
10248
|
const {width: width, height: height} = image;
|
|
10194
|
-
const {
|
|
10249
|
+
const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
|
|
10195
10250
|
const sameBox = box.width === width && box.height === height;
|
|
10196
10251
|
const data = {
|
|
10197
10252
|
mode: mode
|
|
@@ -10254,8 +10309,6 @@ function getPatternData(paint, box, image) {
|
|
|
10254
10309
|
data.scaleX = scaleX;
|
|
10255
10310
|
data.scaleY = scaleY;
|
|
10256
10311
|
}
|
|
10257
|
-
if (opacity && opacity < 1) data.opacity = opacity;
|
|
10258
|
-
if (filters) data.filters = filters;
|
|
10259
10312
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
10260
10313
|
if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
|
|
10261
10314
|
type: "x",
|
|
@@ -10286,7 +10339,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
|
|
|
10286
10339
|
|
|
10287
10340
|
function stretchMode(data, box, scaleX, scaleY) {
|
|
10288
10341
|
const transform = get$2(), {x: x, y: y} = box;
|
|
10289
|
-
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
10342
|
+
if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
|
|
10290
10343
|
scaleHelper(transform, scaleX, scaleY);
|
|
10291
10344
|
data.transform = transform;
|
|
10292
10345
|
}
|
|
@@ -10375,10 +10428,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
|
10375
10428
|
}
|
|
10376
10429
|
|
|
10377
10430
|
function createPattern(paint, ui, canvas, renderOptions) {
|
|
10378
|
-
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
10431
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
10379
10432
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
10380
10433
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
10381
|
-
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10434
|
+
const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10382
10435
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
10383
10436
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
10384
10437
|
width *= scaleX;
|
|
@@ -10394,7 +10447,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
10394
10447
|
if (transform) copy$1(imageMatrix, transform);
|
|
10395
10448
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10396
10449
|
}
|
|
10397
|
-
const imageCanvas = image.getCanvas(width, height,
|
|
10450
|
+
const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
10398
10451
|
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10399
10452
|
paint.style = pattern;
|
|
10400
10453
|
paint.patternId = id;
|
|
@@ -10415,15 +10468,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
10415
10468
|
}
|
|
10416
10469
|
|
|
10417
10470
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
10418
|
-
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
10471
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
10419
10472
|
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
10420
|
-
if (!data || paint.patternId ===
|
|
10473
|
+
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
10421
10474
|
return false;
|
|
10422
10475
|
} else {
|
|
10423
10476
|
if (drawImage) {
|
|
10424
10477
|
if (data.repeat) {
|
|
10425
10478
|
drawImage = false;
|
|
10426
|
-
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
10479
|
+
} else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
10427
10480
|
drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
|
|
10428
10481
|
}
|
|
10429
10482
|
}
|
|
@@ -10441,20 +10494,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
10441
10494
|
}
|
|
10442
10495
|
}
|
|
10443
10496
|
|
|
10444
|
-
function drawImage(paint,
|
|
10445
|
-
const {data: data, image: image
|
|
10446
|
-
let {width: width, height: height} = image
|
|
10447
|
-
if (
|
|
10497
|
+
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
10498
|
+
const {data: data, image: image, complex: complex} = paint;
|
|
10499
|
+
let {width: width, height: height} = image;
|
|
10500
|
+
if (complex) {
|
|
10501
|
+
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
10448
10502
|
canvas.save();
|
|
10449
|
-
|
|
10503
|
+
complex === 2 && canvas.clipUI(ui);
|
|
10450
10504
|
blendMode && (canvas.blendMode = blendMode);
|
|
10451
10505
|
opacity && (canvas.opacity *= opacity);
|
|
10452
10506
|
transform && canvas.transform(transform);
|
|
10453
|
-
|
|
10507
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
10454
10508
|
canvas.restore();
|
|
10455
10509
|
} else {
|
|
10456
10510
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
10457
|
-
|
|
10511
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
10458
10512
|
}
|
|
10459
10513
|
}
|
|
10460
10514
|
|
|
@@ -11174,7 +11228,7 @@ function layoutText(drawData, style) {
|
|
|
11174
11228
|
let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
11175
11229
|
let starY = __baseLine;
|
|
11176
11230
|
if (__clipText && realHeight > height) {
|
|
11177
|
-
realHeight = Math.max(height, __lineHeight);
|
|
11231
|
+
realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
|
|
11178
11232
|
if (countRows > 1) drawData.overflow = countRows;
|
|
11179
11233
|
} else if (height || autoSizeAlign) {
|
|
11180
11234
|
switch (verticalAlign) {
|
|
@@ -11231,10 +11285,10 @@ function layoutText(drawData, style) {
|
|
|
11231
11285
|
}
|
|
11232
11286
|
|
|
11233
11287
|
function clipText(drawData, style, x, width) {
|
|
11234
|
-
if (!width) return;
|
|
11235
11288
|
const {rows: rows, overflow: overflow} = drawData;
|
|
11236
11289
|
let {textOverflow: textOverflow} = style;
|
|
11237
|
-
rows.splice(overflow);
|
|
11290
|
+
if (overflow) rows.splice(overflow);
|
|
11291
|
+
if (!width) return;
|
|
11238
11292
|
if (textOverflow && textOverflow !== "show") {
|
|
11239
11293
|
if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
|
|
11240
11294
|
let char, charRight;
|
|
@@ -11395,4 +11449,4 @@ try {
|
|
|
11395
11449
|
if (wx) useCanvas("miniapp", wx);
|
|
11396
11450
|
} catch (_a) {}
|
|
11397
11451
|
|
|
11398
|
-
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
11452
|
+
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferFilm, LeaferImage, LeaferVideo, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
|