@leafer/core 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/lib/core.cjs +60 -22
- package/lib/core.esm.js +57 -23
- package/lib/core.esm.min.js +1 -1
- package/lib/core.esm.min.js.map +1 -1
- package/lib/core.min.cjs +1 -1
- package/lib/core.min.cjs.map +1 -1
- package/package.json +17 -17
- package/src/index.ts +1 -1
- package/types/index.d.ts +1 -1
package/lib/core.cjs
CHANGED
|
@@ -1720,7 +1720,7 @@ const Platform = {
|
|
|
1720
1720
|
resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
|
|
1721
1721
|
const realWidth = max(floor(width + (xGap || 0)), 1), realHeight = max(floor(height + (yGap || 0)), 1);
|
|
1722
1722
|
let interlaceX, interlaceY, interlaceOffset;
|
|
1723
|
-
if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset,
|
|
1723
|
+
if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, interlace.type === "x" ? width : height))) interlace.type === "x" ? interlaceX = true : interlaceY = true;
|
|
1724
1724
|
const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
|
|
1725
1725
|
const ctx = canvas.getContext("2d");
|
|
1726
1726
|
if (opacity) ctx.globalAlpha = opacity;
|
|
@@ -1890,7 +1890,10 @@ const UICreator = {
|
|
|
1890
1890
|
list$1[tag] = UI;
|
|
1891
1891
|
},
|
|
1892
1892
|
get(tag, data, x, y, width, height) {
|
|
1893
|
-
if (!list$1[tag])
|
|
1893
|
+
if (!list$1[tag]) {
|
|
1894
|
+
debug$9.warn("not register " + tag);
|
|
1895
|
+
return undefined;
|
|
1896
|
+
}
|
|
1894
1897
|
const ui = new list$1[tag](data);
|
|
1895
1898
|
if (!isUndefined(x)) {
|
|
1896
1899
|
ui.x = x;
|
|
@@ -3310,10 +3313,10 @@ const PathCommandDataHelper = {
|
|
|
3310
3313
|
data.push(O$2, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
|
|
3311
3314
|
}
|
|
3312
3315
|
},
|
|
3313
|
-
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
|
|
3316
|
+
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY, fullRadius) {
|
|
3314
3317
|
if (!isUndefined(lastX)) {
|
|
3315
|
-
const
|
|
3316
|
-
radius = min(radius, min(
|
|
3318
|
+
const r = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / (fullRadius ? 1 : 2);
|
|
3319
|
+
radius = min(radius, min(r, r * abs(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
|
|
3317
3320
|
}
|
|
3318
3321
|
data.push(U$2, x1, y1, x2, y2, radius);
|
|
3319
3322
|
},
|
|
@@ -3657,7 +3660,7 @@ const PathCorner = {
|
|
|
3657
3660
|
let command, lastCommand, commandLen;
|
|
3658
3661
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3659
3662
|
if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
|
|
3660
|
-
const len = data.length;
|
|
3663
|
+
const len = data.length, three = len === 9;
|
|
3661
3664
|
const smooth = [];
|
|
3662
3665
|
while (i < len) {
|
|
3663
3666
|
command = data[i];
|
|
@@ -3669,7 +3672,7 @@ const PathCorner = {
|
|
|
3669
3672
|
if (data[i] === L$1) {
|
|
3670
3673
|
secondX = data[i + 1];
|
|
3671
3674
|
secondY = data[i + 2];
|
|
3672
|
-
smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
|
|
3675
|
+
three ? smooth.push(M, startX, startY) : smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
|
|
3673
3676
|
} else {
|
|
3674
3677
|
smooth.push(M, startX, startY);
|
|
3675
3678
|
}
|
|
@@ -3681,11 +3684,11 @@ const PathCorner = {
|
|
|
3681
3684
|
i += 3;
|
|
3682
3685
|
switch (data[i]) {
|
|
3683
3686
|
case L$1:
|
|
3684
|
-
arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
|
|
3687
|
+
arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY, three);
|
|
3685
3688
|
break;
|
|
3686
3689
|
|
|
3687
3690
|
case Z:
|
|
3688
|
-
arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
|
|
3691
|
+
arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
|
|
3689
3692
|
break;
|
|
3690
3693
|
|
|
3691
3694
|
default:
|
|
@@ -3697,7 +3700,7 @@ const PathCorner = {
|
|
|
3697
3700
|
|
|
3698
3701
|
case Z:
|
|
3699
3702
|
if (lastCommand !== Z) {
|
|
3700
|
-
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3703
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY, three);
|
|
3701
3704
|
smooth.push(Z);
|
|
3702
3705
|
}
|
|
3703
3706
|
i += 1;
|
|
@@ -3747,10 +3750,10 @@ function canvasPatch(drawer) {
|
|
|
3747
3750
|
const FileHelper = {
|
|
3748
3751
|
alphaPixelTypes: [ "png", "webp", "svg" ],
|
|
3749
3752
|
upperCaseTypeMap: {},
|
|
3750
|
-
|
|
3751
|
-
if (!type || type.startsWith(
|
|
3753
|
+
mimeType(type, base = "image") {
|
|
3754
|
+
if (!type || type.startsWith(base)) return type;
|
|
3752
3755
|
if (type === "jpg") type = "jpeg";
|
|
3753
|
-
return "
|
|
3756
|
+
return base + "/" + type;
|
|
3754
3757
|
},
|
|
3755
3758
|
fileType(filename) {
|
|
3756
3759
|
const l = filename.split(".");
|
|
@@ -3783,6 +3786,8 @@ const FileHelper = {
|
|
|
3783
3786
|
|
|
3784
3787
|
const F = FileHelper;
|
|
3785
3788
|
|
|
3789
|
+
F.mineType = F.mimeType;
|
|
3790
|
+
|
|
3786
3791
|
F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3787
3792
|
|
|
3788
3793
|
const debug$4 = Debug.get("TaskProcessor");
|
|
@@ -4027,6 +4032,9 @@ const debug$3 = Debug.get("Resource");
|
|
|
4027
4032
|
|
|
4028
4033
|
const Resource = {
|
|
4029
4034
|
tasker: new TaskProcessor,
|
|
4035
|
+
queue: new TaskProcessor({
|
|
4036
|
+
parallel: 1
|
|
4037
|
+
}),
|
|
4030
4038
|
map: {},
|
|
4031
4039
|
get isComplete() {
|
|
4032
4040
|
return R.tasker.isComplete;
|
|
@@ -4063,6 +4071,12 @@ const Resource = {
|
|
|
4063
4071
|
R.set(key, value);
|
|
4064
4072
|
return value;
|
|
4065
4073
|
},
|
|
4074
|
+
loadFilm(_key, _format) {
|
|
4075
|
+
return undefined;
|
|
4076
|
+
},
|
|
4077
|
+
loadVideo(_key, _format) {
|
|
4078
|
+
return undefined;
|
|
4079
|
+
},
|
|
4066
4080
|
destroy() {
|
|
4067
4081
|
R.map = {};
|
|
4068
4082
|
}
|
|
@@ -4073,12 +4087,10 @@ const R = Resource;
|
|
|
4073
4087
|
const ImageManager = {
|
|
4074
4088
|
maxRecycled: 10,
|
|
4075
4089
|
recycledList: [],
|
|
4076
|
-
patternTasker:
|
|
4077
|
-
|
|
4078
|
-
}),
|
|
4079
|
-
get(config) {
|
|
4090
|
+
patternTasker: Resource.queue,
|
|
4091
|
+
get(config, type) {
|
|
4080
4092
|
let image = Resource.get(config.url);
|
|
4081
|
-
if (!image) Resource.set(config.url, image = Creator.image(config));
|
|
4093
|
+
if (!image) Resource.set(config.url, image = type === "film" ? Creator.film(config) : Creator.image(config));
|
|
4082
4094
|
image.use++;
|
|
4083
4095
|
return image;
|
|
4084
4096
|
},
|
|
@@ -4113,7 +4125,7 @@ const ImageManager = {
|
|
|
4113
4125
|
if (config.format) return config.format === format;
|
|
4114
4126
|
const {url: url} = config;
|
|
4115
4127
|
if (url.startsWith("data:")) {
|
|
4116
|
-
if (url.startsWith("data:" + FileHelper.
|
|
4128
|
+
if (url.startsWith("data:" + FileHelper.mimeType(format))) return true;
|
|
4117
4129
|
} else {
|
|
4118
4130
|
if (url.includes("." + format) || url.includes("." + FileHelper.upperCaseTypeMap[format])) return true; else if (format === "png" && !url.includes(".")) return true;
|
|
4119
4131
|
}
|
|
@@ -4129,6 +4141,9 @@ const I = ImageManager;
|
|
|
4129
4141
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
4130
4142
|
|
|
4131
4143
|
class LeaferImage {
|
|
4144
|
+
get tag() {
|
|
4145
|
+
return "Image";
|
|
4146
|
+
}
|
|
4132
4147
|
get url() {
|
|
4133
4148
|
return this.config.url;
|
|
4134
4149
|
}
|
|
@@ -4157,7 +4172,7 @@ class LeaferImage {
|
|
|
4157
4172
|
if (!this.loading) {
|
|
4158
4173
|
this.loading = true;
|
|
4159
4174
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
4160
|
-
return yield Platform.origin.
|
|
4175
|
+
return yield Platform.origin["load" + this.tag](this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
|
|
4161
4176
|
if (thumbSize) this.setThumbView(img);
|
|
4162
4177
|
this.setView(img);
|
|
4163
4178
|
}).catch(e => {
|
|
@@ -4231,6 +4246,9 @@ class LeaferImage {
|
|
|
4231
4246
|
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4232
4247
|
return pattern;
|
|
4233
4248
|
}
|
|
4249
|
+
render(canvas, x, y, width, height, _leaf, _paint, _imageScaleX, _imageScaleY) {
|
|
4250
|
+
canvas.drawImage(this.view, x, y, width, height);
|
|
4251
|
+
}
|
|
4234
4252
|
getLoadUrl(_thumbSize) {
|
|
4235
4253
|
return this.url;
|
|
4236
4254
|
}
|
|
@@ -4257,6 +4275,18 @@ class LeaferImage {
|
|
|
4257
4275
|
}
|
|
4258
4276
|
}
|
|
4259
4277
|
|
|
4278
|
+
class LeaferFilm extends LeaferImage {
|
|
4279
|
+
get tag() {
|
|
4280
|
+
return "Film";
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4283
|
+
|
|
4284
|
+
class LeaferVideo extends LeaferImage {
|
|
4285
|
+
get tag() {
|
|
4286
|
+
return "Video";
|
|
4287
|
+
}
|
|
4288
|
+
}
|
|
4289
|
+
|
|
4260
4290
|
function defineKey(target, key, descriptor, noConfigurable) {
|
|
4261
4291
|
if (!noConfigurable) descriptor.configurable = descriptor.enumerable = true;
|
|
4262
4292
|
Object.defineProperty(target, key, descriptor);
|
|
@@ -6145,9 +6175,11 @@ const BranchRender = {
|
|
|
6145
6175
|
if (this.__hasMask) {
|
|
6146
6176
|
this.__renderMask(canvas, options);
|
|
6147
6177
|
} else {
|
|
6178
|
+
let child;
|
|
6148
6179
|
const {children: children} = this;
|
|
6149
6180
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
6150
|
-
|
|
6181
|
+
child = children[i];
|
|
6182
|
+
excludeRenderBounds(child, options) || (child.__.complex ? child.__renderComplex(canvas, options) : child.__render(canvas, options));
|
|
6151
6183
|
}
|
|
6152
6184
|
}
|
|
6153
6185
|
},
|
|
@@ -6628,6 +6660,7 @@ exports.Leaf = class Leaf {
|
|
|
6628
6660
|
__drawHitPath(_canvas) {}
|
|
6629
6661
|
__updateHitCanvas() {}
|
|
6630
6662
|
__render(_canvas, _options) {}
|
|
6663
|
+
__renderComplex(_canvas, _options) {}
|
|
6631
6664
|
__drawFast(_canvas, _options) {}
|
|
6632
6665
|
__draw(_canvas, _options, _originCanvas) {}
|
|
6633
6666
|
__clip(_canvas, _options) {}
|
|
@@ -6747,6 +6780,7 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
6747
6780
|
this.add(item, index);
|
|
6748
6781
|
noIndex || index++;
|
|
6749
6782
|
}); else child = UICreator.get(child.tag, child);
|
|
6783
|
+
if (!child) return;
|
|
6750
6784
|
}
|
|
6751
6785
|
if (child.parent) child.parent.remove(child);
|
|
6752
6786
|
child.parent = this;
|
|
@@ -6972,7 +7006,7 @@ class LeafLevelList {
|
|
|
6972
7006
|
}
|
|
6973
7007
|
}
|
|
6974
7008
|
|
|
6975
|
-
const version = "2.0.
|
|
7009
|
+
const version = "2.0.2";
|
|
6976
7010
|
|
|
6977
7011
|
exports.AlignHelper = AlignHelper;
|
|
6978
7012
|
|
|
@@ -7048,8 +7082,12 @@ exports.LeaferCanvasBase = LeaferCanvasBase;
|
|
|
7048
7082
|
|
|
7049
7083
|
exports.LeaferEvent = LeaferEvent;
|
|
7050
7084
|
|
|
7085
|
+
exports.LeaferFilm = LeaferFilm;
|
|
7086
|
+
|
|
7051
7087
|
exports.LeaferImage = LeaferImage;
|
|
7052
7088
|
|
|
7089
|
+
exports.LeaferVideo = LeaferVideo;
|
|
7090
|
+
|
|
7053
7091
|
exports.MathHelper = MathHelper;
|
|
7054
7092
|
|
|
7055
7093
|
exports.Matrix = Matrix;
|
package/lib/core.esm.js
CHANGED
|
@@ -1718,7 +1718,7 @@ const Platform = {
|
|
|
1718
1718
|
resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
|
|
1719
1719
|
const realWidth = max(floor(width + (xGap || 0)), 1), realHeight = max(floor(height + (yGap || 0)), 1);
|
|
1720
1720
|
let interlaceX, interlaceY, interlaceOffset;
|
|
1721
|
-
if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset,
|
|
1721
|
+
if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, interlace.type === "x" ? width : height))) interlace.type === "x" ? interlaceX = true : interlaceY = true;
|
|
1722
1722
|
const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
|
|
1723
1723
|
const ctx = canvas.getContext("2d");
|
|
1724
1724
|
if (opacity) ctx.globalAlpha = opacity;
|
|
@@ -1888,7 +1888,10 @@ const UICreator = {
|
|
|
1888
1888
|
list$1[tag] = UI;
|
|
1889
1889
|
},
|
|
1890
1890
|
get(tag, data, x, y, width, height) {
|
|
1891
|
-
if (!list$1[tag])
|
|
1891
|
+
if (!list$1[tag]) {
|
|
1892
|
+
debug$9.warn("not register " + tag);
|
|
1893
|
+
return undefined;
|
|
1894
|
+
}
|
|
1892
1895
|
const ui = new list$1[tag](data);
|
|
1893
1896
|
if (!isUndefined(x)) {
|
|
1894
1897
|
ui.x = x;
|
|
@@ -3308,10 +3311,10 @@ const PathCommandDataHelper = {
|
|
|
3308
3311
|
data.push(O$2, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
|
|
3309
3312
|
}
|
|
3310
3313
|
},
|
|
3311
|
-
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
|
|
3314
|
+
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY, fullRadius) {
|
|
3312
3315
|
if (!isUndefined(lastX)) {
|
|
3313
|
-
const
|
|
3314
|
-
radius = min(radius, min(
|
|
3316
|
+
const r = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / (fullRadius ? 1 : 2);
|
|
3317
|
+
radius = min(radius, min(r, r * abs(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
|
|
3315
3318
|
}
|
|
3316
3319
|
data.push(U$2, x1, y1, x2, y2, radius);
|
|
3317
3320
|
},
|
|
@@ -3655,7 +3658,7 @@ const PathCorner = {
|
|
|
3655
3658
|
let command, lastCommand, commandLen;
|
|
3656
3659
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3657
3660
|
if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
|
|
3658
|
-
const len = data.length;
|
|
3661
|
+
const len = data.length, three = len === 9;
|
|
3659
3662
|
const smooth = [];
|
|
3660
3663
|
while (i < len) {
|
|
3661
3664
|
command = data[i];
|
|
@@ -3667,7 +3670,7 @@ const PathCorner = {
|
|
|
3667
3670
|
if (data[i] === L$1) {
|
|
3668
3671
|
secondX = data[i + 1];
|
|
3669
3672
|
secondY = data[i + 2];
|
|
3670
|
-
smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
|
|
3673
|
+
three ? smooth.push(M, startX, startY) : smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
|
|
3671
3674
|
} else {
|
|
3672
3675
|
smooth.push(M, startX, startY);
|
|
3673
3676
|
}
|
|
@@ -3679,11 +3682,11 @@ const PathCorner = {
|
|
|
3679
3682
|
i += 3;
|
|
3680
3683
|
switch (data[i]) {
|
|
3681
3684
|
case L$1:
|
|
3682
|
-
arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
|
|
3685
|
+
arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY, three);
|
|
3683
3686
|
break;
|
|
3684
3687
|
|
|
3685
3688
|
case Z:
|
|
3686
|
-
arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
|
|
3689
|
+
arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
|
|
3687
3690
|
break;
|
|
3688
3691
|
|
|
3689
3692
|
default:
|
|
@@ -3695,7 +3698,7 @@ const PathCorner = {
|
|
|
3695
3698
|
|
|
3696
3699
|
case Z:
|
|
3697
3700
|
if (lastCommand !== Z) {
|
|
3698
|
-
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3701
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY, three);
|
|
3699
3702
|
smooth.push(Z);
|
|
3700
3703
|
}
|
|
3701
3704
|
i += 1;
|
|
@@ -3745,10 +3748,10 @@ function canvasPatch(drawer) {
|
|
|
3745
3748
|
const FileHelper = {
|
|
3746
3749
|
alphaPixelTypes: [ "png", "webp", "svg" ],
|
|
3747
3750
|
upperCaseTypeMap: {},
|
|
3748
|
-
|
|
3749
|
-
if (!type || type.startsWith(
|
|
3751
|
+
mimeType(type, base = "image") {
|
|
3752
|
+
if (!type || type.startsWith(base)) return type;
|
|
3750
3753
|
if (type === "jpg") type = "jpeg";
|
|
3751
|
-
return "
|
|
3754
|
+
return base + "/" + type;
|
|
3752
3755
|
},
|
|
3753
3756
|
fileType(filename) {
|
|
3754
3757
|
const l = filename.split(".");
|
|
@@ -3781,6 +3784,8 @@ const FileHelper = {
|
|
|
3781
3784
|
|
|
3782
3785
|
const F = FileHelper;
|
|
3783
3786
|
|
|
3787
|
+
F.mineType = F.mimeType;
|
|
3788
|
+
|
|
3784
3789
|
F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3785
3790
|
|
|
3786
3791
|
const debug$4 = Debug.get("TaskProcessor");
|
|
@@ -4025,6 +4030,9 @@ const debug$3 = Debug.get("Resource");
|
|
|
4025
4030
|
|
|
4026
4031
|
const Resource = {
|
|
4027
4032
|
tasker: new TaskProcessor,
|
|
4033
|
+
queue: new TaskProcessor({
|
|
4034
|
+
parallel: 1
|
|
4035
|
+
}),
|
|
4028
4036
|
map: {},
|
|
4029
4037
|
get isComplete() {
|
|
4030
4038
|
return R.tasker.isComplete;
|
|
@@ -4061,6 +4069,12 @@ const Resource = {
|
|
|
4061
4069
|
R.set(key, value);
|
|
4062
4070
|
return value;
|
|
4063
4071
|
},
|
|
4072
|
+
loadFilm(_key, _format) {
|
|
4073
|
+
return undefined;
|
|
4074
|
+
},
|
|
4075
|
+
loadVideo(_key, _format) {
|
|
4076
|
+
return undefined;
|
|
4077
|
+
},
|
|
4064
4078
|
destroy() {
|
|
4065
4079
|
R.map = {};
|
|
4066
4080
|
}
|
|
@@ -4071,12 +4085,10 @@ const R = Resource;
|
|
|
4071
4085
|
const ImageManager = {
|
|
4072
4086
|
maxRecycled: 10,
|
|
4073
4087
|
recycledList: [],
|
|
4074
|
-
patternTasker:
|
|
4075
|
-
|
|
4076
|
-
}),
|
|
4077
|
-
get(config) {
|
|
4088
|
+
patternTasker: Resource.queue,
|
|
4089
|
+
get(config, type) {
|
|
4078
4090
|
let image = Resource.get(config.url);
|
|
4079
|
-
if (!image) Resource.set(config.url, image = Creator.image(config));
|
|
4091
|
+
if (!image) Resource.set(config.url, image = type === "film" ? Creator.film(config) : Creator.image(config));
|
|
4080
4092
|
image.use++;
|
|
4081
4093
|
return image;
|
|
4082
4094
|
},
|
|
@@ -4111,7 +4123,7 @@ const ImageManager = {
|
|
|
4111
4123
|
if (config.format) return config.format === format;
|
|
4112
4124
|
const {url: url} = config;
|
|
4113
4125
|
if (url.startsWith("data:")) {
|
|
4114
|
-
if (url.startsWith("data:" + FileHelper.
|
|
4126
|
+
if (url.startsWith("data:" + FileHelper.mimeType(format))) return true;
|
|
4115
4127
|
} else {
|
|
4116
4128
|
if (url.includes("." + format) || url.includes("." + FileHelper.upperCaseTypeMap[format])) return true; else if (format === "png" && !url.includes(".")) return true;
|
|
4117
4129
|
}
|
|
@@ -4127,6 +4139,9 @@ const I = ImageManager;
|
|
|
4127
4139
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
4128
4140
|
|
|
4129
4141
|
class LeaferImage {
|
|
4142
|
+
get tag() {
|
|
4143
|
+
return "Image";
|
|
4144
|
+
}
|
|
4130
4145
|
get url() {
|
|
4131
4146
|
return this.config.url;
|
|
4132
4147
|
}
|
|
@@ -4155,7 +4170,7 @@ class LeaferImage {
|
|
|
4155
4170
|
if (!this.loading) {
|
|
4156
4171
|
this.loading = true;
|
|
4157
4172
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
4158
|
-
return yield Platform.origin.
|
|
4173
|
+
return yield Platform.origin["load" + this.tag](this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
|
|
4159
4174
|
if (thumbSize) this.setThumbView(img);
|
|
4160
4175
|
this.setView(img);
|
|
4161
4176
|
}).catch(e => {
|
|
@@ -4229,6 +4244,9 @@ class LeaferImage {
|
|
|
4229
4244
|
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4230
4245
|
return pattern;
|
|
4231
4246
|
}
|
|
4247
|
+
render(canvas, x, y, width, height, _leaf, _paint, _imageScaleX, _imageScaleY) {
|
|
4248
|
+
canvas.drawImage(this.view, x, y, width, height);
|
|
4249
|
+
}
|
|
4232
4250
|
getLoadUrl(_thumbSize) {
|
|
4233
4251
|
return this.url;
|
|
4234
4252
|
}
|
|
@@ -4255,6 +4273,18 @@ class LeaferImage {
|
|
|
4255
4273
|
}
|
|
4256
4274
|
}
|
|
4257
4275
|
|
|
4276
|
+
class LeaferFilm extends LeaferImage {
|
|
4277
|
+
get tag() {
|
|
4278
|
+
return "Film";
|
|
4279
|
+
}
|
|
4280
|
+
}
|
|
4281
|
+
|
|
4282
|
+
class LeaferVideo extends LeaferImage {
|
|
4283
|
+
get tag() {
|
|
4284
|
+
return "Video";
|
|
4285
|
+
}
|
|
4286
|
+
}
|
|
4287
|
+
|
|
4258
4288
|
function defineKey(target, key, descriptor, noConfigurable) {
|
|
4259
4289
|
if (!noConfigurable) descriptor.configurable = descriptor.enumerable = true;
|
|
4260
4290
|
Object.defineProperty(target, key, descriptor);
|
|
@@ -6143,9 +6173,11 @@ const BranchRender = {
|
|
|
6143
6173
|
if (this.__hasMask) {
|
|
6144
6174
|
this.__renderMask(canvas, options);
|
|
6145
6175
|
} else {
|
|
6176
|
+
let child;
|
|
6146
6177
|
const {children: children} = this;
|
|
6147
6178
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
6148
|
-
|
|
6179
|
+
child = children[i];
|
|
6180
|
+
excludeRenderBounds(child, options) || (child.__.complex ? child.__renderComplex(canvas, options) : child.__render(canvas, options));
|
|
6149
6181
|
}
|
|
6150
6182
|
}
|
|
6151
6183
|
},
|
|
@@ -6626,6 +6658,7 @@ let Leaf = class Leaf {
|
|
|
6626
6658
|
__drawHitPath(_canvas) {}
|
|
6627
6659
|
__updateHitCanvas() {}
|
|
6628
6660
|
__render(_canvas, _options) {}
|
|
6661
|
+
__renderComplex(_canvas, _options) {}
|
|
6629
6662
|
__drawFast(_canvas, _options) {}
|
|
6630
6663
|
__draw(_canvas, _options, _originCanvas) {}
|
|
6631
6664
|
__clip(_canvas, _options) {}
|
|
@@ -6745,6 +6778,7 @@ let Branch = class Branch extends Leaf {
|
|
|
6745
6778
|
this.add(item, index);
|
|
6746
6779
|
noIndex || index++;
|
|
6747
6780
|
}); else child = UICreator.get(child.tag, child);
|
|
6781
|
+
if (!child) return;
|
|
6748
6782
|
}
|
|
6749
6783
|
if (child.parent) child.parent.remove(child);
|
|
6750
6784
|
child.parent = this;
|
|
@@ -6970,6 +7004,6 @@ class LeafLevelList {
|
|
|
6970
7004
|
}
|
|
6971
7005
|
}
|
|
6972
7006
|
|
|
6973
|
-
const version = "2.0.
|
|
7007
|
+
const version = "2.0.2";
|
|
6974
7008
|
|
|
6975
|
-
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, FourNumberHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, UnitConvertHelper, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, 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, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useModule, version, visibleType };
|
|
7009
|
+
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, FourNumberHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferFilm, LeaferImage, LeaferVideo, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, UnitConvertHelper, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, 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, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useModule, version, visibleType };
|