@leafer-draw/miniapp 1.6.1 → 1.6.3
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 +208 -201
- package/dist/miniapp.esm.js +211 -204
- 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 +1173 -490
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +9 -9
- package/dist/miniapp.cjs.map +0 -1
- package/dist/miniapp.esm.js.map +0 -1
- package/dist/miniapp.module.js.map +0 -1
package/dist/miniapp.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@leafer/core');
|
|
4
4
|
var draw = require('@leafer-ui/draw');
|
|
5
|
+
var core$1 = require('@leafer-ui/core');
|
|
5
6
|
|
|
6
7
|
class LeaferCanvas extends core.LeaferCanvasBase {
|
|
7
8
|
get allowBackgroundColor() { return false; }
|
|
@@ -299,17 +300,15 @@ class Watcher {
|
|
|
299
300
|
this.target.emitEvent(new core.WatchEvent(core.WatchEvent.DATA, { updatedList: this.updatedList }));
|
|
300
301
|
this.__updatedList = new core.LeafList();
|
|
301
302
|
this.totalTimes++;
|
|
302
|
-
this.changed = false;
|
|
303
|
-
this.hasVisible = false;
|
|
304
|
-
this.hasRemove = false;
|
|
305
|
-
this.hasAdd = false;
|
|
303
|
+
this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
|
|
306
304
|
}
|
|
307
305
|
__listenEvents() {
|
|
308
|
-
const { target } = this;
|
|
309
306
|
this.__eventIds = [
|
|
310
|
-
target.on_(
|
|
311
|
-
|
|
312
|
-
|
|
307
|
+
this.target.on_([
|
|
308
|
+
[core.PropertyEvent.CHANGE, this.__onAttrChange, this],
|
|
309
|
+
[[core.ChildEvent.ADD, core.ChildEvent.REMOVE], this.__onChildEvent, this],
|
|
310
|
+
[core.WatchEvent.REQUEST, this.__onRquestData, this]
|
|
311
|
+
])
|
|
313
312
|
];
|
|
314
313
|
}
|
|
315
314
|
__removeListenEvents() {
|
|
@@ -319,13 +318,12 @@ class Watcher {
|
|
|
319
318
|
if (this.target) {
|
|
320
319
|
this.stop();
|
|
321
320
|
this.__removeListenEvents();
|
|
322
|
-
this.target = null;
|
|
323
|
-
this.__updatedList = null;
|
|
321
|
+
this.target = this.__updatedList = null;
|
|
324
322
|
}
|
|
325
323
|
}
|
|
326
324
|
}
|
|
327
325
|
|
|
328
|
-
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds,
|
|
326
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = core.LeafHelper;
|
|
329
327
|
const { pushAllChildBranch, pushAllParent } = core.BranchHelper;
|
|
330
328
|
function updateMatrix(updateList, levelList) {
|
|
331
329
|
let layout;
|
|
@@ -368,15 +366,7 @@ function updateBounds(boundsList) {
|
|
|
368
366
|
});
|
|
369
367
|
}
|
|
370
368
|
function updateChange(updateList) {
|
|
371
|
-
|
|
372
|
-
updateList.list.forEach(leaf => {
|
|
373
|
-
layout = leaf.__layout;
|
|
374
|
-
if (layout.opacityChanged)
|
|
375
|
-
updateAllWorldOpacity(leaf);
|
|
376
|
-
if (layout.stateStyleChanged)
|
|
377
|
-
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
378
|
-
leaf.__updateChange();
|
|
379
|
-
});
|
|
369
|
+
updateList.list.forEach(updateOneChange);
|
|
380
370
|
}
|
|
381
371
|
|
|
382
372
|
const { worldBounds } = core.LeafBoundsHelper;
|
|
@@ -433,7 +423,7 @@ class Layouter {
|
|
|
433
423
|
this.disabled = true;
|
|
434
424
|
}
|
|
435
425
|
layout() {
|
|
436
|
-
if (!this.running)
|
|
426
|
+
if (this.layouting || !this.running)
|
|
437
427
|
return;
|
|
438
428
|
const { target } = this;
|
|
439
429
|
this.times = 0;
|
|
@@ -516,12 +506,10 @@ class Layouter {
|
|
|
516
506
|
}
|
|
517
507
|
static fullLayout(target) {
|
|
518
508
|
updateAllMatrix(target, true);
|
|
519
|
-
if (target.isBranch)
|
|
509
|
+
if (target.isBranch)
|
|
520
510
|
core.BranchHelper.updateBounds(target);
|
|
521
|
-
|
|
522
|
-
else {
|
|
511
|
+
else
|
|
523
512
|
core.LeafHelper.updateBounds(target);
|
|
524
|
-
}
|
|
525
513
|
updateAllChange(target);
|
|
526
514
|
}
|
|
527
515
|
addExtra(leaf) {
|
|
@@ -544,11 +532,12 @@ class Layouter {
|
|
|
544
532
|
this.__updatedList = event.data.updatedList;
|
|
545
533
|
}
|
|
546
534
|
__listenEvents() {
|
|
547
|
-
const { target } = this;
|
|
548
535
|
this.__eventIds = [
|
|
549
|
-
target.on_(
|
|
550
|
-
|
|
551
|
-
|
|
536
|
+
this.target.on_([
|
|
537
|
+
[core.LayoutEvent.REQUEST, this.layout, this],
|
|
538
|
+
[core.LayoutEvent.AGAIN, this.layoutAgain, this],
|
|
539
|
+
[core.WatchEvent.DATA, this.__onReceiveWatchData, this]
|
|
540
|
+
])
|
|
552
541
|
];
|
|
553
542
|
}
|
|
554
543
|
__removeListenEvents() {
|
|
@@ -779,12 +768,13 @@ class Renderer {
|
|
|
779
768
|
this.target.emitEvent(new core.RenderEvent(type, this.times, bounds, options));
|
|
780
769
|
}
|
|
781
770
|
__listenEvents() {
|
|
782
|
-
const { target } = this;
|
|
783
771
|
this.__eventIds = [
|
|
784
|
-
target.on_(
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
772
|
+
this.target.on_([
|
|
773
|
+
[core.RenderEvent.REQUEST, this.update, this],
|
|
774
|
+
[core.LayoutEvent.END, this.__onLayoutEnd, this],
|
|
775
|
+
[core.RenderEvent.AGAIN, this.renderAgain, this],
|
|
776
|
+
[core.ResizeEvent.RESIZE, this.__onResize, this]
|
|
777
|
+
])
|
|
788
778
|
];
|
|
789
779
|
}
|
|
790
780
|
__removeListenEvents() {
|
|
@@ -810,8 +800,10 @@ Object.assign(core.Creator, {
|
|
|
810
800
|
core.Platform.layout = Layouter.fullLayout;
|
|
811
801
|
|
|
812
802
|
function fillText(ui, canvas) {
|
|
813
|
-
|
|
814
|
-
|
|
803
|
+
const data = ui.__, { rows, decorationY } = data.__textDrawData;
|
|
804
|
+
if (data.__isPlacehold && data.placeholderColor)
|
|
805
|
+
canvas.fillStyle = data.placeholderColor;
|
|
806
|
+
let row;
|
|
815
807
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
816
808
|
row = rows[i];
|
|
817
809
|
if (row.text)
|
|
@@ -820,7 +812,7 @@ function fillText(ui, canvas) {
|
|
|
820
812
|
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
821
813
|
}
|
|
822
814
|
if (decorationY) {
|
|
823
|
-
const { decorationColor, decorationHeight } = data;
|
|
815
|
+
const { decorationColor, decorationHeight } = data.__textDrawData;
|
|
824
816
|
if (decorationColor)
|
|
825
817
|
canvas.fillStyle = decorationColor;
|
|
826
818
|
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
@@ -829,65 +821,73 @@ function fillText(ui, canvas) {
|
|
|
829
821
|
|
|
830
822
|
function fill(fill, ui, canvas) {
|
|
831
823
|
canvas.fillStyle = fill;
|
|
832
|
-
|
|
824
|
+
fillPathOrText(ui, canvas);
|
|
833
825
|
}
|
|
834
826
|
function fills(fills, ui, canvas) {
|
|
835
827
|
let item;
|
|
836
|
-
const { windingRule, __font } = ui.__;
|
|
837
828
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
838
829
|
item = fills[i];
|
|
839
|
-
if (item.image
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
if (item.blendMode)
|
|
847
|
-
canvas.blendMode = item.blendMode;
|
|
848
|
-
__font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
|
|
849
|
-
canvas.restore();
|
|
830
|
+
if (item.image) {
|
|
831
|
+
if (draw.PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
|
|
832
|
+
continue;
|
|
833
|
+
if (!item.style) {
|
|
834
|
+
if (!i && item.image.isPlacehold)
|
|
835
|
+
ui.drawImagePlaceholder(canvas, item.image);
|
|
836
|
+
continue;
|
|
850
837
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
838
|
+
}
|
|
839
|
+
canvas.fillStyle = item.style;
|
|
840
|
+
if (item.transform) {
|
|
841
|
+
canvas.save();
|
|
842
|
+
canvas.transform(item.transform);
|
|
843
|
+
if (item.blendMode)
|
|
844
|
+
canvas.blendMode = item.blendMode;
|
|
845
|
+
fillPathOrText(ui, canvas);
|
|
846
|
+
canvas.restore();
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
if (item.blendMode) {
|
|
850
|
+
canvas.saveBlendMode(item.blendMode);
|
|
851
|
+
fillPathOrText(ui, canvas);
|
|
852
|
+
canvas.restoreBlendMode();
|
|
860
853
|
}
|
|
854
|
+
else
|
|
855
|
+
fillPathOrText(ui, canvas);
|
|
861
856
|
}
|
|
862
857
|
}
|
|
863
858
|
}
|
|
859
|
+
function fillPathOrText(ui, canvas) {
|
|
860
|
+
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
const Paint = {};
|
|
864
864
|
|
|
865
865
|
function strokeText(stroke, ui, canvas) {
|
|
866
|
-
|
|
867
|
-
const isStrokes = typeof stroke !== 'string';
|
|
868
|
-
switch (strokeAlign) {
|
|
866
|
+
switch (ui.__.strokeAlign) {
|
|
869
867
|
case 'center':
|
|
870
|
-
|
|
871
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
868
|
+
drawCenter$1(stroke, 1, ui, canvas);
|
|
872
869
|
break;
|
|
873
870
|
case 'inside':
|
|
874
|
-
|
|
871
|
+
drawAlign(stroke, 'inside', ui, canvas);
|
|
875
872
|
break;
|
|
876
873
|
case 'outside':
|
|
877
|
-
|
|
874
|
+
ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
|
|
878
875
|
break;
|
|
879
876
|
}
|
|
880
877
|
}
|
|
881
|
-
function
|
|
882
|
-
const
|
|
878
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
879
|
+
const data = ui.__;
|
|
880
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
|
|
881
|
+
data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
882
|
+
}
|
|
883
|
+
function drawAlign(stroke, align, ui, canvas) {
|
|
883
884
|
const out = canvas.getSameCanvas(true, true);
|
|
884
|
-
out.
|
|
885
|
-
|
|
886
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
|
|
885
|
+
out.font = ui.__.__font;
|
|
886
|
+
drawCenter$1(stroke, 2, ui, out);
|
|
887
887
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
888
888
|
fillText(ui, out);
|
|
889
889
|
out.blendMode = 'normal';
|
|
890
|
-
if (ui.__worldFlipped)
|
|
890
|
+
if (ui.__worldFlipped || core$1.Platform.fullImageShadow)
|
|
891
891
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
892
892
|
else
|
|
893
893
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
@@ -929,90 +929,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
|
929
929
|
}
|
|
930
930
|
|
|
931
931
|
function stroke(stroke, ui, canvas) {
|
|
932
|
-
const
|
|
933
|
-
|
|
934
|
-
if (!__strokeWidth)
|
|
932
|
+
const data = ui.__;
|
|
933
|
+
if (!data.__strokeWidth)
|
|
935
934
|
return;
|
|
936
|
-
if (__font) {
|
|
935
|
+
if (data.__font) {
|
|
937
936
|
strokeText(stroke, ui, canvas);
|
|
938
937
|
}
|
|
939
938
|
else {
|
|
940
|
-
switch (strokeAlign) {
|
|
939
|
+
switch (data.strokeAlign) {
|
|
941
940
|
case 'center':
|
|
942
|
-
|
|
943
|
-
canvas.stroke();
|
|
944
|
-
if (options.__useArrow)
|
|
945
|
-
strokeArrow(ui, canvas);
|
|
941
|
+
drawCenter(stroke, 1, ui, canvas);
|
|
946
942
|
break;
|
|
947
943
|
case 'inside':
|
|
948
|
-
canvas
|
|
949
|
-
canvas.setStroke(stroke, __strokeWidth * 2, options);
|
|
950
|
-
options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
|
|
951
|
-
canvas.stroke();
|
|
952
|
-
canvas.restore();
|
|
944
|
+
drawInside(stroke, ui, canvas);
|
|
953
945
|
break;
|
|
954
946
|
case 'outside':
|
|
955
|
-
|
|
956
|
-
out.setStroke(stroke, __strokeWidth * 2, options);
|
|
957
|
-
ui.__drawRenderPath(out);
|
|
958
|
-
out.stroke();
|
|
959
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
960
|
-
out.clearWorld(ui.__layout.renderBounds);
|
|
961
|
-
if (ui.__worldFlipped)
|
|
962
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
963
|
-
else
|
|
964
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
965
|
-
out.recycle(ui.__nowWorld);
|
|
947
|
+
drawOutside(stroke, ui, canvas);
|
|
966
948
|
break;
|
|
967
949
|
}
|
|
968
950
|
}
|
|
969
951
|
}
|
|
970
952
|
function strokes(strokes, ui, canvas) {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
953
|
+
stroke(strokes, ui, canvas);
|
|
954
|
+
}
|
|
955
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
956
|
+
const data = ui.__;
|
|
957
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
958
|
+
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
959
|
+
if (data.__useArrow)
|
|
960
|
+
Paint.strokeArrow(stroke, ui, canvas);
|
|
961
|
+
}
|
|
962
|
+
function drawInside(stroke, ui, canvas) {
|
|
963
|
+
const data = ui.__;
|
|
964
|
+
canvas.save();
|
|
965
|
+
data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
|
|
966
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
967
|
+
canvas.restore();
|
|
968
|
+
}
|
|
969
|
+
function drawOutside(stroke, ui, canvas) {
|
|
970
|
+
const data = ui.__;
|
|
971
|
+
if (data.__fillAfterStroke) {
|
|
972
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
977
973
|
}
|
|
978
974
|
else {
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
drawStrokesStyle(strokes, false, ui, canvas);
|
|
991
|
-
canvas.restore();
|
|
992
|
-
break;
|
|
993
|
-
case 'outside':
|
|
994
|
-
const { renderBounds } = ui.__layout;
|
|
995
|
-
const out = canvas.getSameCanvas(true, true);
|
|
996
|
-
ui.__drawRenderPath(out);
|
|
997
|
-
out.setStroke(undefined, __strokeWidth * 2, options);
|
|
998
|
-
drawStrokesStyle(strokes, false, ui, out);
|
|
999
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
1000
|
-
out.clearWorld(renderBounds);
|
|
1001
|
-
if (ui.__worldFlipped)
|
|
1002
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1003
|
-
else
|
|
1004
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
1005
|
-
out.recycle(ui.__nowWorld);
|
|
1006
|
-
break;
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
function strokeArrow(ui, canvas) {
|
|
1011
|
-
if (ui.__.dashPattern) {
|
|
1012
|
-
canvas.beginPath();
|
|
1013
|
-
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
1014
|
-
canvas.dashPattern = null;
|
|
1015
|
-
canvas.stroke();
|
|
975
|
+
const { renderBounds } = ui.__layout;
|
|
976
|
+
const out = canvas.getSameCanvas(true, true);
|
|
977
|
+
ui.__drawRenderPath(out);
|
|
978
|
+
drawCenter(stroke, 2, ui, out);
|
|
979
|
+
data.windingRule ? out.clip(data.windingRule) : out.clip();
|
|
980
|
+
out.clearWorld(renderBounds);
|
|
981
|
+
if (ui.__worldFlipped || core$1.Platform.fullImageShadow)
|
|
982
|
+
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
983
|
+
else
|
|
984
|
+
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
985
|
+
out.recycle(ui.__nowWorld);
|
|
1016
986
|
}
|
|
1017
987
|
}
|
|
1018
988
|
|
|
@@ -1059,9 +1029,10 @@ function shape(ui, current, options) {
|
|
|
1059
1029
|
}
|
|
1060
1030
|
|
|
1061
1031
|
let recycleMap;
|
|
1032
|
+
const { stintSet } = core.DataHelper, { hasTransparent: hasTransparent$1 } = draw.ColorConvert;
|
|
1062
1033
|
function compute(attrName, ui) {
|
|
1063
1034
|
const data = ui.__, leafPaints = [];
|
|
1064
|
-
let paints = data.__input[attrName],
|
|
1035
|
+
let paints = data.__input[attrName], isAlphaPixel, isTransparent;
|
|
1065
1036
|
if (!(paints instanceof Array))
|
|
1066
1037
|
paints = [paints];
|
|
1067
1038
|
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
@@ -1071,35 +1042,62 @@ function compute(attrName, ui) {
|
|
|
1071
1042
|
leafPaints.push(item);
|
|
1072
1043
|
}
|
|
1073
1044
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1074
|
-
if (leafPaints.length
|
|
1075
|
-
|
|
1076
|
-
|
|
1045
|
+
if (leafPaints.length) {
|
|
1046
|
+
if (leafPaints.every(item => item.isTransparent)) {
|
|
1047
|
+
if (leafPaints.some(item => item.image))
|
|
1048
|
+
isAlphaPixel = true;
|
|
1049
|
+
isTransparent = true;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
if (attrName === 'fill') {
|
|
1053
|
+
stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
|
|
1054
|
+
stintSet(data, '__isTransparentFill', isTransparent);
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1058
|
+
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1059
|
+
}
|
|
1077
1060
|
}
|
|
1078
1061
|
function getLeafPaint(attrName, paint, ui) {
|
|
1079
1062
|
if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
|
|
1080
1063
|
return undefined;
|
|
1064
|
+
let data;
|
|
1081
1065
|
const { boxBounds } = ui.__layout;
|
|
1082
1066
|
switch (paint.type) {
|
|
1083
|
-
case 'solid':
|
|
1084
|
-
let { type, blendMode, color, opacity } = paint;
|
|
1085
|
-
return { type, blendMode, style: draw.ColorConvert.string(color, opacity) };
|
|
1086
1067
|
case 'image':
|
|
1087
|
-
|
|
1068
|
+
data = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
1069
|
+
break;
|
|
1088
1070
|
case 'linear':
|
|
1089
|
-
|
|
1071
|
+
data = draw.PaintGradient.linearGradient(paint, boxBounds);
|
|
1072
|
+
break;
|
|
1090
1073
|
case 'radial':
|
|
1091
|
-
|
|
1074
|
+
data = draw.PaintGradient.radialGradient(paint, boxBounds);
|
|
1075
|
+
break;
|
|
1092
1076
|
case 'angular':
|
|
1093
|
-
|
|
1077
|
+
data = draw.PaintGradient.conicGradient(paint, boxBounds);
|
|
1078
|
+
break;
|
|
1079
|
+
case 'solid':
|
|
1080
|
+
const { type, blendMode, color, opacity } = paint;
|
|
1081
|
+
data = { type, blendMode, style: draw.ColorConvert.string(color, opacity) };
|
|
1082
|
+
break;
|
|
1094
1083
|
default:
|
|
1095
|
-
|
|
1084
|
+
if (paint.r !== undefined)
|
|
1085
|
+
data = { type: 'solid', style: draw.ColorConvert.string(paint) };
|
|
1086
|
+
}
|
|
1087
|
+
if (data) {
|
|
1088
|
+
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1089
|
+
data.isTransparent = true;
|
|
1090
|
+
if (paint.blendMode)
|
|
1091
|
+
data.blendMode = paint.blendMode;
|
|
1096
1092
|
}
|
|
1093
|
+
return data;
|
|
1097
1094
|
}
|
|
1098
1095
|
|
|
1099
1096
|
const PaintModule = {
|
|
1100
1097
|
compute,
|
|
1101
1098
|
fill,
|
|
1102
1099
|
fills,
|
|
1100
|
+
fillPathOrText,
|
|
1103
1101
|
fillText,
|
|
1104
1102
|
stroke,
|
|
1105
1103
|
strokes,
|
|
@@ -1158,12 +1156,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
1158
1156
|
|
|
1159
1157
|
const { get: get$2, translate } = core.MatrixHelper;
|
|
1160
1158
|
const tempBox = new core.Bounds();
|
|
1161
|
-
const tempPoint = {};
|
|
1162
1159
|
const tempScaleData = {};
|
|
1160
|
+
const tempImage = {};
|
|
1163
1161
|
function createData(leafPaint, image, paint, box) {
|
|
1164
|
-
const {
|
|
1165
|
-
if (blendMode)
|
|
1166
|
-
leafPaint.blendMode = blendMode;
|
|
1162
|
+
const { changeful, sync } = paint;
|
|
1167
1163
|
if (changeful)
|
|
1168
1164
|
leafPaint.changeful = changeful;
|
|
1169
1165
|
if (sync)
|
|
@@ -1171,38 +1167,38 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1171
1167
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1172
1168
|
}
|
|
1173
1169
|
function getPatternData(paint, box, image) {
|
|
1174
|
-
let { width, height } = image;
|
|
1175
1170
|
if (paint.padding)
|
|
1176
1171
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1177
1172
|
if (paint.mode === 'strench')
|
|
1178
1173
|
paint.mode = 'stretch';
|
|
1174
|
+
let { width, height } = image;
|
|
1179
1175
|
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1180
1176
|
const sameBox = box.width === width && box.height === height;
|
|
1181
1177
|
const data = { mode };
|
|
1182
1178
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
1183
|
-
|
|
1184
|
-
let
|
|
1179
|
+
core.BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
|
|
1180
|
+
let scaleX, scaleY;
|
|
1185
1181
|
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
1186
1182
|
if (!sameBox || rotation) {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1183
|
+
scaleX = scaleY = core.BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
|
|
1184
|
+
core.BoundsHelper.put(box, image, align, scaleX, false, tempImage);
|
|
1185
|
+
core.BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
1190
1186
|
}
|
|
1191
1187
|
}
|
|
1192
|
-
else
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1188
|
+
else {
|
|
1189
|
+
if (scale || size) {
|
|
1190
|
+
core.MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
1191
|
+
scaleX = tempScaleData.scaleX;
|
|
1192
|
+
scaleY = tempScaleData.scaleY;
|
|
1193
|
+
}
|
|
1194
|
+
if (align) {
|
|
1195
|
+
if (scaleX)
|
|
1196
|
+
core.BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
1197
|
+
core.AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
|
|
1198
|
+
}
|
|
1203
1199
|
}
|
|
1204
1200
|
if (offset)
|
|
1205
|
-
|
|
1201
|
+
core.PointHelper.move(tempImage, offset);
|
|
1206
1202
|
switch (mode) {
|
|
1207
1203
|
case 'stretch':
|
|
1208
1204
|
if (!sameBox)
|
|
@@ -1210,12 +1206,12 @@ function getPatternData(paint, box, image) {
|
|
|
1210
1206
|
break;
|
|
1211
1207
|
case 'normal':
|
|
1212
1208
|
case 'clip':
|
|
1213
|
-
if (x || y || scaleX || rotation)
|
|
1214
|
-
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
1209
|
+
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
1210
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1215
1211
|
break;
|
|
1216
1212
|
case 'repeat':
|
|
1217
1213
|
if (!sameBox || scaleX || rotation)
|
|
1218
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
|
|
1214
|
+
repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
|
|
1219
1215
|
if (!repeat)
|
|
1220
1216
|
data.repeat = 'repeat';
|
|
1221
1217
|
break;
|
|
@@ -1223,7 +1219,7 @@ function getPatternData(paint, box, image) {
|
|
|
1223
1219
|
case 'cover':
|
|
1224
1220
|
default:
|
|
1225
1221
|
if (scaleX)
|
|
1226
|
-
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
1222
|
+
fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1227
1223
|
}
|
|
1228
1224
|
if (!data.transform) {
|
|
1229
1225
|
if (box.x || box.y) {
|
|
@@ -1256,6 +1252,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1256
1252
|
}
|
|
1257
1253
|
else {
|
|
1258
1254
|
leafPaint = { type: paint.type, image };
|
|
1255
|
+
if (image.hasAlphaPixel)
|
|
1256
|
+
leafPaint.isTransparent = true;
|
|
1259
1257
|
cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
|
|
1260
1258
|
}
|
|
1261
1259
|
if (firstUse || image.loading)
|
|
@@ -1280,7 +1278,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1280
1278
|
ignoreRender(ui, false);
|
|
1281
1279
|
if (!ui.destroyed) {
|
|
1282
1280
|
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
1283
|
-
if (image.
|
|
1281
|
+
if (image.hasAlphaPixel)
|
|
1284
1282
|
ui.__layout.hitCanvasChanged = true;
|
|
1285
1283
|
ui.forceUpdate('surface');
|
|
1286
1284
|
}
|
|
@@ -1292,6 +1290,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1292
1290
|
onLoadError(ui, event, error);
|
|
1293
1291
|
leafPaint.loadId = null;
|
|
1294
1292
|
});
|
|
1293
|
+
if (ui.placeholderColor) {
|
|
1294
|
+
if (!ui.placeholderDelay)
|
|
1295
|
+
image.isPlacehold = true;
|
|
1296
|
+
else
|
|
1297
|
+
setTimeout(() => {
|
|
1298
|
+
if (!image.ready) {
|
|
1299
|
+
image.isPlacehold = true;
|
|
1300
|
+
ui.forceUpdate('surface');
|
|
1301
|
+
}
|
|
1302
|
+
}, ui.placeholderDelay);
|
|
1303
|
+
}
|
|
1295
1304
|
}
|
|
1296
1305
|
return leafPaint;
|
|
1297
1306
|
}
|
|
@@ -1529,32 +1538,33 @@ const PaintImageModule = {
|
|
|
1529
1538
|
repeatMode
|
|
1530
1539
|
};
|
|
1531
1540
|
|
|
1532
|
-
const { toPoint: toPoint$2 } = core.AroundHelper;
|
|
1541
|
+
const { toPoint: toPoint$2 } = core.AroundHelper, { hasTransparent } = draw.ColorConvert;
|
|
1533
1542
|
const realFrom$2 = {};
|
|
1534
1543
|
const realTo$2 = {};
|
|
1535
1544
|
function linearGradient(paint, box) {
|
|
1536
|
-
let { from, to, type,
|
|
1545
|
+
let { from, to, type, opacity } = paint;
|
|
1537
1546
|
toPoint$2(from || 'top', box, realFrom$2);
|
|
1538
1547
|
toPoint$2(to || 'bottom', box, realTo$2);
|
|
1539
1548
|
const style = core.Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
|
|
1540
|
-
applyStops(style, paint.stops, opacity);
|
|
1541
1549
|
const data = { type, style };
|
|
1542
|
-
|
|
1543
|
-
data.blendMode = blendMode;
|
|
1550
|
+
applyStops(data, style, paint.stops, opacity);
|
|
1544
1551
|
return data;
|
|
1545
1552
|
}
|
|
1546
|
-
function applyStops(gradient, stops, opacity) {
|
|
1553
|
+
function applyStops(data, gradient, stops, opacity) {
|
|
1547
1554
|
if (stops) {
|
|
1548
|
-
let stop;
|
|
1555
|
+
let stop, color, offset, isTransparent;
|
|
1549
1556
|
for (let i = 0, len = stops.length; i < len; i++) {
|
|
1550
1557
|
stop = stops[i];
|
|
1551
|
-
if (typeof stop === 'string')
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1558
|
+
if (typeof stop === 'string')
|
|
1559
|
+
offset = i / (len - 1), color = draw.ColorConvert.string(stop, opacity);
|
|
1560
|
+
else
|
|
1561
|
+
offset = stop.offset, color = draw.ColorConvert.string(stop.color, opacity);
|
|
1562
|
+
gradient.addColorStop(offset, color);
|
|
1563
|
+
if (!isTransparent && hasTransparent(color))
|
|
1564
|
+
isTransparent = true;
|
|
1557
1565
|
}
|
|
1566
|
+
if (isTransparent)
|
|
1567
|
+
data.isTransparent = true;
|
|
1558
1568
|
}
|
|
1559
1569
|
}
|
|
1560
1570
|
|
|
@@ -1564,17 +1574,15 @@ const { toPoint: toPoint$1 } = core.AroundHelper;
|
|
|
1564
1574
|
const realFrom$1 = {};
|
|
1565
1575
|
const realTo$1 = {};
|
|
1566
1576
|
function radialGradient(paint, box) {
|
|
1567
|
-
let { from, to, type, opacity,
|
|
1577
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
1568
1578
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
1569
1579
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
1570
1580
|
const style = core.Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
1571
|
-
applyStops(style, paint.stops, opacity);
|
|
1572
1581
|
const data = { type, style };
|
|
1582
|
+
applyStops(data, style, paint.stops, opacity);
|
|
1573
1583
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
1574
1584
|
if (transform)
|
|
1575
1585
|
data.transform = transform;
|
|
1576
|
-
if (blendMode)
|
|
1577
|
-
data.blendMode = blendMode;
|
|
1578
1586
|
return data;
|
|
1579
1587
|
}
|
|
1580
1588
|
function getTransform(box, from, to, stretch, rotate90) {
|
|
@@ -1600,17 +1608,15 @@ const { toPoint } = core.AroundHelper;
|
|
|
1600
1608
|
const realFrom = {};
|
|
1601
1609
|
const realTo = {};
|
|
1602
1610
|
function conicGradient(paint, box) {
|
|
1603
|
-
let { from, to, type, opacity,
|
|
1611
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
1604
1612
|
toPoint(from || 'center', box, realFrom);
|
|
1605
1613
|
toPoint(to || 'bottom', box, realTo);
|
|
1606
1614
|
const style = core.Platform.conicGradientSupport ? core.Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : core.Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
1607
|
-
applyStops(style, paint.stops, opacity);
|
|
1608
1615
|
const data = { type, style };
|
|
1616
|
+
applyStops(data, style, paint.stops, opacity);
|
|
1609
1617
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, core.Platform.conicGradientRotate90);
|
|
1610
1618
|
if (transform)
|
|
1611
1619
|
data.transform = transform;
|
|
1612
|
-
if (blendMode)
|
|
1613
|
-
data.blendMode = blendMode;
|
|
1614
1620
|
return data;
|
|
1615
1621
|
}
|
|
1616
1622
|
|
|
@@ -1943,6 +1949,8 @@ function createRows(drawData, content, style) {
|
|
|
1943
1949
|
lastCharType = null;
|
|
1944
1950
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
1945
1951
|
word = { data: [] }, row = { words: [] };
|
|
1952
|
+
if (__letterSpacing)
|
|
1953
|
+
content = [...content];
|
|
1946
1954
|
for (let i = 0, len = content.length; i < len; i++) {
|
|
1947
1955
|
char = content[i];
|
|
1948
1956
|
if (char === '\n') {
|
|
@@ -2381,4 +2389,3 @@ Object.keys(draw).forEach(function (k) {
|
|
|
2381
2389
|
get: function () { return draw[k]; }
|
|
2382
2390
|
});
|
|
2383
2391
|
});
|
|
2384
|
-
//# sourceMappingURL=miniapp.cjs.map
|