@leafer-ui/node 1.0.0-rc.6 → 1.0.0-rc.7
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/node.cjs +132 -90
- package/dist/node.esm.js +135 -93
- package/dist/node.esm.min.js +1 -1
- package/dist/node.min.cjs +1 -1
- package/package.json +6 -6
package/dist/node.cjs
CHANGED
|
@@ -42,7 +42,7 @@ class Watcher {
|
|
|
42
42
|
if (this.hasRemove) {
|
|
43
43
|
const updatedList = new core.LeafList();
|
|
44
44
|
this.__updatedList.list.forEach(item => { if (item.leafer)
|
|
45
|
-
updatedList.
|
|
45
|
+
updatedList.add(item); });
|
|
46
46
|
return updatedList;
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
@@ -77,7 +77,7 @@ class Watcher {
|
|
|
77
77
|
this.target.emit(core.RenderEvent.REQUEST);
|
|
78
78
|
}
|
|
79
79
|
__onAttrChange(event) {
|
|
80
|
-
this.__updatedList.
|
|
80
|
+
this.__updatedList.add(event.target);
|
|
81
81
|
this.update();
|
|
82
82
|
}
|
|
83
83
|
__onChildEvent(event) {
|
|
@@ -87,12 +87,12 @@ class Watcher {
|
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
89
|
this.hasRemove = true;
|
|
90
|
-
this.__updatedList.
|
|
90
|
+
this.__updatedList.add(event.parent);
|
|
91
91
|
}
|
|
92
92
|
this.update();
|
|
93
93
|
}
|
|
94
94
|
__pushChild(child) {
|
|
95
|
-
this.__updatedList.
|
|
95
|
+
this.__updatedList.add(child);
|
|
96
96
|
if (child.isBranch)
|
|
97
97
|
this.__loopChildren(child);
|
|
98
98
|
}
|
|
@@ -131,7 +131,7 @@ class Watcher {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
const {
|
|
134
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = core.LeafHelper;
|
|
135
135
|
const { pushAllChildBranch, pushAllParent } = core.BranchHelper;
|
|
136
136
|
function updateMatrix(updateList, levelList) {
|
|
137
137
|
let layout;
|
|
@@ -139,14 +139,14 @@ function updateMatrix(updateList, levelList) {
|
|
|
139
139
|
layout = leaf.__layout;
|
|
140
140
|
if (levelList.without(leaf) && !layout.proxyZoom) {
|
|
141
141
|
if (layout.matrixChanged) {
|
|
142
|
-
|
|
143
|
-
levelList.
|
|
142
|
+
updateAllMatrix$1(leaf, true);
|
|
143
|
+
levelList.add(leaf);
|
|
144
144
|
if (leaf.isBranch)
|
|
145
145
|
pushAllChildBranch(leaf, levelList);
|
|
146
146
|
pushAllParent(leaf, levelList);
|
|
147
147
|
}
|
|
148
148
|
else if (layout.boundsChanged) {
|
|
149
|
-
levelList.
|
|
149
|
+
levelList.add(leaf);
|
|
150
150
|
if (leaf.isBranch)
|
|
151
151
|
leaf.__tempNumber = 0;
|
|
152
152
|
pushAllParent(leaf, levelList);
|
|
@@ -155,20 +155,21 @@ function updateMatrix(updateList, levelList) {
|
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
function updateBounds(boundsList) {
|
|
158
|
-
let
|
|
158
|
+
let list, branch, children;
|
|
159
159
|
boundsList.sort(true);
|
|
160
160
|
boundsList.levels.forEach(level => {
|
|
161
|
-
|
|
162
|
-
for (let i = 0, len =
|
|
163
|
-
branch =
|
|
161
|
+
list = boundsList.levelMap[level];
|
|
162
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
163
|
+
branch = list[i];
|
|
164
164
|
if (branch.isBranch && branch.__tempNumber) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
children = branch.children;
|
|
166
|
+
for (let j = 0, jLen = children.length; j < jLen; j++) {
|
|
167
|
+
if (!children[j].isBranch) {
|
|
168
|
+
updateOneBounds(children[j]);
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
|
-
branch
|
|
172
|
+
updateOneBounds(branch);
|
|
172
173
|
}
|
|
173
174
|
});
|
|
174
175
|
}
|
|
@@ -181,7 +182,7 @@ function updateChange(updateList) {
|
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
const { worldBounds } = core.LeafBoundsHelper;
|
|
184
|
-
const {
|
|
185
|
+
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
185
186
|
class LayoutBlockData {
|
|
186
187
|
constructor(list) {
|
|
187
188
|
this.updatedBounds = new core.Bounds();
|
|
@@ -192,14 +193,20 @@ class LayoutBlockData {
|
|
|
192
193
|
this.updatedList = list;
|
|
193
194
|
}
|
|
194
195
|
setBefore() {
|
|
195
|
-
|
|
196
|
+
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
196
197
|
}
|
|
197
198
|
setAfter() {
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
const { list } = this.updatedList;
|
|
200
|
+
if (list.some(leaf => leaf.noBounds)) {
|
|
201
|
+
this.afterBounds.set(bigBounds);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
this.afterBounds.setListWithFn(list, worldBounds);
|
|
205
|
+
}
|
|
206
|
+
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
200
207
|
}
|
|
201
208
|
merge(data) {
|
|
202
|
-
this.updatedList.
|
|
209
|
+
this.updatedList.addList(data.updatedList.list);
|
|
203
210
|
this.beforeBounds.add(data.beforeBounds);
|
|
204
211
|
this.afterBounds.add(data.afterBounds);
|
|
205
212
|
this.updatedBounds.add(data.updatedBounds);
|
|
@@ -209,8 +216,7 @@ class LayoutBlockData {
|
|
|
209
216
|
}
|
|
210
217
|
}
|
|
211
218
|
|
|
212
|
-
const {
|
|
213
|
-
const { pushAllBranchStack, updateWorldBoundsByBranchStack } = core.BranchHelper;
|
|
219
|
+
const { updateAllMatrix, updateAllChange } = core.LeafHelper;
|
|
214
220
|
const debug$1 = core.Debug.get('Layouter');
|
|
215
221
|
class Layouter {
|
|
216
222
|
constructor(target, userConfig) {
|
|
@@ -287,12 +293,15 @@ class Layouter {
|
|
|
287
293
|
const { target, __updatedList: updateList } = this;
|
|
288
294
|
const { BEFORE, LAYOUT, AFTER } = core.LayoutEvent;
|
|
289
295
|
const blocks = this.getBlocks(updateList);
|
|
290
|
-
blocks.forEach(item =>
|
|
296
|
+
blocks.forEach(item => item.setBefore());
|
|
291
297
|
target.emitEvent(new core.LayoutEvent(BEFORE, blocks, this.times));
|
|
298
|
+
this.extraBlock = null;
|
|
292
299
|
updateList.sort();
|
|
293
300
|
updateMatrix(updateList, this.__levelList);
|
|
294
301
|
updateBounds(this.__levelList);
|
|
295
302
|
updateChange(updateList);
|
|
303
|
+
if (this.extraBlock)
|
|
304
|
+
blocks.push(this.extraBlock);
|
|
296
305
|
blocks.forEach(item => item.setAfter());
|
|
297
306
|
target.emitEvent(new core.LayoutEvent(LAYOUT, blocks, this.times));
|
|
298
307
|
target.emitEvent(new core.LayoutEvent(AFTER, blocks, this.times));
|
|
@@ -315,17 +324,20 @@ class Layouter {
|
|
|
315
324
|
core.Run.end(t);
|
|
316
325
|
}
|
|
317
326
|
static fullLayout(target) {
|
|
318
|
-
|
|
327
|
+
updateAllMatrix(target, true);
|
|
319
328
|
if (target.isBranch) {
|
|
320
|
-
|
|
321
|
-
pushAllBranchStack(target, branchStack);
|
|
322
|
-
updateWorldBoundsByBranchStack(branchStack);
|
|
329
|
+
core.BranchHelper.updateBounds(target);
|
|
323
330
|
}
|
|
324
331
|
else {
|
|
325
|
-
|
|
332
|
+
core.LeafHelper.updateBounds(target);
|
|
326
333
|
}
|
|
327
334
|
updateAllChange(target);
|
|
328
335
|
}
|
|
336
|
+
addExtra(leaf) {
|
|
337
|
+
const block = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
|
|
338
|
+
block.updatedList.add(leaf);
|
|
339
|
+
block.beforeBounds.add(leaf.__world);
|
|
340
|
+
}
|
|
329
341
|
createBlock(data) {
|
|
330
342
|
return new LayoutBlockData(data);
|
|
331
343
|
}
|
|
@@ -353,8 +365,7 @@ class Layouter {
|
|
|
353
365
|
if (this.target) {
|
|
354
366
|
this.stop();
|
|
355
367
|
this.__removeListenEvents();
|
|
356
|
-
this.target = null;
|
|
357
|
-
this.config = null;
|
|
368
|
+
this.target = this.config = null;
|
|
358
369
|
}
|
|
359
370
|
}
|
|
360
371
|
}
|
|
@@ -465,7 +476,7 @@ class Renderer {
|
|
|
465
476
|
const { canvas } = this;
|
|
466
477
|
const bounds = block.getIntersect(canvas.bounds);
|
|
467
478
|
const includes = block.includes(this.target.__world);
|
|
468
|
-
const realBounds = new core.Bounds(
|
|
479
|
+
const realBounds = new core.Bounds(bounds);
|
|
469
480
|
canvas.save();
|
|
470
481
|
if (includes && !core.Debug.showRepaint) {
|
|
471
482
|
canvas.clear();
|
|
@@ -515,7 +526,7 @@ class Renderer {
|
|
|
515
526
|
const { updateBlocks: list } = this;
|
|
516
527
|
if (list) {
|
|
517
528
|
const bounds = new core.Bounds();
|
|
518
|
-
bounds.
|
|
529
|
+
bounds.setList(list);
|
|
519
530
|
list.length = 0;
|
|
520
531
|
list.push(bounds);
|
|
521
532
|
}
|
|
@@ -555,7 +566,7 @@ class Renderer {
|
|
|
555
566
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
556
567
|
if (empty) {
|
|
557
568
|
if (!leaf.isLeafer)
|
|
558
|
-
debug.
|
|
569
|
+
debug.tip(leaf.innerName, ': empty');
|
|
559
570
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
560
571
|
}
|
|
561
572
|
return empty;
|
|
@@ -589,6 +600,14 @@ class Renderer {
|
|
|
589
600
|
}
|
|
590
601
|
}
|
|
591
602
|
|
|
603
|
+
var AnswerType;
|
|
604
|
+
(function (AnswerType) {
|
|
605
|
+
AnswerType[AnswerType["No"] = 0] = "No";
|
|
606
|
+
AnswerType[AnswerType["Yes"] = 1] = "Yes";
|
|
607
|
+
AnswerType[AnswerType["NoAndSkip"] = 2] = "NoAndSkip";
|
|
608
|
+
AnswerType[AnswerType["YesAndSkip"] = 3] = "YesAndSkip";
|
|
609
|
+
})(AnswerType || (AnswerType = {}));
|
|
610
|
+
|
|
592
611
|
const { hitRadiusPoint } = core.BoundsHelper;
|
|
593
612
|
class Pather {
|
|
594
613
|
constructor(target, selector) {
|
|
@@ -633,10 +652,10 @@ class Pather {
|
|
|
633
652
|
getPath(leaf) {
|
|
634
653
|
const path = new core.LeafList();
|
|
635
654
|
while (leaf) {
|
|
636
|
-
path.
|
|
655
|
+
path.add(leaf);
|
|
637
656
|
leaf = leaf.parent;
|
|
638
657
|
}
|
|
639
|
-
path.
|
|
658
|
+
path.add(this.target);
|
|
640
659
|
return path;
|
|
641
660
|
}
|
|
642
661
|
getHitablePath(leaf) {
|
|
@@ -646,7 +665,7 @@ class Pather {
|
|
|
646
665
|
item = path.list[i];
|
|
647
666
|
if (!item.__.hittable)
|
|
648
667
|
break;
|
|
649
|
-
hittablePath.
|
|
668
|
+
hittablePath.addAt(item, 0);
|
|
650
669
|
if (!item.__.hitChildren)
|
|
651
670
|
break;
|
|
652
671
|
}
|
|
@@ -665,7 +684,7 @@ class Pather {
|
|
|
665
684
|
leaf = path.list[j];
|
|
666
685
|
if (nextPath && nextPath.has(leaf))
|
|
667
686
|
break;
|
|
668
|
-
throughPath.
|
|
687
|
+
throughPath.add(leaf);
|
|
669
688
|
}
|
|
670
689
|
}
|
|
671
690
|
return throughPath;
|
|
@@ -707,14 +726,15 @@ class Pather {
|
|
|
707
726
|
}
|
|
708
727
|
}
|
|
709
728
|
|
|
729
|
+
const { Yes, NoAndSkip, YesAndSkip } = AnswerType;
|
|
710
730
|
class Selector {
|
|
711
731
|
constructor(target, userConfig) {
|
|
712
732
|
this.config = {};
|
|
713
733
|
this.innerIdMap = {};
|
|
714
734
|
this.idMap = {};
|
|
715
735
|
this.methods = {
|
|
716
|
-
id: (leaf, name) => leaf.id === name ? this.idMap[name] = leaf : 0,
|
|
717
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? this.innerIdMap[innerId] = leaf : 0,
|
|
736
|
+
id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
|
|
737
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
|
|
718
738
|
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
719
739
|
tag: (leaf, name) => leaf.__tag === name ? 1 : 0
|
|
720
740
|
};
|
|
@@ -724,11 +744,6 @@ class Selector {
|
|
|
724
744
|
this.pather = new Pather(target, this);
|
|
725
745
|
this.__listenEvents();
|
|
726
746
|
}
|
|
727
|
-
getByPoint(hitPoint, hitRadius, options) {
|
|
728
|
-
if (core.Platform.name === 'node')
|
|
729
|
-
this.target.emit(core.LayoutEvent.CHECK_UPDATE);
|
|
730
|
-
return this.pather.getByPoint(hitPoint, hitRadius, options);
|
|
731
|
-
}
|
|
732
747
|
getBy(condition, branch, one, options) {
|
|
733
748
|
switch (typeof condition) {
|
|
734
749
|
case 'number':
|
|
@@ -748,6 +763,11 @@ class Selector {
|
|
|
748
763
|
return this.getByMethod(condition, branch, one, options);
|
|
749
764
|
}
|
|
750
765
|
}
|
|
766
|
+
getByPoint(hitPoint, hitRadius, options) {
|
|
767
|
+
if (core.Platform.name === 'node')
|
|
768
|
+
this.target.emit(core.LayoutEvent.CHECK_UPDATE);
|
|
769
|
+
return this.pather.getByPoint(hitPoint, hitRadius, options);
|
|
770
|
+
}
|
|
751
771
|
getByInnerId(innerId, branch) {
|
|
752
772
|
const cache = this.innerIdMap[innerId];
|
|
753
773
|
if (cache)
|
|
@@ -774,10 +794,11 @@ class Selector {
|
|
|
774
794
|
return list || this.findLeaf;
|
|
775
795
|
}
|
|
776
796
|
eachFind(children, method, list, options) {
|
|
777
|
-
let child;
|
|
797
|
+
let child, result;
|
|
778
798
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
779
799
|
child = children[i];
|
|
780
|
-
|
|
800
|
+
result = method(child, options);
|
|
801
|
+
if (result === Yes || result === YesAndSkip) {
|
|
781
802
|
if (list) {
|
|
782
803
|
list.push(child);
|
|
783
804
|
}
|
|
@@ -786,7 +807,7 @@ class Selector {
|
|
|
786
807
|
return;
|
|
787
808
|
}
|
|
788
809
|
}
|
|
789
|
-
if (child.isBranch)
|
|
810
|
+
if (child.isBranch && result < NoAndSkip)
|
|
790
811
|
this.eachFind(child.children, method, list, options);
|
|
791
812
|
}
|
|
792
813
|
}
|
|
@@ -903,9 +924,8 @@ core.Platform.name = 'node';
|
|
|
903
924
|
core.Platform.requestRender = function (render) { setTimeout(render); };
|
|
904
925
|
core.Platform.devicePixelRatio = 1;
|
|
905
926
|
core.Platform.conicGradientSupport = true;
|
|
906
|
-
core.Platform.realtimeLayout = true;
|
|
907
927
|
|
|
908
|
-
const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper
|
|
928
|
+
const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = core.MatrixHelper;
|
|
909
929
|
function fillOrFitMode(data, mode, box, width, height, rotation) {
|
|
910
930
|
const transform = get$4();
|
|
911
931
|
const swap = rotation && rotation !== 180;
|
|
@@ -915,7 +935,7 @@ function fillOrFitMode(data, mode, box, width, height, rotation) {
|
|
|
915
935
|
const x = box.x + (box.width - width * scale) / 2;
|
|
916
936
|
const y = box.y + (box.height - height * scale) / 2;
|
|
917
937
|
translate$1(transform, x, y);
|
|
918
|
-
scaleHelper
|
|
938
|
+
scaleHelper(transform, scale);
|
|
919
939
|
if (rotation)
|
|
920
940
|
rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
921
941
|
data.scaleX = data.scaleY = scale;
|
|
@@ -927,7 +947,7 @@ function clipMode(data, box, offset, scale, rotation) {
|
|
|
927
947
|
if (offset)
|
|
928
948
|
translate$1(transform, offset.x, offset.y);
|
|
929
949
|
if (scale) {
|
|
930
|
-
typeof scale === 'number' ? scaleHelper
|
|
950
|
+
typeof scale === 'number' ? scaleHelper(transform, scale) : scaleHelper(transform, scale.x, scale.y);
|
|
931
951
|
data.scaleX = transform.a;
|
|
932
952
|
data.scaleY = transform.d;
|
|
933
953
|
}
|
|
@@ -1040,6 +1060,10 @@ function hasNaturalSize(ui, attrName, image) {
|
|
|
1040
1060
|
d.__naturalWidth = image.width;
|
|
1041
1061
|
d.__naturalHeight = image.height;
|
|
1042
1062
|
if (!d.__getInput('width') || !d.__getInput('height')) {
|
|
1063
|
+
if (ui.__proxyData) {
|
|
1064
|
+
ui.setProxyAttr('width', ui.__.width);
|
|
1065
|
+
ui.setProxyAttr('height', ui.__.height);
|
|
1066
|
+
}
|
|
1043
1067
|
ui.forceUpdate('width');
|
|
1044
1068
|
return false;
|
|
1045
1069
|
}
|
|
@@ -1051,22 +1075,21 @@ function emit(type, data) {
|
|
|
1051
1075
|
data.target.emitEvent(new core.ImageEvent(type, data));
|
|
1052
1076
|
}
|
|
1053
1077
|
|
|
1054
|
-
const
|
|
1078
|
+
const Export$1 = {};
|
|
1079
|
+
|
|
1080
|
+
const { get: get$2, scale, copy: copy$1 } = core.MatrixHelper;
|
|
1055
1081
|
function createPattern(ui, paint, pixelRatio) {
|
|
1056
1082
|
let { scaleX, scaleY } = ui.__world;
|
|
1057
1083
|
const id = scaleX + '-' + scaleY;
|
|
1058
1084
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1059
|
-
paint.patternId = id;
|
|
1060
1085
|
scaleX = Math.abs(scaleX);
|
|
1061
1086
|
scaleY = Math.abs(scaleY);
|
|
1062
1087
|
const { image, data } = paint;
|
|
1063
|
-
|
|
1064
|
-
const maxHeight = image.isSVG ? 4096 : Math.min(image.height, 4096);
|
|
1065
|
-
let scale, matrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
|
|
1088
|
+
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
|
|
1066
1089
|
if (sx) {
|
|
1067
|
-
|
|
1068
|
-
copy$1(
|
|
1069
|
-
|
|
1090
|
+
imageMatrix = get$2();
|
|
1091
|
+
copy$1(imageMatrix, transform);
|
|
1092
|
+
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
1070
1093
|
scaleX *= sx;
|
|
1071
1094
|
scaleY *= sy;
|
|
1072
1095
|
}
|
|
@@ -1074,38 +1097,49 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1074
1097
|
scaleY *= pixelRatio;
|
|
1075
1098
|
width *= scaleX;
|
|
1076
1099
|
height *= scaleY;
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1100
|
+
const size = width * height;
|
|
1101
|
+
if (paint.data.mode !== 'repeat') {
|
|
1102
|
+
if (size > core.Platform.image.maxCacheSize)
|
|
1103
|
+
return false;
|
|
1104
|
+
}
|
|
1105
|
+
let maxSize = core.Platform.image.maxPatternSize;
|
|
1106
|
+
if (!image.isSVG) {
|
|
1107
|
+
const imageSize = image.width * image.height;
|
|
1108
|
+
if (maxSize > imageSize)
|
|
1109
|
+
maxSize = imageSize;
|
|
1110
|
+
}
|
|
1111
|
+
if (size > maxSize)
|
|
1112
|
+
imageScale = Math.sqrt(size / maxSize);
|
|
1113
|
+
if (imageScale) {
|
|
1114
|
+
scaleX /= imageScale;
|
|
1115
|
+
scaleY /= imageScale;
|
|
1116
|
+
width /= imageScale;
|
|
1117
|
+
height /= imageScale;
|
|
1085
1118
|
}
|
|
1086
1119
|
if (sx) {
|
|
1087
1120
|
scaleX /= sx;
|
|
1088
1121
|
scaleY /= sy;
|
|
1089
1122
|
}
|
|
1090
1123
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
1091
|
-
if (!
|
|
1092
|
-
|
|
1124
|
+
if (!imageMatrix) {
|
|
1125
|
+
imageMatrix = get$2();
|
|
1093
1126
|
if (transform)
|
|
1094
|
-
copy$1(
|
|
1127
|
+
copy$1(imageMatrix, transform);
|
|
1095
1128
|
}
|
|
1096
|
-
|
|
1129
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
1097
1130
|
}
|
|
1098
|
-
const
|
|
1131
|
+
const pattern = core.Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), mode === 'repeat' ? 'repeat' : (core.Platform.origin.noRepeat || 'no-repeat'));
|
|
1099
1132
|
try {
|
|
1100
1133
|
if (paint.transform)
|
|
1101
1134
|
paint.transform = null;
|
|
1102
|
-
if (
|
|
1103
|
-
|
|
1135
|
+
if (imageMatrix)
|
|
1136
|
+
pattern.setTransform ? pattern.setTransform(imageMatrix) : paint.transform = imageMatrix;
|
|
1104
1137
|
}
|
|
1105
1138
|
catch (_a) {
|
|
1106
|
-
paint.transform =
|
|
1139
|
+
paint.transform = imageMatrix;
|
|
1107
1140
|
}
|
|
1108
|
-
paint.style =
|
|
1141
|
+
paint.style = pattern;
|
|
1142
|
+
paint.patternId = id;
|
|
1109
1143
|
return true;
|
|
1110
1144
|
}
|
|
1111
1145
|
else {
|
|
@@ -1113,18 +1147,24 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1113
1147
|
}
|
|
1114
1148
|
}
|
|
1115
1149
|
|
|
1150
|
+
const { abs } = Math;
|
|
1116
1151
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
1117
1152
|
const { scaleX, scaleY } = ui.__world;
|
|
1118
1153
|
if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
|
|
1119
1154
|
return false;
|
|
1120
1155
|
}
|
|
1121
1156
|
else {
|
|
1157
|
+
const { data } = paint;
|
|
1122
1158
|
if (allowPaint) {
|
|
1123
|
-
if (
|
|
1124
|
-
let { width, height } =
|
|
1125
|
-
width *= scaleX * canvas.pixelRatio;
|
|
1126
|
-
height *= scaleY * canvas.pixelRatio;
|
|
1127
|
-
|
|
1159
|
+
if (data.mode !== 'repeat') {
|
|
1160
|
+
let { width, height } = data;
|
|
1161
|
+
width *= abs(scaleX) * canvas.pixelRatio;
|
|
1162
|
+
height *= abs(scaleY) * canvas.pixelRatio;
|
|
1163
|
+
if (data.scaleX) {
|
|
1164
|
+
width *= data.scaleX;
|
|
1165
|
+
height *= data.scaleY;
|
|
1166
|
+
}
|
|
1167
|
+
allowPaint = width * height > core.Platform.image.maxCacheSize;
|
|
1128
1168
|
}
|
|
1129
1169
|
else {
|
|
1130
1170
|
allowPaint = false;
|
|
@@ -1133,7 +1173,6 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1133
1173
|
if (allowPaint) {
|
|
1134
1174
|
canvas.save();
|
|
1135
1175
|
canvas.clip();
|
|
1136
|
-
const { data } = paint;
|
|
1137
1176
|
if (paint.blendMode)
|
|
1138
1177
|
canvas.blendMode = paint.blendMode;
|
|
1139
1178
|
if (data.opacity)
|
|
@@ -1145,7 +1184,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1145
1184
|
return true;
|
|
1146
1185
|
}
|
|
1147
1186
|
else {
|
|
1148
|
-
if (!paint.style) {
|
|
1187
|
+
if (!paint.style || Export$1.running) {
|
|
1149
1188
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
1150
1189
|
}
|
|
1151
1190
|
else {
|
|
@@ -1164,7 +1203,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1164
1203
|
}
|
|
1165
1204
|
|
|
1166
1205
|
function recycleImage(attrName, data) {
|
|
1167
|
-
const paints =
|
|
1206
|
+
const paints = data['_' + attrName];
|
|
1168
1207
|
if (paints instanceof Array) {
|
|
1169
1208
|
let image, recycleMap, input, url;
|
|
1170
1209
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
@@ -1268,7 +1307,7 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas, renderOptions) {
|
|
|
1268
1307
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
1269
1308
|
fillText(ui, out);
|
|
1270
1309
|
out.blendMode = 'normal';
|
|
1271
|
-
if (ui.
|
|
1310
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
1272
1311
|
canvas.copyWorldByReset(out);
|
|
1273
1312
|
}
|
|
1274
1313
|
else {
|
|
@@ -1341,7 +1380,7 @@ function stroke(stroke, ui, canvas, renderOptions) {
|
|
|
1341
1380
|
out.stroke();
|
|
1342
1381
|
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
1343
1382
|
out.clearWorld(ui.__layout.renderBounds);
|
|
1344
|
-
if (ui.
|
|
1383
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
1345
1384
|
canvas.copyWorldByReset(out);
|
|
1346
1385
|
}
|
|
1347
1386
|
else {
|
|
@@ -1381,7 +1420,7 @@ function strokes(strokes, ui, canvas, renderOptions) {
|
|
|
1381
1420
|
drawStrokesStyle(strokes, false, ui, out);
|
|
1382
1421
|
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
1383
1422
|
out.clearWorld(renderBounds);
|
|
1384
|
-
if (ui.
|
|
1423
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
1385
1424
|
canvas.copyWorldByReset(out);
|
|
1386
1425
|
}
|
|
1387
1426
|
else {
|
|
@@ -1605,7 +1644,7 @@ function shadow(ui, current, shape, renderOptions) {
|
|
|
1605
1644
|
}
|
|
1606
1645
|
worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1607
1646
|
}
|
|
1608
|
-
if (ui.
|
|
1647
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
1609
1648
|
current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
|
|
1610
1649
|
}
|
|
1611
1650
|
else {
|
|
@@ -1669,7 +1708,7 @@ function innerShadow(ui, current, shape, renderOptions) {
|
|
|
1669
1708
|
copyBounds = bounds;
|
|
1670
1709
|
}
|
|
1671
1710
|
other.fillWorld(copyBounds, item.color, 'source-in');
|
|
1672
|
-
if (ui.
|
|
1711
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
1673
1712
|
current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
|
|
1674
1713
|
}
|
|
1675
1714
|
else {
|
|
@@ -2167,6 +2206,7 @@ const ColorConvert = {
|
|
|
2167
2206
|
|
|
2168
2207
|
const Export = {
|
|
2169
2208
|
export(leaf, filename, options) {
|
|
2209
|
+
Export.running = true;
|
|
2170
2210
|
return addTask((success) => new Promise((resolve) => {
|
|
2171
2211
|
const { leafer } = leaf;
|
|
2172
2212
|
if (leafer) {
|
|
@@ -2204,6 +2244,7 @@ const Export = {
|
|
|
2204
2244
|
}
|
|
2205
2245
|
success({ data });
|
|
2206
2246
|
resolve();
|
|
2247
|
+
Export.running = false;
|
|
2207
2248
|
if (unreal)
|
|
2208
2249
|
canvas.recycle();
|
|
2209
2250
|
}));
|
|
@@ -2211,6 +2252,7 @@ const Export = {
|
|
|
2211
2252
|
else {
|
|
2212
2253
|
success({ data: false });
|
|
2213
2254
|
resolve();
|
|
2255
|
+
Export.running = false;
|
|
2214
2256
|
}
|
|
2215
2257
|
}));
|
|
2216
2258
|
}
|