@leafer-draw/miniapp 1.7.0 → 1.8.0
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 +77 -47
- package/dist/miniapp.esm.js +78 -48
- 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 +228 -134
- 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
CHANGED
|
@@ -836,9 +836,14 @@ function fills(fills, ui, canvas) {
|
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
838
|
canvas.fillStyle = item.style;
|
|
839
|
-
if (item.transform) {
|
|
839
|
+
if (item.transform || item.scaleFixed) {
|
|
840
840
|
canvas.save();
|
|
841
|
-
|
|
841
|
+
if (item.transform)
|
|
842
|
+
canvas.transform(item.transform);
|
|
843
|
+
if (item.scaleFixed) {
|
|
844
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true);
|
|
845
|
+
canvas.scale(1 / scaleX, 1 / scaleY);
|
|
846
|
+
}
|
|
842
847
|
if (item.blendMode)
|
|
843
848
|
canvas.blendMode = item.blendMode;
|
|
844
849
|
fillPathOrText(ui, canvas);
|
|
@@ -874,8 +879,13 @@ function strokeText(stroke, ui, canvas) {
|
|
|
874
879
|
}
|
|
875
880
|
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
876
881
|
const data = ui.__;
|
|
877
|
-
|
|
878
|
-
|
|
882
|
+
if (typeof stroke === 'object') {
|
|
883
|
+
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
884
|
+
}
|
|
885
|
+
else {
|
|
886
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
887
|
+
drawTextStroke(ui, canvas);
|
|
888
|
+
}
|
|
879
889
|
}
|
|
880
890
|
function drawAlign(stroke, align, ui, canvas) {
|
|
881
891
|
const out = canvas.getSameCanvas(true, true);
|
|
@@ -884,15 +894,9 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
884
894
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
885
895
|
fillText(ui, out);
|
|
886
896
|
out.blendMode = 'normal';
|
|
887
|
-
|
|
897
|
+
core.LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
888
898
|
out.recycle(ui.__nowWorld);
|
|
889
899
|
}
|
|
890
|
-
function copyWorld(canvas, out, ui) {
|
|
891
|
-
if (ui.__worldFlipped || core.Platform.fullImageShadow)
|
|
892
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
893
|
-
else
|
|
894
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
895
|
-
}
|
|
896
900
|
function drawTextStroke(ui, canvas) {
|
|
897
901
|
let row, data = ui.__.__textDrawData;
|
|
898
902
|
const { rows, decorationY } = data;
|
|
@@ -908,14 +912,21 @@ function drawTextStroke(ui, canvas) {
|
|
|
908
912
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
909
913
|
}
|
|
910
914
|
}
|
|
911
|
-
function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
915
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
912
916
|
let item;
|
|
917
|
+
const data = ui.__, { __hasMultiStrokeStyle } = data;
|
|
918
|
+
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
913
919
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
914
920
|
item = strokes[i];
|
|
915
921
|
if (item.image && draw.PaintImage.checkImage(ui, canvas, item, false))
|
|
916
922
|
continue;
|
|
917
923
|
if (item.style) {
|
|
918
|
-
|
|
924
|
+
if (__hasMultiStrokeStyle) {
|
|
925
|
+
const { strokeStyle } = item;
|
|
926
|
+
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
927
|
+
}
|
|
928
|
+
else
|
|
929
|
+
canvas.strokeStyle = item.style;
|
|
919
930
|
if (item.blendMode) {
|
|
920
931
|
canvas.saveBlendMode(item.blendMode);
|
|
921
932
|
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
@@ -954,8 +965,13 @@ function strokes(strokes, ui, canvas) {
|
|
|
954
965
|
}
|
|
955
966
|
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
956
967
|
const data = ui.__;
|
|
957
|
-
|
|
958
|
-
|
|
968
|
+
if (typeof stroke === 'object') {
|
|
969
|
+
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
973
|
+
canvas.stroke();
|
|
974
|
+
}
|
|
959
975
|
if (data.__useArrow)
|
|
960
976
|
draw.Paint.strokeArrow(stroke, ui, canvas);
|
|
961
977
|
}
|
|
@@ -977,7 +993,7 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
977
993
|
drawCenter(stroke, 2, ui, out);
|
|
978
994
|
out.clipUI(data);
|
|
979
995
|
out.clearWorld(renderBounds);
|
|
980
|
-
|
|
996
|
+
core.LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
981
997
|
out.recycle(ui.__nowWorld);
|
|
982
998
|
}
|
|
983
999
|
}
|
|
@@ -1032,8 +1048,16 @@ function compute(attrName, ui) {
|
|
|
1032
1048
|
if (!(paints instanceof Array))
|
|
1033
1049
|
paints = [paints];
|
|
1034
1050
|
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
1051
|
+
let maxChildStrokeWidth;
|
|
1035
1052
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1036
|
-
(item = getLeafPaint(attrName, paints[i], ui))
|
|
1053
|
+
if (item = getLeafPaint(attrName, paints[i], ui)) {
|
|
1054
|
+
leafPaints.push(item);
|
|
1055
|
+
if (item.strokeStyle) {
|
|
1056
|
+
maxChildStrokeWidth || (maxChildStrokeWidth = 1);
|
|
1057
|
+
if (item.strokeStyle.strokeWidth)
|
|
1058
|
+
maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1037
1061
|
}
|
|
1038
1062
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1039
1063
|
if (leafPaints.length) {
|
|
@@ -1050,6 +1074,7 @@ function compute(attrName, ui) {
|
|
|
1050
1074
|
else {
|
|
1051
1075
|
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1052
1076
|
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1077
|
+
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
|
|
1053
1078
|
}
|
|
1054
1079
|
}
|
|
1055
1080
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -1081,6 +1106,11 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1081
1106
|
if (data) {
|
|
1082
1107
|
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1083
1108
|
data.isTransparent = true;
|
|
1109
|
+
if (paint.style) {
|
|
1110
|
+
if (paint.style.strokeWidth === 0)
|
|
1111
|
+
return undefined;
|
|
1112
|
+
data.strokeStyle = paint.style;
|
|
1113
|
+
}
|
|
1084
1114
|
if (paint.blendMode)
|
|
1085
1115
|
data.blendMode = paint.blendMode;
|
|
1086
1116
|
}
|
|
@@ -1100,8 +1130,8 @@ const PaintModule = {
|
|
|
1100
1130
|
shape
|
|
1101
1131
|
};
|
|
1102
1132
|
|
|
1103
|
-
let origin = {};
|
|
1104
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = core.MatrixHelper;
|
|
1133
|
+
let origin = {}, tempMatrix = core.getMatrixData();
|
|
1134
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = core.MatrixHelper;
|
|
1105
1135
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1106
1136
|
const transform = get$3();
|
|
1107
1137
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -1110,7 +1140,7 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1110
1140
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1111
1141
|
data.transform = transform;
|
|
1112
1142
|
}
|
|
1113
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
1143
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
|
|
1114
1144
|
const transform = get$3();
|
|
1115
1145
|
if (rotation)
|
|
1116
1146
|
rotate(transform, rotation);
|
|
@@ -1119,6 +1149,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
|
1119
1149
|
if (scaleX)
|
|
1120
1150
|
scaleHelper(transform, scaleX, scaleY);
|
|
1121
1151
|
translate$1(transform, box.x + x, box.y + y);
|
|
1152
|
+
if (clipSize) {
|
|
1153
|
+
tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
|
|
1154
|
+
multiplyParent(transform, tempMatrix);
|
|
1155
|
+
}
|
|
1122
1156
|
data.transform = transform;
|
|
1123
1157
|
}
|
|
1124
1158
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -1155,13 +1189,15 @@ const tempBox = new core.Bounds();
|
|
|
1155
1189
|
const tempScaleData = {};
|
|
1156
1190
|
const tempImage = {};
|
|
1157
1191
|
function createData(leafPaint, image, paint, box) {
|
|
1158
|
-
const { changeful, sync, editing } = paint;
|
|
1192
|
+
const { changeful, sync, editing, scaleFixed } = paint;
|
|
1159
1193
|
if (changeful)
|
|
1160
1194
|
leafPaint.changeful = changeful;
|
|
1161
1195
|
if (sync)
|
|
1162
1196
|
leafPaint.sync = sync;
|
|
1163
1197
|
if (editing)
|
|
1164
1198
|
leafPaint.editing = editing;
|
|
1199
|
+
if (scaleFixed)
|
|
1200
|
+
leafPaint.scaleFixed = scaleFixed;
|
|
1165
1201
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1166
1202
|
}
|
|
1167
1203
|
function getPatternData(paint, box, image) {
|
|
@@ -1170,7 +1206,7 @@ function getPatternData(paint, box, image) {
|
|
|
1170
1206
|
if (paint.mode === 'strench')
|
|
1171
1207
|
paint.mode = 'stretch';
|
|
1172
1208
|
let { width, height } = image;
|
|
1173
|
-
const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
|
|
1209
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
|
|
1174
1210
|
const sameBox = box.width === width && box.height === height;
|
|
1175
1211
|
const data = { mode };
|
|
1176
1212
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1204,8 +1240,8 @@ function getPatternData(paint, box, image) {
|
|
|
1204
1240
|
break;
|
|
1205
1241
|
case 'normal':
|
|
1206
1242
|
case 'clip':
|
|
1207
|
-
if (tempImage.x || tempImage.y || scaleX || rotation || skew)
|
|
1208
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
|
|
1243
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1244
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
|
|
1209
1245
|
break;
|
|
1210
1246
|
case 'repeat':
|
|
1211
1247
|
if (!sameBox || scaleX || rotation)
|
|
@@ -1342,18 +1378,16 @@ function ignoreRender(ui, value) {
|
|
|
1342
1378
|
}
|
|
1343
1379
|
|
|
1344
1380
|
const { get: get$1, scale, copy: copy$1 } = core.MatrixHelper;
|
|
1345
|
-
const { ceil, abs
|
|
1381
|
+
const { ceil, abs } = Math;
|
|
1346
1382
|
function createPattern(ui, paint, pixelRatio) {
|
|
1347
|
-
let { scaleX, scaleY } =
|
|
1383
|
+
let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1348
1384
|
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1349
1385
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1350
|
-
scaleX = abs$1(scaleX);
|
|
1351
|
-
scaleY = abs$1(scaleY);
|
|
1352
1386
|
const { image, data } = paint;
|
|
1353
1387
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1354
1388
|
if (sx) {
|
|
1355
|
-
sx = abs
|
|
1356
|
-
sy = abs
|
|
1389
|
+
sx = abs(sx);
|
|
1390
|
+
sy = abs(sy);
|
|
1357
1391
|
imageMatrix = get$1();
|
|
1358
1392
|
copy$1(imageMatrix, transform);
|
|
1359
1393
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -1438,9 +1472,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1438
1472
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1439
1473
|
};
|
|
1440
1474
|
|
|
1441
|
-
const { abs } = Math;
|
|
1442
1475
|
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1443
|
-
const { scaleX, scaleY } =
|
|
1476
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1444
1477
|
const { pixelRatio } = canvas, { data } = paint;
|
|
1445
1478
|
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
|
|
1446
1479
|
return false;
|
|
@@ -1453,8 +1486,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1453
1486
|
else {
|
|
1454
1487
|
if (!(paint.changeful || core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
|
|
1455
1488
|
let { width, height } = data;
|
|
1456
|
-
width *=
|
|
1457
|
-
height *=
|
|
1489
|
+
width *= scaleX * pixelRatio;
|
|
1490
|
+
height *= scaleY * pixelRatio;
|
|
1458
1491
|
if (data.scaleX) {
|
|
1459
1492
|
width *= data.scaleX;
|
|
1460
1493
|
height *= data.scaleY;
|
|
@@ -1464,6 +1497,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1464
1497
|
}
|
|
1465
1498
|
}
|
|
1466
1499
|
if (allowDraw) {
|
|
1500
|
+
if (ui.__.__isFastShadow) {
|
|
1501
|
+
canvas.fillStyle = paint.style || '#000';
|
|
1502
|
+
canvas.fill();
|
|
1503
|
+
}
|
|
1467
1504
|
drawImage(ui, canvas, paint, data);
|
|
1468
1505
|
return true;
|
|
1469
1506
|
}
|
|
@@ -1652,10 +1689,7 @@ function shadow(ui, current, shape) {
|
|
|
1652
1689
|
}
|
|
1653
1690
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1654
1691
|
}
|
|
1655
|
-
|
|
1656
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1657
|
-
else
|
|
1658
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1692
|
+
core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1659
1693
|
if (end && index < end)
|
|
1660
1694
|
other.clearWorld(copyBounds, true);
|
|
1661
1695
|
});
|
|
@@ -1714,10 +1748,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1714
1748
|
copyBounds = bounds;
|
|
1715
1749
|
}
|
|
1716
1750
|
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
1717
|
-
|
|
1718
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1719
|
-
else
|
|
1720
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1751
|
+
core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1721
1752
|
if (end && index < end)
|
|
1722
1753
|
other.clearWorld(copyBounds, true);
|
|
1723
1754
|
});
|
|
@@ -1773,12 +1804,11 @@ draw.Group.prototype.__renderMask = function (canvas, options) {
|
|
|
1773
1804
|
contentCanvas = getCanvas(canvas);
|
|
1774
1805
|
child.__render(maskCanvas, options);
|
|
1775
1806
|
}
|
|
1776
|
-
if (
|
|
1777
|
-
|
|
1778
|
-
}
|
|
1779
|
-
if (excludeRenderBounds(child, options))
|
|
1807
|
+
if (mask === 'clipping' || mask === 'clipping-path')
|
|
1808
|
+
excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
1780
1809
|
continue;
|
|
1781
|
-
|
|
1810
|
+
}
|
|
1811
|
+
excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
|
|
1782
1812
|
}
|
|
1783
1813
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
1784
1814
|
};
|
package/dist/miniapp.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4 } from '@leafer/core';
|
|
1
|
+
import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, getMatrixData, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4 } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
4
|
import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert, Effect } from '@leafer-ui/draw';
|
|
@@ -837,9 +837,14 @@ function fills(fills, ui, canvas) {
|
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
839
|
canvas.fillStyle = item.style;
|
|
840
|
-
if (item.transform) {
|
|
840
|
+
if (item.transform || item.scaleFixed) {
|
|
841
841
|
canvas.save();
|
|
842
|
-
|
|
842
|
+
if (item.transform)
|
|
843
|
+
canvas.transform(item.transform);
|
|
844
|
+
if (item.scaleFixed) {
|
|
845
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true);
|
|
846
|
+
canvas.scale(1 / scaleX, 1 / scaleY);
|
|
847
|
+
}
|
|
843
848
|
if (item.blendMode)
|
|
844
849
|
canvas.blendMode = item.blendMode;
|
|
845
850
|
fillPathOrText(ui, canvas);
|
|
@@ -875,8 +880,13 @@ function strokeText(stroke, ui, canvas) {
|
|
|
875
880
|
}
|
|
876
881
|
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
877
882
|
const data = ui.__;
|
|
878
|
-
|
|
879
|
-
|
|
883
|
+
if (typeof stroke === 'object') {
|
|
884
|
+
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
887
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
888
|
+
drawTextStroke(ui, canvas);
|
|
889
|
+
}
|
|
880
890
|
}
|
|
881
891
|
function drawAlign(stroke, align, ui, canvas) {
|
|
882
892
|
const out = canvas.getSameCanvas(true, true);
|
|
@@ -885,15 +895,9 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
885
895
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
886
896
|
fillText(ui, out);
|
|
887
897
|
out.blendMode = 'normal';
|
|
888
|
-
|
|
898
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
889
899
|
out.recycle(ui.__nowWorld);
|
|
890
900
|
}
|
|
891
|
-
function copyWorld(canvas, out, ui) {
|
|
892
|
-
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
893
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
894
|
-
else
|
|
895
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
896
|
-
}
|
|
897
901
|
function drawTextStroke(ui, canvas) {
|
|
898
902
|
let row, data = ui.__.__textDrawData;
|
|
899
903
|
const { rows, decorationY } = data;
|
|
@@ -909,14 +913,21 @@ function drawTextStroke(ui, canvas) {
|
|
|
909
913
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
910
914
|
}
|
|
911
915
|
}
|
|
912
|
-
function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
916
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
913
917
|
let item;
|
|
918
|
+
const data = ui.__, { __hasMultiStrokeStyle } = data;
|
|
919
|
+
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
914
920
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
915
921
|
item = strokes[i];
|
|
916
922
|
if (item.image && PaintImage.checkImage(ui, canvas, item, false))
|
|
917
923
|
continue;
|
|
918
924
|
if (item.style) {
|
|
919
|
-
|
|
925
|
+
if (__hasMultiStrokeStyle) {
|
|
926
|
+
const { strokeStyle } = item;
|
|
927
|
+
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
928
|
+
}
|
|
929
|
+
else
|
|
930
|
+
canvas.strokeStyle = item.style;
|
|
920
931
|
if (item.blendMode) {
|
|
921
932
|
canvas.saveBlendMode(item.blendMode);
|
|
922
933
|
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
@@ -955,8 +966,13 @@ function strokes(strokes, ui, canvas) {
|
|
|
955
966
|
}
|
|
956
967
|
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
957
968
|
const data = ui.__;
|
|
958
|
-
|
|
959
|
-
|
|
969
|
+
if (typeof stroke === 'object') {
|
|
970
|
+
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
971
|
+
}
|
|
972
|
+
else {
|
|
973
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
974
|
+
canvas.stroke();
|
|
975
|
+
}
|
|
960
976
|
if (data.__useArrow)
|
|
961
977
|
Paint.strokeArrow(stroke, ui, canvas);
|
|
962
978
|
}
|
|
@@ -978,7 +994,7 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
978
994
|
drawCenter(stroke, 2, ui, out);
|
|
979
995
|
out.clipUI(data);
|
|
980
996
|
out.clearWorld(renderBounds);
|
|
981
|
-
|
|
997
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
982
998
|
out.recycle(ui.__nowWorld);
|
|
983
999
|
}
|
|
984
1000
|
}
|
|
@@ -1033,8 +1049,16 @@ function compute(attrName, ui) {
|
|
|
1033
1049
|
if (!(paints instanceof Array))
|
|
1034
1050
|
paints = [paints];
|
|
1035
1051
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
1052
|
+
let maxChildStrokeWidth;
|
|
1036
1053
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1037
|
-
(item = getLeafPaint(attrName, paints[i], ui))
|
|
1054
|
+
if (item = getLeafPaint(attrName, paints[i], ui)) {
|
|
1055
|
+
leafPaints.push(item);
|
|
1056
|
+
if (item.strokeStyle) {
|
|
1057
|
+
maxChildStrokeWidth || (maxChildStrokeWidth = 1);
|
|
1058
|
+
if (item.strokeStyle.strokeWidth)
|
|
1059
|
+
maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1038
1062
|
}
|
|
1039
1063
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1040
1064
|
if (leafPaints.length) {
|
|
@@ -1051,6 +1075,7 @@ function compute(attrName, ui) {
|
|
|
1051
1075
|
else {
|
|
1052
1076
|
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1053
1077
|
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1078
|
+
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
|
|
1054
1079
|
}
|
|
1055
1080
|
}
|
|
1056
1081
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -1082,6 +1107,11 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1082
1107
|
if (data) {
|
|
1083
1108
|
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1084
1109
|
data.isTransparent = true;
|
|
1110
|
+
if (paint.style) {
|
|
1111
|
+
if (paint.style.strokeWidth === 0)
|
|
1112
|
+
return undefined;
|
|
1113
|
+
data.strokeStyle = paint.style;
|
|
1114
|
+
}
|
|
1085
1115
|
if (paint.blendMode)
|
|
1086
1116
|
data.blendMode = paint.blendMode;
|
|
1087
1117
|
}
|
|
@@ -1101,8 +1131,8 @@ const PaintModule = {
|
|
|
1101
1131
|
shape
|
|
1102
1132
|
};
|
|
1103
1133
|
|
|
1104
|
-
let origin = {};
|
|
1105
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
|
|
1134
|
+
let origin = {}, tempMatrix = getMatrixData();
|
|
1135
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
|
|
1106
1136
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1107
1137
|
const transform = get$3();
|
|
1108
1138
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -1111,7 +1141,7 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1111
1141
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1112
1142
|
data.transform = transform;
|
|
1113
1143
|
}
|
|
1114
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
1144
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
|
|
1115
1145
|
const transform = get$3();
|
|
1116
1146
|
if (rotation)
|
|
1117
1147
|
rotate(transform, rotation);
|
|
@@ -1120,6 +1150,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
|
1120
1150
|
if (scaleX)
|
|
1121
1151
|
scaleHelper(transform, scaleX, scaleY);
|
|
1122
1152
|
translate$1(transform, box.x + x, box.y + y);
|
|
1153
|
+
if (clipSize) {
|
|
1154
|
+
tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
|
|
1155
|
+
multiplyParent(transform, tempMatrix);
|
|
1156
|
+
}
|
|
1123
1157
|
data.transform = transform;
|
|
1124
1158
|
}
|
|
1125
1159
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -1156,13 +1190,15 @@ const tempBox = new Bounds();
|
|
|
1156
1190
|
const tempScaleData = {};
|
|
1157
1191
|
const tempImage = {};
|
|
1158
1192
|
function createData(leafPaint, image, paint, box) {
|
|
1159
|
-
const { changeful, sync, editing } = paint;
|
|
1193
|
+
const { changeful, sync, editing, scaleFixed } = paint;
|
|
1160
1194
|
if (changeful)
|
|
1161
1195
|
leafPaint.changeful = changeful;
|
|
1162
1196
|
if (sync)
|
|
1163
1197
|
leafPaint.sync = sync;
|
|
1164
1198
|
if (editing)
|
|
1165
1199
|
leafPaint.editing = editing;
|
|
1200
|
+
if (scaleFixed)
|
|
1201
|
+
leafPaint.scaleFixed = scaleFixed;
|
|
1166
1202
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1167
1203
|
}
|
|
1168
1204
|
function getPatternData(paint, box, image) {
|
|
@@ -1171,7 +1207,7 @@ function getPatternData(paint, box, image) {
|
|
|
1171
1207
|
if (paint.mode === 'strench')
|
|
1172
1208
|
paint.mode = 'stretch';
|
|
1173
1209
|
let { width, height } = image;
|
|
1174
|
-
const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
|
|
1210
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
|
|
1175
1211
|
const sameBox = box.width === width && box.height === height;
|
|
1176
1212
|
const data = { mode };
|
|
1177
1213
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1205,8 +1241,8 @@ function getPatternData(paint, box, image) {
|
|
|
1205
1241
|
break;
|
|
1206
1242
|
case 'normal':
|
|
1207
1243
|
case 'clip':
|
|
1208
|
-
if (tempImage.x || tempImage.y || scaleX || rotation || skew)
|
|
1209
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
|
|
1244
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1245
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
|
|
1210
1246
|
break;
|
|
1211
1247
|
case 'repeat':
|
|
1212
1248
|
if (!sameBox || scaleX || rotation)
|
|
@@ -1343,18 +1379,16 @@ function ignoreRender(ui, value) {
|
|
|
1343
1379
|
}
|
|
1344
1380
|
|
|
1345
1381
|
const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
1346
|
-
const { ceil, abs
|
|
1382
|
+
const { ceil, abs } = Math;
|
|
1347
1383
|
function createPattern(ui, paint, pixelRatio) {
|
|
1348
|
-
let { scaleX, scaleY } =
|
|
1384
|
+
let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1349
1385
|
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1350
1386
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1351
|
-
scaleX = abs$1(scaleX);
|
|
1352
|
-
scaleY = abs$1(scaleY);
|
|
1353
1387
|
const { image, data } = paint;
|
|
1354
1388
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1355
1389
|
if (sx) {
|
|
1356
|
-
sx = abs
|
|
1357
|
-
sy = abs
|
|
1390
|
+
sx = abs(sx);
|
|
1391
|
+
sy = abs(sy);
|
|
1358
1392
|
imageMatrix = get$1();
|
|
1359
1393
|
copy$1(imageMatrix, transform);
|
|
1360
1394
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -1439,9 +1473,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1439
1473
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1440
1474
|
};
|
|
1441
1475
|
|
|
1442
|
-
const { abs } = Math;
|
|
1443
1476
|
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1444
|
-
const { scaleX, scaleY } =
|
|
1477
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1445
1478
|
const { pixelRatio } = canvas, { data } = paint;
|
|
1446
1479
|
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1447
1480
|
return false;
|
|
@@ -1454,8 +1487,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1454
1487
|
else {
|
|
1455
1488
|
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1456
1489
|
let { width, height } = data;
|
|
1457
|
-
width *=
|
|
1458
|
-
height *=
|
|
1490
|
+
width *= scaleX * pixelRatio;
|
|
1491
|
+
height *= scaleY * pixelRatio;
|
|
1459
1492
|
if (data.scaleX) {
|
|
1460
1493
|
width *= data.scaleX;
|
|
1461
1494
|
height *= data.scaleY;
|
|
@@ -1465,6 +1498,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1465
1498
|
}
|
|
1466
1499
|
}
|
|
1467
1500
|
if (allowDraw) {
|
|
1501
|
+
if (ui.__.__isFastShadow) {
|
|
1502
|
+
canvas.fillStyle = paint.style || '#000';
|
|
1503
|
+
canvas.fill();
|
|
1504
|
+
}
|
|
1468
1505
|
drawImage(ui, canvas, paint, data);
|
|
1469
1506
|
return true;
|
|
1470
1507
|
}
|
|
@@ -1653,10 +1690,7 @@ function shadow(ui, current, shape) {
|
|
|
1653
1690
|
}
|
|
1654
1691
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1655
1692
|
}
|
|
1656
|
-
|
|
1657
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1658
|
-
else
|
|
1659
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1693
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1660
1694
|
if (end && index < end)
|
|
1661
1695
|
other.clearWorld(copyBounds, true);
|
|
1662
1696
|
});
|
|
@@ -1715,10 +1749,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1715
1749
|
copyBounds = bounds;
|
|
1716
1750
|
}
|
|
1717
1751
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
|
|
1718
|
-
|
|
1719
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1720
|
-
else
|
|
1721
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1752
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1722
1753
|
if (end && index < end)
|
|
1723
1754
|
other.clearWorld(copyBounds, true);
|
|
1724
1755
|
});
|
|
@@ -1774,12 +1805,11 @@ Group.prototype.__renderMask = function (canvas, options) {
|
|
|
1774
1805
|
contentCanvas = getCanvas(canvas);
|
|
1775
1806
|
child.__render(maskCanvas, options);
|
|
1776
1807
|
}
|
|
1777
|
-
if (
|
|
1778
|
-
|
|
1779
|
-
}
|
|
1780
|
-
if (excludeRenderBounds(child, options))
|
|
1808
|
+
if (mask === 'clipping' || mask === 'clipping-path')
|
|
1809
|
+
excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
1781
1810
|
continue;
|
|
1782
|
-
|
|
1811
|
+
}
|
|
1812
|
+
excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
|
|
1783
1813
|
}
|
|
1784
1814
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
1785
1815
|
};
|