@leafer-draw/node 1.6.2 → 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/node.cjs +173 -179
- package/dist/node.esm.js +182 -188
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +10 -10
package/dist/node.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var core = require('@leafer/core');
|
|
4
4
|
var fs = require('fs');
|
|
5
5
|
var draw = require('@leafer-ui/draw');
|
|
6
|
+
var core$1 = require('@leafer-ui/core');
|
|
6
7
|
|
|
7
8
|
/******************************************************************************
|
|
8
9
|
Copyright (c) Microsoft Corporation.
|
|
@@ -173,17 +174,15 @@ class Watcher {
|
|
|
173
174
|
this.target.emitEvent(new core.WatchEvent(core.WatchEvent.DATA, { updatedList: this.updatedList }));
|
|
174
175
|
this.__updatedList = new core.LeafList();
|
|
175
176
|
this.totalTimes++;
|
|
176
|
-
this.changed = false;
|
|
177
|
-
this.hasVisible = false;
|
|
178
|
-
this.hasRemove = false;
|
|
179
|
-
this.hasAdd = false;
|
|
177
|
+
this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
|
|
180
178
|
}
|
|
181
179
|
__listenEvents() {
|
|
182
|
-
const { target } = this;
|
|
183
180
|
this.__eventIds = [
|
|
184
|
-
target.on_(
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
this.target.on_([
|
|
182
|
+
[core.PropertyEvent.CHANGE, this.__onAttrChange, this],
|
|
183
|
+
[[core.ChildEvent.ADD, core.ChildEvent.REMOVE], this.__onChildEvent, this],
|
|
184
|
+
[core.WatchEvent.REQUEST, this.__onRquestData, this]
|
|
185
|
+
])
|
|
187
186
|
];
|
|
188
187
|
}
|
|
189
188
|
__removeListenEvents() {
|
|
@@ -193,8 +192,7 @@ class Watcher {
|
|
|
193
192
|
if (this.target) {
|
|
194
193
|
this.stop();
|
|
195
194
|
this.__removeListenEvents();
|
|
196
|
-
this.target = null;
|
|
197
|
-
this.__updatedList = null;
|
|
195
|
+
this.target = this.__updatedList = null;
|
|
198
196
|
}
|
|
199
197
|
}
|
|
200
198
|
}
|
|
@@ -299,7 +297,7 @@ class Layouter {
|
|
|
299
297
|
this.disabled = true;
|
|
300
298
|
}
|
|
301
299
|
layout() {
|
|
302
|
-
if (!this.running)
|
|
300
|
+
if (this.layouting || !this.running)
|
|
303
301
|
return;
|
|
304
302
|
const { target } = this;
|
|
305
303
|
this.times = 0;
|
|
@@ -382,12 +380,10 @@ class Layouter {
|
|
|
382
380
|
}
|
|
383
381
|
static fullLayout(target) {
|
|
384
382
|
updateAllMatrix(target, true);
|
|
385
|
-
if (target.isBranch)
|
|
383
|
+
if (target.isBranch)
|
|
386
384
|
core.BranchHelper.updateBounds(target);
|
|
387
|
-
|
|
388
|
-
else {
|
|
385
|
+
else
|
|
389
386
|
core.LeafHelper.updateBounds(target);
|
|
390
|
-
}
|
|
391
387
|
updateAllChange(target);
|
|
392
388
|
}
|
|
393
389
|
addExtra(leaf) {
|
|
@@ -410,11 +406,12 @@ class Layouter {
|
|
|
410
406
|
this.__updatedList = event.data.updatedList;
|
|
411
407
|
}
|
|
412
408
|
__listenEvents() {
|
|
413
|
-
const { target } = this;
|
|
414
409
|
this.__eventIds = [
|
|
415
|
-
target.on_(
|
|
416
|
-
|
|
417
|
-
|
|
410
|
+
this.target.on_([
|
|
411
|
+
[core.LayoutEvent.REQUEST, this.layout, this],
|
|
412
|
+
[core.LayoutEvent.AGAIN, this.layoutAgain, this],
|
|
413
|
+
[core.WatchEvent.DATA, this.__onReceiveWatchData, this]
|
|
414
|
+
])
|
|
418
415
|
];
|
|
419
416
|
}
|
|
420
417
|
__removeListenEvents() {
|
|
@@ -645,12 +642,13 @@ class Renderer {
|
|
|
645
642
|
this.target.emitEvent(new core.RenderEvent(type, this.times, bounds, options));
|
|
646
643
|
}
|
|
647
644
|
__listenEvents() {
|
|
648
|
-
const { target } = this;
|
|
649
645
|
this.__eventIds = [
|
|
650
|
-
target.on_(
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
646
|
+
this.target.on_([
|
|
647
|
+
[core.RenderEvent.REQUEST, this.update, this],
|
|
648
|
+
[core.LayoutEvent.END, this.__onLayoutEnd, this],
|
|
649
|
+
[core.RenderEvent.AGAIN, this.renderAgain, this],
|
|
650
|
+
[core.ResizeEvent.RESIZE, this.__onResize, this]
|
|
651
|
+
])
|
|
654
652
|
];
|
|
655
653
|
}
|
|
656
654
|
__removeListenEvents() {
|
|
@@ -736,32 +734,34 @@ function fillPathOrText(ui, canvas) {
|
|
|
736
734
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
737
735
|
}
|
|
738
736
|
|
|
737
|
+
const Paint = {};
|
|
738
|
+
|
|
739
739
|
function strokeText(stroke, ui, canvas) {
|
|
740
|
-
|
|
741
|
-
const isStrokes = typeof stroke !== 'string';
|
|
742
|
-
switch (strokeAlign) {
|
|
740
|
+
switch (ui.__.strokeAlign) {
|
|
743
741
|
case 'center':
|
|
744
|
-
|
|
745
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
742
|
+
drawCenter$1(stroke, 1, ui, canvas);
|
|
746
743
|
break;
|
|
747
744
|
case 'inside':
|
|
748
|
-
|
|
745
|
+
drawAlign(stroke, 'inside', ui, canvas);
|
|
749
746
|
break;
|
|
750
747
|
case 'outside':
|
|
751
|
-
|
|
748
|
+
ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
|
|
752
749
|
break;
|
|
753
750
|
}
|
|
754
751
|
}
|
|
755
|
-
function
|
|
756
|
-
const
|
|
752
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
753
|
+
const data = ui.__;
|
|
754
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
|
|
755
|
+
data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
756
|
+
}
|
|
757
|
+
function drawAlign(stroke, align, ui, canvas) {
|
|
757
758
|
const out = canvas.getSameCanvas(true, true);
|
|
758
|
-
out.
|
|
759
|
-
|
|
760
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
|
|
759
|
+
out.font = ui.__.__font;
|
|
760
|
+
drawCenter$1(stroke, 2, ui, out);
|
|
761
761
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
762
762
|
fillText(ui, out);
|
|
763
763
|
out.blendMode = 'normal';
|
|
764
|
-
if (ui.__worldFlipped)
|
|
764
|
+
if (ui.__worldFlipped || core$1.Platform.fullImageShadow)
|
|
765
765
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
766
766
|
else
|
|
767
767
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
@@ -803,90 +803,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
|
803
803
|
}
|
|
804
804
|
|
|
805
805
|
function stroke(stroke, ui, canvas) {
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
if (!__strokeWidth)
|
|
806
|
+
const data = ui.__;
|
|
807
|
+
if (!data.__strokeWidth)
|
|
809
808
|
return;
|
|
810
|
-
if (__font) {
|
|
809
|
+
if (data.__font) {
|
|
811
810
|
strokeText(stroke, ui, canvas);
|
|
812
811
|
}
|
|
813
812
|
else {
|
|
814
|
-
switch (strokeAlign) {
|
|
813
|
+
switch (data.strokeAlign) {
|
|
815
814
|
case 'center':
|
|
816
|
-
|
|
817
|
-
canvas.stroke();
|
|
818
|
-
if (options.__useArrow)
|
|
819
|
-
strokeArrow(ui, canvas);
|
|
815
|
+
drawCenter(stroke, 1, ui, canvas);
|
|
820
816
|
break;
|
|
821
817
|
case 'inside':
|
|
822
|
-
canvas
|
|
823
|
-
canvas.setStroke(stroke, __strokeWidth * 2, options);
|
|
824
|
-
options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
|
|
825
|
-
canvas.stroke();
|
|
826
|
-
canvas.restore();
|
|
818
|
+
drawInside(stroke, ui, canvas);
|
|
827
819
|
break;
|
|
828
820
|
case 'outside':
|
|
829
|
-
|
|
830
|
-
out.setStroke(stroke, __strokeWidth * 2, options);
|
|
831
|
-
ui.__drawRenderPath(out);
|
|
832
|
-
out.stroke();
|
|
833
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
834
|
-
out.clearWorld(ui.__layout.renderBounds);
|
|
835
|
-
if (ui.__worldFlipped)
|
|
836
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
837
|
-
else
|
|
838
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
839
|
-
out.recycle(ui.__nowWorld);
|
|
821
|
+
drawOutside(stroke, ui, canvas);
|
|
840
822
|
break;
|
|
841
823
|
}
|
|
842
824
|
}
|
|
843
825
|
}
|
|
844
826
|
function strokes(strokes, ui, canvas) {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
827
|
+
stroke(strokes, ui, canvas);
|
|
828
|
+
}
|
|
829
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
830
|
+
const data = ui.__;
|
|
831
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
832
|
+
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
833
|
+
if (data.__useArrow)
|
|
834
|
+
Paint.strokeArrow(stroke, ui, canvas);
|
|
835
|
+
}
|
|
836
|
+
function drawInside(stroke, ui, canvas) {
|
|
837
|
+
const data = ui.__;
|
|
838
|
+
canvas.save();
|
|
839
|
+
data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
|
|
840
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
841
|
+
canvas.restore();
|
|
842
|
+
}
|
|
843
|
+
function drawOutside(stroke, ui, canvas) {
|
|
844
|
+
const data = ui.__;
|
|
845
|
+
if (data.__fillAfterStroke) {
|
|
846
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
851
847
|
}
|
|
852
848
|
else {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
drawStrokesStyle(strokes, false, ui, canvas);
|
|
865
|
-
canvas.restore();
|
|
866
|
-
break;
|
|
867
|
-
case 'outside':
|
|
868
|
-
const { renderBounds } = ui.__layout;
|
|
869
|
-
const out = canvas.getSameCanvas(true, true);
|
|
870
|
-
ui.__drawRenderPath(out);
|
|
871
|
-
out.setStroke(undefined, __strokeWidth * 2, options);
|
|
872
|
-
drawStrokesStyle(strokes, false, ui, out);
|
|
873
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
874
|
-
out.clearWorld(renderBounds);
|
|
875
|
-
if (ui.__worldFlipped)
|
|
876
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
877
|
-
else
|
|
878
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
879
|
-
out.recycle(ui.__nowWorld);
|
|
880
|
-
break;
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
function strokeArrow(ui, canvas) {
|
|
885
|
-
if (ui.__.dashPattern) {
|
|
886
|
-
canvas.beginPath();
|
|
887
|
-
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
888
|
-
canvas.dashPattern = null;
|
|
889
|
-
canvas.stroke();
|
|
849
|
+
const { renderBounds } = ui.__layout;
|
|
850
|
+
const out = canvas.getSameCanvas(true, true);
|
|
851
|
+
ui.__drawRenderPath(out);
|
|
852
|
+
drawCenter(stroke, 2, ui, out);
|
|
853
|
+
data.windingRule ? out.clip(data.windingRule) : out.clip();
|
|
854
|
+
out.clearWorld(renderBounds);
|
|
855
|
+
if (ui.__worldFlipped || core$1.Platform.fullImageShadow)
|
|
856
|
+
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
857
|
+
else
|
|
858
|
+
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
859
|
+
out.recycle(ui.__nowWorld);
|
|
890
860
|
}
|
|
891
861
|
}
|
|
892
862
|
|
|
@@ -933,9 +903,10 @@ function shape(ui, current, options) {
|
|
|
933
903
|
}
|
|
934
904
|
|
|
935
905
|
let recycleMap;
|
|
906
|
+
const { stintSet } = core.DataHelper, { hasTransparent: hasTransparent$1 } = draw.ColorConvert;
|
|
936
907
|
function compute(attrName, ui) {
|
|
937
908
|
const data = ui.__, leafPaints = [];
|
|
938
|
-
let paints = data.__input[attrName],
|
|
909
|
+
let paints = data.__input[attrName], isAlphaPixel, isTransparent;
|
|
939
910
|
if (!(paints instanceof Array))
|
|
940
911
|
paints = [paints];
|
|
941
912
|
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
@@ -945,29 +916,55 @@ function compute(attrName, ui) {
|
|
|
945
916
|
leafPaints.push(item);
|
|
946
917
|
}
|
|
947
918
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
948
|
-
if (leafPaints.length
|
|
949
|
-
|
|
950
|
-
|
|
919
|
+
if (leafPaints.length) {
|
|
920
|
+
if (leafPaints.every(item => item.isTransparent)) {
|
|
921
|
+
if (leafPaints.some(item => item.image))
|
|
922
|
+
isAlphaPixel = true;
|
|
923
|
+
isTransparent = true;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
if (attrName === 'fill') {
|
|
927
|
+
stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
|
|
928
|
+
stintSet(data, '__isTransparentFill', isTransparent);
|
|
929
|
+
}
|
|
930
|
+
else {
|
|
931
|
+
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
932
|
+
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
933
|
+
}
|
|
951
934
|
}
|
|
952
935
|
function getLeafPaint(attrName, paint, ui) {
|
|
953
936
|
if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
|
|
954
937
|
return undefined;
|
|
938
|
+
let data;
|
|
955
939
|
const { boxBounds } = ui.__layout;
|
|
956
940
|
switch (paint.type) {
|
|
957
|
-
case 'solid':
|
|
958
|
-
let { type, blendMode, color, opacity } = paint;
|
|
959
|
-
return { type, blendMode, style: draw.ColorConvert.string(color, opacity) };
|
|
960
941
|
case 'image':
|
|
961
|
-
|
|
942
|
+
data = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
943
|
+
break;
|
|
962
944
|
case 'linear':
|
|
963
|
-
|
|
945
|
+
data = draw.PaintGradient.linearGradient(paint, boxBounds);
|
|
946
|
+
break;
|
|
964
947
|
case 'radial':
|
|
965
|
-
|
|
948
|
+
data = draw.PaintGradient.radialGradient(paint, boxBounds);
|
|
949
|
+
break;
|
|
966
950
|
case 'angular':
|
|
967
|
-
|
|
951
|
+
data = draw.PaintGradient.conicGradient(paint, boxBounds);
|
|
952
|
+
break;
|
|
953
|
+
case 'solid':
|
|
954
|
+
const { type, blendMode, color, opacity } = paint;
|
|
955
|
+
data = { type, blendMode, style: draw.ColorConvert.string(color, opacity) };
|
|
956
|
+
break;
|
|
968
957
|
default:
|
|
969
|
-
|
|
958
|
+
if (paint.r !== undefined)
|
|
959
|
+
data = { type: 'solid', style: draw.ColorConvert.string(paint) };
|
|
960
|
+
}
|
|
961
|
+
if (data) {
|
|
962
|
+
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
963
|
+
data.isTransparent = true;
|
|
964
|
+
if (paint.blendMode)
|
|
965
|
+
data.blendMode = paint.blendMode;
|
|
970
966
|
}
|
|
967
|
+
return data;
|
|
971
968
|
}
|
|
972
969
|
|
|
973
970
|
const PaintModule = {
|
|
@@ -1033,12 +1030,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
1033
1030
|
|
|
1034
1031
|
const { get: get$2, translate } = core.MatrixHelper;
|
|
1035
1032
|
const tempBox = new core.Bounds();
|
|
1036
|
-
const tempPoint = {};
|
|
1037
1033
|
const tempScaleData = {};
|
|
1034
|
+
const tempImage = {};
|
|
1038
1035
|
function createData(leafPaint, image, paint, box) {
|
|
1039
|
-
const {
|
|
1040
|
-
if (blendMode)
|
|
1041
|
-
leafPaint.blendMode = blendMode;
|
|
1036
|
+
const { changeful, sync } = paint;
|
|
1042
1037
|
if (changeful)
|
|
1043
1038
|
leafPaint.changeful = changeful;
|
|
1044
1039
|
if (sync)
|
|
@@ -1046,38 +1041,38 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1046
1041
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1047
1042
|
}
|
|
1048
1043
|
function getPatternData(paint, box, image) {
|
|
1049
|
-
let { width, height } = image;
|
|
1050
1044
|
if (paint.padding)
|
|
1051
1045
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1052
1046
|
if (paint.mode === 'strench')
|
|
1053
1047
|
paint.mode = 'stretch';
|
|
1048
|
+
let { width, height } = image;
|
|
1054
1049
|
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1055
1050
|
const sameBox = box.width === width && box.height === height;
|
|
1056
1051
|
const data = { mode };
|
|
1057
1052
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
1058
|
-
|
|
1059
|
-
let
|
|
1053
|
+
core.BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
|
|
1054
|
+
let scaleX, scaleY;
|
|
1060
1055
|
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
1061
1056
|
if (!sameBox || rotation) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1057
|
+
scaleX = scaleY = core.BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
|
|
1058
|
+
core.BoundsHelper.put(box, image, align, scaleX, false, tempImage);
|
|
1059
|
+
core.BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
1065
1060
|
}
|
|
1066
1061
|
}
|
|
1067
|
-
else
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1062
|
+
else {
|
|
1063
|
+
if (scale || size) {
|
|
1064
|
+
core.MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
1065
|
+
scaleX = tempScaleData.scaleX;
|
|
1066
|
+
scaleY = tempScaleData.scaleY;
|
|
1067
|
+
}
|
|
1068
|
+
if (align) {
|
|
1069
|
+
if (scaleX)
|
|
1070
|
+
core.BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
1071
|
+
core.AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
|
|
1072
|
+
}
|
|
1078
1073
|
}
|
|
1079
1074
|
if (offset)
|
|
1080
|
-
|
|
1075
|
+
core.PointHelper.move(tempImage, offset);
|
|
1081
1076
|
switch (mode) {
|
|
1082
1077
|
case 'stretch':
|
|
1083
1078
|
if (!sameBox)
|
|
@@ -1085,12 +1080,12 @@ function getPatternData(paint, box, image) {
|
|
|
1085
1080
|
break;
|
|
1086
1081
|
case 'normal':
|
|
1087
1082
|
case 'clip':
|
|
1088
|
-
if (x || y || scaleX || rotation)
|
|
1089
|
-
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
1083
|
+
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
1084
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1090
1085
|
break;
|
|
1091
1086
|
case 'repeat':
|
|
1092
1087
|
if (!sameBox || scaleX || rotation)
|
|
1093
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
|
|
1088
|
+
repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
|
|
1094
1089
|
if (!repeat)
|
|
1095
1090
|
data.repeat = 'repeat';
|
|
1096
1091
|
break;
|
|
@@ -1098,7 +1093,7 @@ function getPatternData(paint, box, image) {
|
|
|
1098
1093
|
case 'cover':
|
|
1099
1094
|
default:
|
|
1100
1095
|
if (scaleX)
|
|
1101
|
-
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
1096
|
+
fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1102
1097
|
}
|
|
1103
1098
|
if (!data.transform) {
|
|
1104
1099
|
if (box.x || box.y) {
|
|
@@ -1131,6 +1126,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1131
1126
|
}
|
|
1132
1127
|
else {
|
|
1133
1128
|
leafPaint = { type: paint.type, image };
|
|
1129
|
+
if (image.hasAlphaPixel)
|
|
1130
|
+
leafPaint.isTransparent = true;
|
|
1134
1131
|
cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
|
|
1135
1132
|
}
|
|
1136
1133
|
if (firstUse || image.loading)
|
|
@@ -1155,7 +1152,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1155
1152
|
ignoreRender(ui, false);
|
|
1156
1153
|
if (!ui.destroyed) {
|
|
1157
1154
|
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
1158
|
-
if (image.
|
|
1155
|
+
if (image.hasAlphaPixel)
|
|
1159
1156
|
ui.__layout.hitCanvasChanged = true;
|
|
1160
1157
|
ui.forceUpdate('surface');
|
|
1161
1158
|
}
|
|
@@ -1167,13 +1164,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1167
1164
|
onLoadError(ui, event, error);
|
|
1168
1165
|
leafPaint.loadId = null;
|
|
1169
1166
|
});
|
|
1170
|
-
if (ui.placeholderColor)
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1167
|
+
if (ui.placeholderColor) {
|
|
1168
|
+
if (!ui.placeholderDelay)
|
|
1169
|
+
image.isPlacehold = true;
|
|
1170
|
+
else
|
|
1171
|
+
setTimeout(() => {
|
|
1172
|
+
if (!image.ready) {
|
|
1173
|
+
image.isPlacehold = true;
|
|
1174
|
+
ui.forceUpdate('surface');
|
|
1175
|
+
}
|
|
1176
|
+
}, ui.placeholderDelay);
|
|
1177
|
+
}
|
|
1177
1178
|
}
|
|
1178
1179
|
return leafPaint;
|
|
1179
1180
|
}
|
|
@@ -1379,32 +1380,33 @@ const PaintImageModule = {
|
|
|
1379
1380
|
repeatMode
|
|
1380
1381
|
};
|
|
1381
1382
|
|
|
1382
|
-
const { toPoint: toPoint$2 } = core.AroundHelper;
|
|
1383
|
+
const { toPoint: toPoint$2 } = core.AroundHelper, { hasTransparent } = draw.ColorConvert;
|
|
1383
1384
|
const realFrom$2 = {};
|
|
1384
1385
|
const realTo$2 = {};
|
|
1385
1386
|
function linearGradient(paint, box) {
|
|
1386
|
-
let { from, to, type,
|
|
1387
|
+
let { from, to, type, opacity } = paint;
|
|
1387
1388
|
toPoint$2(from || 'top', box, realFrom$2);
|
|
1388
1389
|
toPoint$2(to || 'bottom', box, realTo$2);
|
|
1389
1390
|
const style = core.Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
|
|
1390
|
-
applyStops(style, paint.stops, opacity);
|
|
1391
1391
|
const data = { type, style };
|
|
1392
|
-
|
|
1393
|
-
data.blendMode = blendMode;
|
|
1392
|
+
applyStops(data, style, paint.stops, opacity);
|
|
1394
1393
|
return data;
|
|
1395
1394
|
}
|
|
1396
|
-
function applyStops(gradient, stops, opacity) {
|
|
1395
|
+
function applyStops(data, gradient, stops, opacity) {
|
|
1397
1396
|
if (stops) {
|
|
1398
|
-
let stop;
|
|
1397
|
+
let stop, color, offset, isTransparent;
|
|
1399
1398
|
for (let i = 0, len = stops.length; i < len; i++) {
|
|
1400
1399
|
stop = stops[i];
|
|
1401
|
-
if (typeof stop === 'string')
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1400
|
+
if (typeof stop === 'string')
|
|
1401
|
+
offset = i / (len - 1), color = draw.ColorConvert.string(stop, opacity);
|
|
1402
|
+
else
|
|
1403
|
+
offset = stop.offset, color = draw.ColorConvert.string(stop.color, opacity);
|
|
1404
|
+
gradient.addColorStop(offset, color);
|
|
1405
|
+
if (!isTransparent && hasTransparent(color))
|
|
1406
|
+
isTransparent = true;
|
|
1407
1407
|
}
|
|
1408
|
+
if (isTransparent)
|
|
1409
|
+
data.isTransparent = true;
|
|
1408
1410
|
}
|
|
1409
1411
|
}
|
|
1410
1412
|
|
|
@@ -1414,17 +1416,15 @@ const { toPoint: toPoint$1 } = core.AroundHelper;
|
|
|
1414
1416
|
const realFrom$1 = {};
|
|
1415
1417
|
const realTo$1 = {};
|
|
1416
1418
|
function radialGradient(paint, box) {
|
|
1417
|
-
let { from, to, type, opacity,
|
|
1419
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
1418
1420
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
1419
1421
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
1420
1422
|
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));
|
|
1421
|
-
applyStops(style, paint.stops, opacity);
|
|
1422
1423
|
const data = { type, style };
|
|
1424
|
+
applyStops(data, style, paint.stops, opacity);
|
|
1423
1425
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
1424
1426
|
if (transform)
|
|
1425
1427
|
data.transform = transform;
|
|
1426
|
-
if (blendMode)
|
|
1427
|
-
data.blendMode = blendMode;
|
|
1428
1428
|
return data;
|
|
1429
1429
|
}
|
|
1430
1430
|
function getTransform(box, from, to, stretch, rotate90) {
|
|
@@ -1450,17 +1450,15 @@ const { toPoint } = core.AroundHelper;
|
|
|
1450
1450
|
const realFrom = {};
|
|
1451
1451
|
const realTo = {};
|
|
1452
1452
|
function conicGradient(paint, box) {
|
|
1453
|
-
let { from, to, type, opacity,
|
|
1453
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
1454
1454
|
toPoint(from || 'center', box, realFrom);
|
|
1455
1455
|
toPoint(to || 'bottom', box, realTo);
|
|
1456
1456
|
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));
|
|
1457
|
-
applyStops(style, paint.stops, opacity);
|
|
1458
1457
|
const data = { type, style };
|
|
1458
|
+
applyStops(data, style, paint.stops, opacity);
|
|
1459
1459
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, core.Platform.conicGradientRotate90);
|
|
1460
1460
|
if (transform)
|
|
1461
1461
|
data.transform = transform;
|
|
1462
|
-
if (blendMode)
|
|
1463
|
-
data.blendMode = blendMode;
|
|
1464
1462
|
return data;
|
|
1465
1463
|
}
|
|
1466
1464
|
|
|
@@ -1793,6 +1791,8 @@ function createRows(drawData, content, style) {
|
|
|
1793
1791
|
lastCharType = null;
|
|
1794
1792
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
1795
1793
|
word = { data: [] }, row = { words: [] };
|
|
1794
|
+
if (__letterSpacing)
|
|
1795
|
+
content = [...content];
|
|
1796
1796
|
for (let i = 0, len = content.length; i < len; i++) {
|
|
1797
1797
|
char = content[i];
|
|
1798
1798
|
if (char === '\n') {
|
|
@@ -2242,10 +2242,9 @@ const ExportModule = {
|
|
|
2242
2242
|
else {
|
|
2243
2243
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2244
2244
|
const { worldTransform, isLeafer, leafer, isFrame } = leaf;
|
|
2245
|
-
const { slice, clip, trim, padding, onCanvas } = options;
|
|
2245
|
+
const { slice, clip, trim, screenshot, padding, onCanvas } = options;
|
|
2246
2246
|
const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
|
|
2247
2247
|
const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
|
|
2248
|
-
const screenshot = options.screenshot || leaf.isApp;
|
|
2249
2248
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
2250
2249
|
const needFill = draw.FileHelper.isOpaqueImage(filename) || fill, matrix = new draw.Matrix();
|
|
2251
2250
|
if (screenshot) {
|
|
@@ -2281,11 +2280,6 @@ const ExportModule = {
|
|
|
2281
2280
|
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
2282
2281
|
draw.MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
2283
2282
|
let pixelRatio = options.pixelRatio || 1;
|
|
2284
|
-
if (leaf.isApp) {
|
|
2285
|
-
scaleData.scaleX *= pixelRatio;
|
|
2286
|
-
scaleData.scaleY *= pixelRatio;
|
|
2287
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
2288
|
-
}
|
|
2289
2283
|
let { x, y, width, height } = new draw.Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
2290
2284
|
if (clip)
|
|
2291
2285
|
x += clip.x, y += clip.y, width = clip.width, height = clip.height;
|