leafer-draw 2.0.1 → 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/web.cjs +94 -69
- package/dist/web.esm.js +82 -71
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +141 -90
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +146 -95
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +3 -3
package/dist/web.js
CHANGED
|
@@ -7,6 +7,42 @@ var LeaferUI = function(exports) {
|
|
|
7
7
|
PathNodeHandleType[PathNodeHandleType["mirrorAngle"] = 3] = "mirrorAngle";
|
|
8
8
|
PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
|
|
9
9
|
})(exports.PathNodeHandleType || (exports.PathNodeHandleType = {}));
|
|
10
|
+
function __decorate(decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
}
|
|
15
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) {
|
|
17
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
22
|
+
function fulfilled(value) {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function rejected(value) {
|
|
30
|
+
try {
|
|
31
|
+
step(generator["throw"](value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function step(result) {
|
|
37
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
38
|
+
}
|
|
39
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
43
|
+
var e = new Error(message);
|
|
44
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
45
|
+
};
|
|
10
46
|
exports.Answer = void 0;
|
|
11
47
|
(function(Answer) {
|
|
12
48
|
Answer[Answer["No"] = 0] = "No";
|
|
@@ -1803,7 +1839,10 @@ var LeaferUI = function(exports) {
|
|
|
1803
1839
|
list$1[tag] = UI;
|
|
1804
1840
|
},
|
|
1805
1841
|
get(tag, data, x, y, width, height) {
|
|
1806
|
-
if (!list$1[tag])
|
|
1842
|
+
if (!list$1[tag]) {
|
|
1843
|
+
debug$e.warn("not register " + tag);
|
|
1844
|
+
return undefined;
|
|
1845
|
+
}
|
|
1807
1846
|
const ui = new list$1[tag](data);
|
|
1808
1847
|
if (!isUndefined(x)) {
|
|
1809
1848
|
ui.x = x;
|
|
@@ -1888,42 +1927,6 @@ var LeaferUI = function(exports) {
|
|
|
1888
1927
|
this.clear();
|
|
1889
1928
|
}
|
|
1890
1929
|
}
|
|
1891
|
-
function __decorate(decorators, target, key, desc) {
|
|
1892
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1893
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1894
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1895
|
-
}
|
|
1896
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1897
|
-
function adopt(value) {
|
|
1898
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
1899
|
-
resolve(value);
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1903
|
-
function fulfilled(value) {
|
|
1904
|
-
try {
|
|
1905
|
-
step(generator.next(value));
|
|
1906
|
-
} catch (e) {
|
|
1907
|
-
reject(e);
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
function rejected(value) {
|
|
1911
|
-
try {
|
|
1912
|
-
step(generator["throw"](value));
|
|
1913
|
-
} catch (e) {
|
|
1914
|
-
reject(e);
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
function step(result) {
|
|
1918
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1919
|
-
}
|
|
1920
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1921
|
-
});
|
|
1922
|
-
}
|
|
1923
|
-
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
1924
|
-
var e = new Error(message);
|
|
1925
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1926
|
-
};
|
|
1927
1930
|
function contextAttr(realName) {
|
|
1928
1931
|
return (target, key) => {
|
|
1929
1932
|
if (!realName) realName = key;
|
|
@@ -3523,10 +3526,10 @@ var LeaferUI = function(exports) {
|
|
|
3523
3526
|
const FileHelper = {
|
|
3524
3527
|
alphaPixelTypes: [ "png", "webp", "svg" ],
|
|
3525
3528
|
upperCaseTypeMap: {},
|
|
3526
|
-
|
|
3527
|
-
if (!type || type.startsWith(
|
|
3529
|
+
mimeType(type, base = "image") {
|
|
3530
|
+
if (!type || type.startsWith(base)) return type;
|
|
3528
3531
|
if (type === "jpg") type = "jpeg";
|
|
3529
|
-
return "
|
|
3532
|
+
return base + "/" + type;
|
|
3530
3533
|
},
|
|
3531
3534
|
fileType(filename) {
|
|
3532
3535
|
const l = filename.split(".");
|
|
@@ -3557,6 +3560,7 @@ var LeaferUI = function(exports) {
|
|
|
3557
3560
|
}
|
|
3558
3561
|
};
|
|
3559
3562
|
const F = FileHelper;
|
|
3563
|
+
F.mineType = F.mimeType;
|
|
3560
3564
|
F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3561
3565
|
const debug$9 = Debug.get("TaskProcessor");
|
|
3562
3566
|
class TaskItem {
|
|
@@ -3796,6 +3800,9 @@ var LeaferUI = function(exports) {
|
|
|
3796
3800
|
const debug$8 = Debug.get("Resource");
|
|
3797
3801
|
const Resource = {
|
|
3798
3802
|
tasker: new TaskProcessor,
|
|
3803
|
+
queue: new TaskProcessor({
|
|
3804
|
+
parallel: 1
|
|
3805
|
+
}),
|
|
3799
3806
|
map: {},
|
|
3800
3807
|
get isComplete() {
|
|
3801
3808
|
return R.tasker.isComplete;
|
|
@@ -3832,6 +3839,12 @@ var LeaferUI = function(exports) {
|
|
|
3832
3839
|
R.set(key, value);
|
|
3833
3840
|
return value;
|
|
3834
3841
|
},
|
|
3842
|
+
loadFilm(_key, _format) {
|
|
3843
|
+
return undefined;
|
|
3844
|
+
},
|
|
3845
|
+
loadVideo(_key, _format) {
|
|
3846
|
+
return undefined;
|
|
3847
|
+
},
|
|
3835
3848
|
destroy() {
|
|
3836
3849
|
R.map = {};
|
|
3837
3850
|
}
|
|
@@ -3840,12 +3853,10 @@ var LeaferUI = function(exports) {
|
|
|
3840
3853
|
const ImageManager = {
|
|
3841
3854
|
maxRecycled: 10,
|
|
3842
3855
|
recycledList: [],
|
|
3843
|
-
patternTasker:
|
|
3844
|
-
|
|
3845
|
-
}),
|
|
3846
|
-
get(config) {
|
|
3856
|
+
patternTasker: Resource.queue,
|
|
3857
|
+
get(config, type) {
|
|
3847
3858
|
let image = Resource.get(config.url);
|
|
3848
|
-
if (!image) Resource.set(config.url, image = Creator.image(config));
|
|
3859
|
+
if (!image) Resource.set(config.url, image = type === "film" ? Creator.film(config) : Creator.image(config));
|
|
3849
3860
|
image.use++;
|
|
3850
3861
|
return image;
|
|
3851
3862
|
},
|
|
@@ -3880,7 +3891,7 @@ var LeaferUI = function(exports) {
|
|
|
3880
3891
|
if (config.format) return config.format === format;
|
|
3881
3892
|
const {url: url} = config;
|
|
3882
3893
|
if (url.startsWith("data:")) {
|
|
3883
|
-
if (url.startsWith("data:" + FileHelper.
|
|
3894
|
+
if (url.startsWith("data:" + FileHelper.mimeType(format))) return true;
|
|
3884
3895
|
} else {
|
|
3885
3896
|
if (url.includes("." + format) || url.includes("." + FileHelper.upperCaseTypeMap[format])) return true; else if (format === "png" && !url.includes(".")) return true;
|
|
3886
3897
|
}
|
|
@@ -3893,6 +3904,9 @@ var LeaferUI = function(exports) {
|
|
|
3893
3904
|
const I = ImageManager;
|
|
3894
3905
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
3895
3906
|
class LeaferImage {
|
|
3907
|
+
get tag() {
|
|
3908
|
+
return "Image";
|
|
3909
|
+
}
|
|
3896
3910
|
get url() {
|
|
3897
3911
|
return this.config.url;
|
|
3898
3912
|
}
|
|
@@ -3921,7 +3935,7 @@ var LeaferUI = function(exports) {
|
|
|
3921
3935
|
if (!this.loading) {
|
|
3922
3936
|
this.loading = true;
|
|
3923
3937
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
3924
|
-
return yield Platform.origin.
|
|
3938
|
+
return yield Platform.origin["load" + this.tag](this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
|
|
3925
3939
|
if (thumbSize) this.setThumbView(img);
|
|
3926
3940
|
this.setView(img);
|
|
3927
3941
|
}).catch(e => {
|
|
@@ -3995,6 +4009,9 @@ var LeaferUI = function(exports) {
|
|
|
3995
4009
|
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
3996
4010
|
return pattern;
|
|
3997
4011
|
}
|
|
4012
|
+
render(canvas, x, y, width, height, _leaf, _paint, _imageScaleX, _imageScaleY) {
|
|
4013
|
+
canvas.drawImage(this.view, x, y, width, height);
|
|
4014
|
+
}
|
|
3998
4015
|
getLoadUrl(_thumbSize) {
|
|
3999
4016
|
return this.url;
|
|
4000
4017
|
}
|
|
@@ -4020,6 +4037,16 @@ var LeaferUI = function(exports) {
|
|
|
4020
4037
|
this.waitComplete.length = 0;
|
|
4021
4038
|
}
|
|
4022
4039
|
}
|
|
4040
|
+
class LeaferFilm extends LeaferImage {
|
|
4041
|
+
get tag() {
|
|
4042
|
+
return "Film";
|
|
4043
|
+
}
|
|
4044
|
+
}
|
|
4045
|
+
class LeaferVideo extends LeaferImage {
|
|
4046
|
+
get tag() {
|
|
4047
|
+
return "Video";
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4023
4050
|
function defineKey(target, key, descriptor, noConfigurable) {
|
|
4024
4051
|
if (!noConfigurable) descriptor.configurable = descriptor.enumerable = true;
|
|
4025
4052
|
Object.defineProperty(target, key, descriptor);
|
|
@@ -5758,9 +5785,11 @@ var LeaferUI = function(exports) {
|
|
|
5758
5785
|
if (this.__hasMask) {
|
|
5759
5786
|
this.__renderMask(canvas, options);
|
|
5760
5787
|
} else {
|
|
5788
|
+
let child;
|
|
5761
5789
|
const {children: children} = this;
|
|
5762
5790
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
5763
|
-
|
|
5791
|
+
child = children[i];
|
|
5792
|
+
excludeRenderBounds$1(child, options) || (child.__.complex ? child.__renderComplex(canvas, options) : child.__render(canvas, options));
|
|
5764
5793
|
}
|
|
5765
5794
|
}
|
|
5766
5795
|
},
|
|
@@ -6233,6 +6262,7 @@ var LeaferUI = function(exports) {
|
|
|
6233
6262
|
__drawHitPath(_canvas) {}
|
|
6234
6263
|
__updateHitCanvas() {}
|
|
6235
6264
|
__render(_canvas, _options) {}
|
|
6265
|
+
__renderComplex(_canvas, _options) {}
|
|
6236
6266
|
__drawFast(_canvas, _options) {}
|
|
6237
6267
|
__draw(_canvas, _options, _originCanvas) {}
|
|
6238
6268
|
__clip(_canvas, _options) {}
|
|
@@ -6346,6 +6376,7 @@ var LeaferUI = function(exports) {
|
|
|
6346
6376
|
this.add(item, index);
|
|
6347
6377
|
noIndex || index++;
|
|
6348
6378
|
}); else child = UICreator.get(child.tag, child);
|
|
6379
|
+
if (!child) return;
|
|
6349
6380
|
}
|
|
6350
6381
|
if (child.parent) child.parent.remove(child);
|
|
6351
6382
|
child.parent = this;
|
|
@@ -6567,7 +6598,7 @@ var LeaferUI = function(exports) {
|
|
|
6567
6598
|
this.levelMap = null;
|
|
6568
6599
|
}
|
|
6569
6600
|
}
|
|
6570
|
-
const version = "2.0.
|
|
6601
|
+
const version = "2.0.2";
|
|
6571
6602
|
const debug$4 = Debug.get("LeaferCanvas");
|
|
6572
6603
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6573
6604
|
set zIndex(zIndex) {
|
|
@@ -6767,7 +6798,6 @@ var LeaferUI = function(exports) {
|
|
|
6767
6798
|
}
|
|
6768
6799
|
canvasPatch(CanvasRenderingContext2D.prototype);
|
|
6769
6800
|
canvasPatch(Path2D.prototype);
|
|
6770
|
-
const {mineType: mineType, fileType: fileType} = FileHelper;
|
|
6771
6801
|
Object.assign(Creator, {
|
|
6772
6802
|
canvas: (options, manager) => new LeaferCanvas(options, manager),
|
|
6773
6803
|
image: options => new LeaferImage(options)
|
|
@@ -6781,29 +6811,27 @@ var LeaferUI = function(exports) {
|
|
|
6781
6811
|
return canvas;
|
|
6782
6812
|
},
|
|
6783
6813
|
canvasToDataURL: (canvas, type, quality) => {
|
|
6784
|
-
const imageType =
|
|
6814
|
+
const imageType = FileHelper.mimeType(type), url = canvas.toDataURL(imageType, quality);
|
|
6785
6815
|
return imageType === "image/bmp" ? url.replace("image/png;", "image/bmp;") : url;
|
|
6786
6816
|
},
|
|
6787
|
-
canvasToBolb: (canvas, type, quality) => new Promise(resolve => canvas.toBlob(resolve,
|
|
6817
|
+
canvasToBolb: (canvas, type, quality) => new Promise(resolve => canvas.toBlob(resolve, FileHelper.mimeType(type), quality)),
|
|
6788
6818
|
canvasSaveAs: (canvas, filename, quality) => {
|
|
6789
|
-
const url = canvas.toDataURL(
|
|
6819
|
+
const url = canvas.toDataURL(FileHelper.mimeType(FileHelper.fileType(filename)), quality);
|
|
6790
6820
|
return Platform.origin.download(url, filename);
|
|
6791
6821
|
},
|
|
6792
6822
|
download(url, filename) {
|
|
6793
|
-
return
|
|
6823
|
+
return __awaiter(this, void 0, void 0, function*() {
|
|
6794
6824
|
let el = document.createElement("a");
|
|
6795
6825
|
el.href = url;
|
|
6796
6826
|
el.download = filename;
|
|
6797
6827
|
document.body.appendChild(el);
|
|
6798
6828
|
el.click();
|
|
6799
6829
|
document.body.removeChild(el);
|
|
6800
|
-
resolve();
|
|
6801
6830
|
});
|
|
6802
6831
|
},
|
|
6803
|
-
loadImage(src) {
|
|
6832
|
+
loadImage(src, crossOrigin, _leaferImage) {
|
|
6804
6833
|
return new Promise((resolve, reject) => {
|
|
6805
6834
|
const img = new Platform.origin.Image;
|
|
6806
|
-
const {crossOrigin: crossOrigin} = Platform.image;
|
|
6807
6835
|
if (crossOrigin) {
|
|
6808
6836
|
img.setAttribute("crossOrigin", crossOrigin);
|
|
6809
6837
|
img.crossOrigin = crossOrigin;
|
|
@@ -6817,6 +6845,13 @@ var LeaferUI = function(exports) {
|
|
|
6817
6845
|
img.src = Platform.image.getRealURL(src);
|
|
6818
6846
|
});
|
|
6819
6847
|
},
|
|
6848
|
+
loadContent(url_1) {
|
|
6849
|
+
return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
|
|
6850
|
+
const response = yield fetch(url);
|
|
6851
|
+
if (!response.ok) throw new Error(`${response.status}`);
|
|
6852
|
+
return yield response[responseType]();
|
|
6853
|
+
});
|
|
6854
|
+
},
|
|
6820
6855
|
Image: Image,
|
|
6821
6856
|
PointerEvent: PointerEvent,
|
|
6822
6857
|
DragEvent: DragEvent
|
|
@@ -7308,7 +7343,7 @@ var LeaferUI = function(exports) {
|
|
|
7308
7343
|
getCellList() {
|
|
7309
7344
|
return undefined;
|
|
7310
7345
|
}
|
|
7311
|
-
addBlock(block) {
|
|
7346
|
+
addBlock(block, _leafList) {
|
|
7312
7347
|
if (!this.updateBlocks) this.updateBlocks = [];
|
|
7313
7348
|
this.updateBlocks.push(block);
|
|
7314
7349
|
}
|
|
@@ -7356,7 +7391,8 @@ var LeaferUI = function(exports) {
|
|
|
7356
7391
|
__onLayoutEnd(event) {
|
|
7357
7392
|
if (event.data) event.data.map(item => {
|
|
7358
7393
|
let empty;
|
|
7359
|
-
|
|
7394
|
+
const {updatedList: updatedList} = item;
|
|
7395
|
+
if (updatedList) updatedList.list.some(leaf => {
|
|
7360
7396
|
empty = !leaf.__world.width || !leaf.__world.height;
|
|
7361
7397
|
if (empty) {
|
|
7362
7398
|
if (!leaf.isLeafer) debug$2.tip(leaf.innerName, ": empty");
|
|
@@ -7364,7 +7400,7 @@ var LeaferUI = function(exports) {
|
|
|
7364
7400
|
}
|
|
7365
7401
|
return empty;
|
|
7366
7402
|
});
|
|
7367
|
-
this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
|
|
7403
|
+
this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
|
|
7368
7404
|
});
|
|
7369
7405
|
}
|
|
7370
7406
|
emitRender(type, bounds, options) {
|
|
@@ -7731,13 +7767,16 @@ var LeaferUI = function(exports) {
|
|
|
7731
7767
|
}
|
|
7732
7768
|
}
|
|
7733
7769
|
class ImageData extends RectData {
|
|
7770
|
+
get __urlType() {
|
|
7771
|
+
return "image";
|
|
7772
|
+
}
|
|
7734
7773
|
setUrl(value) {
|
|
7735
7774
|
this.__setImageFill(value);
|
|
7736
7775
|
this._url = value;
|
|
7737
7776
|
}
|
|
7738
7777
|
__setImageFill(value) {
|
|
7739
7778
|
this.fill = value ? {
|
|
7740
|
-
type:
|
|
7779
|
+
type: this.__urlType,
|
|
7741
7780
|
mode: "stretch",
|
|
7742
7781
|
url: value
|
|
7743
7782
|
} : undefined;
|
|
@@ -8153,7 +8192,10 @@ var LeaferUI = function(exports) {
|
|
|
8153
8192
|
}
|
|
8154
8193
|
toJSON(options) {
|
|
8155
8194
|
const data = super.toJSON(options);
|
|
8156
|
-
if (!this.childlessJSON)
|
|
8195
|
+
if (!this.childlessJSON) {
|
|
8196
|
+
const children = data.children = [];
|
|
8197
|
+
this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)));
|
|
8198
|
+
}
|
|
8157
8199
|
return data;
|
|
8158
8200
|
}
|
|
8159
8201
|
pick(_hitPoint, _options) {
|
|
@@ -8295,12 +8337,12 @@ var LeaferUI = function(exports) {
|
|
|
8295
8337
|
this.emitLeafer(LeaferEvent.STOP);
|
|
8296
8338
|
}
|
|
8297
8339
|
}
|
|
8298
|
-
unlockLayout() {
|
|
8340
|
+
unlockLayout(updateLayout = true) {
|
|
8299
8341
|
this.layouter.start();
|
|
8300
|
-
this.updateLayout();
|
|
8342
|
+
if (updateLayout) this.updateLayout();
|
|
8301
8343
|
}
|
|
8302
|
-
lockLayout() {
|
|
8303
|
-
this.updateLayout();
|
|
8344
|
+
lockLayout(updateLayout = true) {
|
|
8345
|
+
if (updateLayout) this.updateLayout();
|
|
8304
8346
|
this.layouter.stop();
|
|
8305
8347
|
}
|
|
8306
8348
|
resize(size) {
|
|
@@ -9347,11 +9389,14 @@ var LeaferUI = function(exports) {
|
|
|
9347
9389
|
function getLeafPaint(attrName, paint, ui) {
|
|
9348
9390
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
9349
9391
|
let leafPaint;
|
|
9350
|
-
const {boxBounds: boxBounds} = ui.__layout;
|
|
9351
|
-
switch (
|
|
9392
|
+
const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
|
|
9393
|
+
switch (type) {
|
|
9352
9394
|
case "image":
|
|
9395
|
+
case "film":
|
|
9396
|
+
case "video":
|
|
9353
9397
|
if (!paint.url) return undefined;
|
|
9354
9398
|
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
9399
|
+
if (type !== "image") PaintImage[type](leafPaint);
|
|
9355
9400
|
break;
|
|
9356
9401
|
|
|
9357
9402
|
case "linear":
|
|
@@ -9367,7 +9412,7 @@ var LeaferUI = function(exports) {
|
|
|
9367
9412
|
break;
|
|
9368
9413
|
|
|
9369
9414
|
case "solid":
|
|
9370
|
-
const {
|
|
9415
|
+
const {color: color, opacity: opacity} = paint;
|
|
9371
9416
|
leafPaint = {
|
|
9372
9417
|
type: type,
|
|
9373
9418
|
style: ColorConvert.string(color, opacity)
|
|
@@ -9407,7 +9452,7 @@ var LeaferUI = function(exports) {
|
|
|
9407
9452
|
const {isSame: isSame} = BoundsHelper;
|
|
9408
9453
|
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
9409
9454
|
let leafPaint, event;
|
|
9410
|
-
const image = ImageManager.get(paint);
|
|
9455
|
+
const image = ImageManager.get(paint, paint.type);
|
|
9411
9456
|
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
9412
9457
|
leafPaint = cache.leafPaint;
|
|
9413
9458
|
} else {
|
|
@@ -9467,8 +9512,8 @@ var LeaferUI = function(exports) {
|
|
|
9467
9512
|
return leafPaint;
|
|
9468
9513
|
}
|
|
9469
9514
|
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
9470
|
-
|
|
9471
|
-
|
|
9515
|
+
const data = ui.__;
|
|
9516
|
+
if (attrName === "fill" && !data.__naturalWidth) {
|
|
9472
9517
|
data.__naturalWidth = image.width / data.pixelRatio;
|
|
9473
9518
|
data.__naturalHeight = image.height / data.pixelRatio;
|
|
9474
9519
|
if (data.__autoSide) {
|
|
@@ -9480,7 +9525,12 @@ var LeaferUI = function(exports) {
|
|
|
9480
9525
|
return false;
|
|
9481
9526
|
}
|
|
9482
9527
|
}
|
|
9483
|
-
if (!leafPaint.data)
|
|
9528
|
+
if (!leafPaint.data) {
|
|
9529
|
+
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
9530
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
|
|
9531
|
+
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
9532
|
+
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
9533
|
+
}
|
|
9484
9534
|
return true;
|
|
9485
9535
|
}
|
|
9486
9536
|
function onLoad(ui, event) {
|
|
@@ -9512,7 +9562,7 @@ var LeaferUI = function(exports) {
|
|
|
9512
9562
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
9513
9563
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
9514
9564
|
const {width: width, height: height} = image;
|
|
9515
|
-
const {
|
|
9565
|
+
const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
|
|
9516
9566
|
const sameBox = box.width === width && box.height === height;
|
|
9517
9567
|
const data = {
|
|
9518
9568
|
mode: mode
|
|
@@ -9575,8 +9625,6 @@ var LeaferUI = function(exports) {
|
|
|
9575
9625
|
data.scaleX = scaleX;
|
|
9576
9626
|
data.scaleY = scaleY;
|
|
9577
9627
|
}
|
|
9578
|
-
if (opacity && opacity < 1) data.opacity = opacity;
|
|
9579
|
-
if (filters) data.filters = filters;
|
|
9580
9628
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
9581
9629
|
if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
|
|
9582
9630
|
type: "x",
|
|
@@ -9602,7 +9650,7 @@ var LeaferUI = function(exports) {
|
|
|
9602
9650
|
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
9603
9651
|
function stretchMode(data, box, scaleX, scaleY) {
|
|
9604
9652
|
const transform = get$2(), {x: x, y: y} = box;
|
|
9605
|
-
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
9653
|
+
if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
|
|
9606
9654
|
scaleHelper(transform, scaleX, scaleY);
|
|
9607
9655
|
data.transform = transform;
|
|
9608
9656
|
}
|
|
@@ -9683,10 +9731,10 @@ var LeaferUI = function(exports) {
|
|
|
9683
9731
|
}
|
|
9684
9732
|
}
|
|
9685
9733
|
function createPattern(paint, ui, canvas, renderOptions) {
|
|
9686
|
-
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
9734
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
9687
9735
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
9688
9736
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
9689
|
-
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
9737
|
+
const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
9690
9738
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
9691
9739
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
9692
9740
|
width *= scaleX;
|
|
@@ -9702,7 +9750,7 @@ var LeaferUI = function(exports) {
|
|
|
9702
9750
|
if (transform) copy$1(imageMatrix, transform);
|
|
9703
9751
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
9704
9752
|
}
|
|
9705
|
-
const imageCanvas = image.getCanvas(width, height,
|
|
9753
|
+
const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
9706
9754
|
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
9707
9755
|
paint.style = pattern;
|
|
9708
9756
|
paint.patternId = id;
|
|
@@ -9721,15 +9769,15 @@ var LeaferUI = function(exports) {
|
|
|
9721
9769
|
return fixScale;
|
|
9722
9770
|
}
|
|
9723
9771
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
9724
|
-
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
9772
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
9725
9773
|
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
9726
|
-
if (!data || paint.patternId ===
|
|
9774
|
+
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
9727
9775
|
return false;
|
|
9728
9776
|
} else {
|
|
9729
9777
|
if (drawImage) {
|
|
9730
9778
|
if (data.repeat) {
|
|
9731
9779
|
drawImage = false;
|
|
9732
|
-
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
9780
|
+
} else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
9733
9781
|
drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
|
|
9734
9782
|
}
|
|
9735
9783
|
}
|
|
@@ -9746,20 +9794,21 @@ var LeaferUI = function(exports) {
|
|
|
9746
9794
|
}
|
|
9747
9795
|
}
|
|
9748
9796
|
}
|
|
9749
|
-
function drawImage(paint,
|
|
9750
|
-
const {data: data, image: image
|
|
9751
|
-
let {width: width, height: height} = image
|
|
9752
|
-
if (
|
|
9797
|
+
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
9798
|
+
const {data: data, image: image, complex: complex} = paint;
|
|
9799
|
+
let {width: width, height: height} = image;
|
|
9800
|
+
if (complex) {
|
|
9801
|
+
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
9753
9802
|
canvas.save();
|
|
9754
|
-
|
|
9803
|
+
complex === 2 && canvas.clipUI(ui);
|
|
9755
9804
|
blendMode && (canvas.blendMode = blendMode);
|
|
9756
9805
|
opacity && (canvas.opacity *= opacity);
|
|
9757
9806
|
transform && canvas.transform(transform);
|
|
9758
|
-
|
|
9807
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
9759
9808
|
canvas.restore();
|
|
9760
9809
|
} else {
|
|
9761
9810
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
9762
|
-
|
|
9811
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
9763
9812
|
}
|
|
9764
9813
|
}
|
|
9765
9814
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
@@ -10646,7 +10695,9 @@ var LeaferUI = function(exports) {
|
|
|
10646
10695
|
exports.LeaferCanvasBase = LeaferCanvasBase;
|
|
10647
10696
|
exports.LeaferData = LeaferData;
|
|
10648
10697
|
exports.LeaferEvent = LeaferEvent;
|
|
10698
|
+
exports.LeaferFilm = LeaferFilm;
|
|
10649
10699
|
exports.LeaferImage = LeaferImage;
|
|
10700
|
+
exports.LeaferVideo = LeaferVideo;
|
|
10650
10701
|
exports.LineData = LineData;
|
|
10651
10702
|
exports.MathHelper = MathHelper;
|
|
10652
10703
|
exports.Matrix = Matrix;
|