@leafer-ui/worker 1.6.7 → 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/worker.cjs +86 -50
- package/dist/worker.esm.js +87 -51
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +315 -192
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +313 -192
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +11 -11
package/dist/worker.cjs
CHANGED
|
@@ -855,9 +855,14 @@ function fills(fills, ui, canvas) {
|
|
|
855
855
|
}
|
|
856
856
|
}
|
|
857
857
|
canvas.fillStyle = item.style;
|
|
858
|
-
if (item.transform) {
|
|
858
|
+
if (item.transform || item.scaleFixed) {
|
|
859
859
|
canvas.save();
|
|
860
|
-
|
|
860
|
+
if (item.transform)
|
|
861
|
+
canvas.transform(item.transform);
|
|
862
|
+
if (item.scaleFixed) {
|
|
863
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true);
|
|
864
|
+
canvas.scale(1 / scaleX, 1 / scaleY);
|
|
865
|
+
}
|
|
861
866
|
if (item.blendMode)
|
|
862
867
|
canvas.blendMode = item.blendMode;
|
|
863
868
|
fillPathOrText(ui, canvas);
|
|
@@ -893,8 +898,13 @@ function strokeText(stroke, ui, canvas) {
|
|
|
893
898
|
}
|
|
894
899
|
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
895
900
|
const data = ui.__;
|
|
896
|
-
|
|
897
|
-
|
|
901
|
+
if (typeof stroke === 'object') {
|
|
902
|
+
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
906
|
+
drawTextStroke(ui, canvas);
|
|
907
|
+
}
|
|
898
908
|
}
|
|
899
909
|
function drawAlign(stroke, align, ui, canvas) {
|
|
900
910
|
const out = canvas.getSameCanvas(true, true);
|
|
@@ -903,15 +913,9 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
903
913
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
904
914
|
fillText(ui, out);
|
|
905
915
|
out.blendMode = 'normal';
|
|
906
|
-
|
|
916
|
+
core.LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
907
917
|
out.recycle(ui.__nowWorld);
|
|
908
918
|
}
|
|
909
|
-
function copyWorld(canvas, out, ui) {
|
|
910
|
-
if (ui.__worldFlipped || core.Platform.fullImageShadow)
|
|
911
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
912
|
-
else
|
|
913
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
914
|
-
}
|
|
915
919
|
function drawTextStroke(ui, canvas) {
|
|
916
920
|
let row, data = ui.__.__textDrawData;
|
|
917
921
|
const { rows, decorationY } = data;
|
|
@@ -927,14 +931,21 @@ function drawTextStroke(ui, canvas) {
|
|
|
927
931
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
928
932
|
}
|
|
929
933
|
}
|
|
930
|
-
function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
934
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
931
935
|
let item;
|
|
936
|
+
const data = ui.__, { __hasMultiStrokeStyle } = data;
|
|
937
|
+
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
932
938
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
933
939
|
item = strokes[i];
|
|
934
940
|
if (item.image && draw.PaintImage.checkImage(ui, canvas, item, false))
|
|
935
941
|
continue;
|
|
936
942
|
if (item.style) {
|
|
937
|
-
|
|
943
|
+
if (__hasMultiStrokeStyle) {
|
|
944
|
+
const { strokeStyle } = item;
|
|
945
|
+
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
946
|
+
}
|
|
947
|
+
else
|
|
948
|
+
canvas.strokeStyle = item.style;
|
|
938
949
|
if (item.blendMode) {
|
|
939
950
|
canvas.saveBlendMode(item.blendMode);
|
|
940
951
|
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
@@ -973,8 +984,13 @@ function strokes(strokes, ui, canvas) {
|
|
|
973
984
|
}
|
|
974
985
|
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
975
986
|
const data = ui.__;
|
|
976
|
-
|
|
977
|
-
|
|
987
|
+
if (typeof stroke === 'object') {
|
|
988
|
+
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
989
|
+
}
|
|
990
|
+
else {
|
|
991
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
992
|
+
canvas.stroke();
|
|
993
|
+
}
|
|
978
994
|
if (data.__useArrow)
|
|
979
995
|
draw.Paint.strokeArrow(stroke, ui, canvas);
|
|
980
996
|
}
|
|
@@ -996,7 +1012,7 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
996
1012
|
drawCenter(stroke, 2, ui, out);
|
|
997
1013
|
out.clipUI(data);
|
|
998
1014
|
out.clearWorld(renderBounds);
|
|
999
|
-
|
|
1015
|
+
core.LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
1000
1016
|
out.recycle(ui.__nowWorld);
|
|
1001
1017
|
}
|
|
1002
1018
|
}
|
|
@@ -1051,8 +1067,16 @@ function compute(attrName, ui) {
|
|
|
1051
1067
|
if (!(paints instanceof Array))
|
|
1052
1068
|
paints = [paints];
|
|
1053
1069
|
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
1070
|
+
let maxChildStrokeWidth;
|
|
1054
1071
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1055
|
-
(item = getLeafPaint(attrName, paints[i], ui))
|
|
1072
|
+
if (item = getLeafPaint(attrName, paints[i], ui)) {
|
|
1073
|
+
leafPaints.push(item);
|
|
1074
|
+
if (item.strokeStyle) {
|
|
1075
|
+
maxChildStrokeWidth || (maxChildStrokeWidth = 1);
|
|
1076
|
+
if (item.strokeStyle.strokeWidth)
|
|
1077
|
+
maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1056
1080
|
}
|
|
1057
1081
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1058
1082
|
if (leafPaints.length) {
|
|
@@ -1069,6 +1093,7 @@ function compute(attrName, ui) {
|
|
|
1069
1093
|
else {
|
|
1070
1094
|
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1071
1095
|
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1096
|
+
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
|
|
1072
1097
|
}
|
|
1073
1098
|
}
|
|
1074
1099
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -1100,6 +1125,11 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1100
1125
|
if (data) {
|
|
1101
1126
|
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1102
1127
|
data.isTransparent = true;
|
|
1128
|
+
if (paint.style) {
|
|
1129
|
+
if (paint.style.strokeWidth === 0)
|
|
1130
|
+
return undefined;
|
|
1131
|
+
data.strokeStyle = paint.style;
|
|
1132
|
+
}
|
|
1103
1133
|
if (paint.blendMode)
|
|
1104
1134
|
data.blendMode = paint.blendMode;
|
|
1105
1135
|
}
|
|
@@ -1119,8 +1149,8 @@ const PaintModule = {
|
|
|
1119
1149
|
shape
|
|
1120
1150
|
};
|
|
1121
1151
|
|
|
1122
|
-
let origin = {};
|
|
1123
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = core.MatrixHelper;
|
|
1152
|
+
let origin = {}, tempMatrix = core.getMatrixData();
|
|
1153
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = core.MatrixHelper;
|
|
1124
1154
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1125
1155
|
const transform = get$3();
|
|
1126
1156
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -1129,13 +1159,19 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1129
1159
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1130
1160
|
data.transform = transform;
|
|
1131
1161
|
}
|
|
1132
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1162
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
|
|
1133
1163
|
const transform = get$3();
|
|
1134
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
1135
|
-
if (scaleX)
|
|
1136
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
1137
1164
|
if (rotation)
|
|
1138
1165
|
rotate(transform, rotation);
|
|
1166
|
+
if (skew)
|
|
1167
|
+
skewHelper(transform, skew.x, skew.y);
|
|
1168
|
+
if (scaleX)
|
|
1169
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
1170
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
1171
|
+
if (clipSize) {
|
|
1172
|
+
tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
|
|
1173
|
+
multiplyParent(transform, tempMatrix);
|
|
1174
|
+
}
|
|
1139
1175
|
data.transform = transform;
|
|
1140
1176
|
}
|
|
1141
1177
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -1172,11 +1208,15 @@ const tempBox = new core.Bounds();
|
|
|
1172
1208
|
const tempScaleData = {};
|
|
1173
1209
|
const tempImage = {};
|
|
1174
1210
|
function createData(leafPaint, image, paint, box) {
|
|
1175
|
-
const { changeful, sync } = paint;
|
|
1211
|
+
const { changeful, sync, editing, scaleFixed } = paint;
|
|
1176
1212
|
if (changeful)
|
|
1177
1213
|
leafPaint.changeful = changeful;
|
|
1178
1214
|
if (sync)
|
|
1179
1215
|
leafPaint.sync = sync;
|
|
1216
|
+
if (editing)
|
|
1217
|
+
leafPaint.editing = editing;
|
|
1218
|
+
if (scaleFixed)
|
|
1219
|
+
leafPaint.scaleFixed = scaleFixed;
|
|
1180
1220
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1181
1221
|
}
|
|
1182
1222
|
function getPatternData(paint, box, image) {
|
|
@@ -1185,7 +1225,7 @@ function getPatternData(paint, box, image) {
|
|
|
1185
1225
|
if (paint.mode === 'strench')
|
|
1186
1226
|
paint.mode = 'stretch';
|
|
1187
1227
|
let { width, height } = image;
|
|
1188
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1228
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
|
|
1189
1229
|
const sameBox = box.width === width && box.height === height;
|
|
1190
1230
|
const data = { mode };
|
|
1191
1231
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1219,8 +1259,8 @@ function getPatternData(paint, box, image) {
|
|
|
1219
1259
|
break;
|
|
1220
1260
|
case 'normal':
|
|
1221
1261
|
case 'clip':
|
|
1222
|
-
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
1223
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1262
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1263
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
|
|
1224
1264
|
break;
|
|
1225
1265
|
case 'repeat':
|
|
1226
1266
|
if (!sameBox || scaleX || rotation)
|
|
@@ -1297,11 +1337,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1297
1337
|
}
|
|
1298
1338
|
onLoadSuccess(ui, event);
|
|
1299
1339
|
}
|
|
1300
|
-
leafPaint.loadId =
|
|
1340
|
+
leafPaint.loadId = undefined;
|
|
1301
1341
|
}, (error) => {
|
|
1302
1342
|
ignoreRender(ui, false);
|
|
1303
1343
|
onLoadError(ui, event, error);
|
|
1304
|
-
leafPaint.loadId =
|
|
1344
|
+
leafPaint.loadId = undefined;
|
|
1305
1345
|
});
|
|
1306
1346
|
if (ui.placeholderColor) {
|
|
1307
1347
|
if (!ui.placeholderDelay)
|
|
@@ -1357,16 +1397,16 @@ function ignoreRender(ui, value) {
|
|
|
1357
1397
|
}
|
|
1358
1398
|
|
|
1359
1399
|
const { get: get$1, scale, copy: copy$1 } = core.MatrixHelper;
|
|
1360
|
-
const { ceil, abs
|
|
1400
|
+
const { ceil, abs } = Math;
|
|
1361
1401
|
function createPattern(ui, paint, pixelRatio) {
|
|
1362
|
-
let { scaleX, scaleY } =
|
|
1402
|
+
let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1363
1403
|
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1364
1404
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1365
|
-
scaleX = abs$1(scaleX);
|
|
1366
|
-
scaleY = abs$1(scaleY);
|
|
1367
1405
|
const { image, data } = paint;
|
|
1368
1406
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1369
1407
|
if (sx) {
|
|
1408
|
+
sx = abs(sx);
|
|
1409
|
+
sy = abs(sy);
|
|
1370
1410
|
imageMatrix = get$1();
|
|
1371
1411
|
copy$1(imageMatrix, transform);
|
|
1372
1412
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -1451,9 +1491,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1451
1491
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1452
1492
|
};
|
|
1453
1493
|
|
|
1454
|
-
const { abs } = Math;
|
|
1455
1494
|
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1456
|
-
const { scaleX, scaleY } =
|
|
1495
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1457
1496
|
const { pixelRatio } = canvas, { data } = paint;
|
|
1458
1497
|
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
|
|
1459
1498
|
return false;
|
|
@@ -1466,8 +1505,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1466
1505
|
else {
|
|
1467
1506
|
if (!(paint.changeful || core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
|
|
1468
1507
|
let { width, height } = data;
|
|
1469
|
-
width *=
|
|
1470
|
-
height *=
|
|
1508
|
+
width *= scaleX * pixelRatio;
|
|
1509
|
+
height *= scaleY * pixelRatio;
|
|
1471
1510
|
if (data.scaleX) {
|
|
1472
1511
|
width *= data.scaleX;
|
|
1473
1512
|
height *= data.scaleY;
|
|
@@ -1477,6 +1516,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1477
1516
|
}
|
|
1478
1517
|
}
|
|
1479
1518
|
if (allowDraw) {
|
|
1519
|
+
if (ui.__.__isFastShadow) {
|
|
1520
|
+
canvas.fillStyle = paint.style || '#000';
|
|
1521
|
+
canvas.fill();
|
|
1522
|
+
}
|
|
1480
1523
|
drawImage(ui, canvas, paint, data);
|
|
1481
1524
|
return true;
|
|
1482
1525
|
}
|
|
@@ -1665,10 +1708,7 @@ function shadow(ui, current, shape) {
|
|
|
1665
1708
|
}
|
|
1666
1709
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1667
1710
|
}
|
|
1668
|
-
|
|
1669
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1670
|
-
else
|
|
1671
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1711
|
+
core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1672
1712
|
if (end && index < end)
|
|
1673
1713
|
other.clearWorld(copyBounds, true);
|
|
1674
1714
|
});
|
|
@@ -1727,10 +1767,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1727
1767
|
copyBounds = bounds;
|
|
1728
1768
|
}
|
|
1729
1769
|
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
1730
|
-
|
|
1731
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1732
|
-
else
|
|
1733
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1770
|
+
core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1734
1771
|
if (end && index < end)
|
|
1735
1772
|
other.clearWorld(copyBounds, true);
|
|
1736
1773
|
});
|
|
@@ -1786,12 +1823,11 @@ draw.Group.prototype.__renderMask = function (canvas, options) {
|
|
|
1786
1823
|
contentCanvas = getCanvas(canvas);
|
|
1787
1824
|
child.__render(maskCanvas, options);
|
|
1788
1825
|
}
|
|
1789
|
-
if (
|
|
1790
|
-
|
|
1791
|
-
}
|
|
1792
|
-
if (excludeRenderBounds(child, options))
|
|
1826
|
+
if (mask === 'clipping' || mask === 'clipping-path')
|
|
1827
|
+
excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
1793
1828
|
continue;
|
|
1794
|
-
|
|
1829
|
+
}
|
|
1830
|
+
excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
|
|
1795
1831
|
}
|
|
1796
1832
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
1797
1833
|
};
|
package/dist/worker.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper, Plugin, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4 } from '@leafer/core';
|
|
1
|
+
import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper, Plugin, 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 { HitCanvasManager, InteractionBase } from '@leafer-ui/core';
|
|
@@ -856,9 +856,14 @@ function fills(fills, ui, canvas) {
|
|
|
856
856
|
}
|
|
857
857
|
}
|
|
858
858
|
canvas.fillStyle = item.style;
|
|
859
|
-
if (item.transform) {
|
|
859
|
+
if (item.transform || item.scaleFixed) {
|
|
860
860
|
canvas.save();
|
|
861
|
-
|
|
861
|
+
if (item.transform)
|
|
862
|
+
canvas.transform(item.transform);
|
|
863
|
+
if (item.scaleFixed) {
|
|
864
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true);
|
|
865
|
+
canvas.scale(1 / scaleX, 1 / scaleY);
|
|
866
|
+
}
|
|
862
867
|
if (item.blendMode)
|
|
863
868
|
canvas.blendMode = item.blendMode;
|
|
864
869
|
fillPathOrText(ui, canvas);
|
|
@@ -894,8 +899,13 @@ function strokeText(stroke, ui, canvas) {
|
|
|
894
899
|
}
|
|
895
900
|
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
896
901
|
const data = ui.__;
|
|
897
|
-
|
|
898
|
-
|
|
902
|
+
if (typeof stroke === 'object') {
|
|
903
|
+
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
904
|
+
}
|
|
905
|
+
else {
|
|
906
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
907
|
+
drawTextStroke(ui, canvas);
|
|
908
|
+
}
|
|
899
909
|
}
|
|
900
910
|
function drawAlign(stroke, align, ui, canvas) {
|
|
901
911
|
const out = canvas.getSameCanvas(true, true);
|
|
@@ -904,15 +914,9 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
904
914
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
905
915
|
fillText(ui, out);
|
|
906
916
|
out.blendMode = 'normal';
|
|
907
|
-
|
|
917
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
908
918
|
out.recycle(ui.__nowWorld);
|
|
909
919
|
}
|
|
910
|
-
function copyWorld(canvas, out, ui) {
|
|
911
|
-
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
912
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
913
|
-
else
|
|
914
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
915
|
-
}
|
|
916
920
|
function drawTextStroke(ui, canvas) {
|
|
917
921
|
let row, data = ui.__.__textDrawData;
|
|
918
922
|
const { rows, decorationY } = data;
|
|
@@ -928,14 +932,21 @@ function drawTextStroke(ui, canvas) {
|
|
|
928
932
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
929
933
|
}
|
|
930
934
|
}
|
|
931
|
-
function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
935
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
932
936
|
let item;
|
|
937
|
+
const data = ui.__, { __hasMultiStrokeStyle } = data;
|
|
938
|
+
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
933
939
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
934
940
|
item = strokes[i];
|
|
935
941
|
if (item.image && PaintImage.checkImage(ui, canvas, item, false))
|
|
936
942
|
continue;
|
|
937
943
|
if (item.style) {
|
|
938
|
-
|
|
944
|
+
if (__hasMultiStrokeStyle) {
|
|
945
|
+
const { strokeStyle } = item;
|
|
946
|
+
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
947
|
+
}
|
|
948
|
+
else
|
|
949
|
+
canvas.strokeStyle = item.style;
|
|
939
950
|
if (item.blendMode) {
|
|
940
951
|
canvas.saveBlendMode(item.blendMode);
|
|
941
952
|
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
@@ -974,8 +985,13 @@ function strokes(strokes, ui, canvas) {
|
|
|
974
985
|
}
|
|
975
986
|
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
976
987
|
const data = ui.__;
|
|
977
|
-
|
|
978
|
-
|
|
988
|
+
if (typeof stroke === 'object') {
|
|
989
|
+
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
990
|
+
}
|
|
991
|
+
else {
|
|
992
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
993
|
+
canvas.stroke();
|
|
994
|
+
}
|
|
979
995
|
if (data.__useArrow)
|
|
980
996
|
Paint.strokeArrow(stroke, ui, canvas);
|
|
981
997
|
}
|
|
@@ -997,7 +1013,7 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
997
1013
|
drawCenter(stroke, 2, ui, out);
|
|
998
1014
|
out.clipUI(data);
|
|
999
1015
|
out.clearWorld(renderBounds);
|
|
1000
|
-
|
|
1016
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
1001
1017
|
out.recycle(ui.__nowWorld);
|
|
1002
1018
|
}
|
|
1003
1019
|
}
|
|
@@ -1052,8 +1068,16 @@ function compute(attrName, ui) {
|
|
|
1052
1068
|
if (!(paints instanceof Array))
|
|
1053
1069
|
paints = [paints];
|
|
1054
1070
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
1071
|
+
let maxChildStrokeWidth;
|
|
1055
1072
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1056
|
-
(item = getLeafPaint(attrName, paints[i], ui))
|
|
1073
|
+
if (item = getLeafPaint(attrName, paints[i], ui)) {
|
|
1074
|
+
leafPaints.push(item);
|
|
1075
|
+
if (item.strokeStyle) {
|
|
1076
|
+
maxChildStrokeWidth || (maxChildStrokeWidth = 1);
|
|
1077
|
+
if (item.strokeStyle.strokeWidth)
|
|
1078
|
+
maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1057
1081
|
}
|
|
1058
1082
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1059
1083
|
if (leafPaints.length) {
|
|
@@ -1070,6 +1094,7 @@ function compute(attrName, ui) {
|
|
|
1070
1094
|
else {
|
|
1071
1095
|
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1072
1096
|
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1097
|
+
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
|
|
1073
1098
|
}
|
|
1074
1099
|
}
|
|
1075
1100
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -1101,6 +1126,11 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1101
1126
|
if (data) {
|
|
1102
1127
|
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1103
1128
|
data.isTransparent = true;
|
|
1129
|
+
if (paint.style) {
|
|
1130
|
+
if (paint.style.strokeWidth === 0)
|
|
1131
|
+
return undefined;
|
|
1132
|
+
data.strokeStyle = paint.style;
|
|
1133
|
+
}
|
|
1104
1134
|
if (paint.blendMode)
|
|
1105
1135
|
data.blendMode = paint.blendMode;
|
|
1106
1136
|
}
|
|
@@ -1120,8 +1150,8 @@ const PaintModule = {
|
|
|
1120
1150
|
shape
|
|
1121
1151
|
};
|
|
1122
1152
|
|
|
1123
|
-
let origin = {};
|
|
1124
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
|
|
1153
|
+
let origin = {}, tempMatrix = getMatrixData();
|
|
1154
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
|
|
1125
1155
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1126
1156
|
const transform = get$3();
|
|
1127
1157
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -1130,13 +1160,19 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1130
1160
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1131
1161
|
data.transform = transform;
|
|
1132
1162
|
}
|
|
1133
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1163
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
|
|
1134
1164
|
const transform = get$3();
|
|
1135
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
1136
|
-
if (scaleX)
|
|
1137
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
1138
1165
|
if (rotation)
|
|
1139
1166
|
rotate(transform, rotation);
|
|
1167
|
+
if (skew)
|
|
1168
|
+
skewHelper(transform, skew.x, skew.y);
|
|
1169
|
+
if (scaleX)
|
|
1170
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
1171
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
1172
|
+
if (clipSize) {
|
|
1173
|
+
tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
|
|
1174
|
+
multiplyParent(transform, tempMatrix);
|
|
1175
|
+
}
|
|
1140
1176
|
data.transform = transform;
|
|
1141
1177
|
}
|
|
1142
1178
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -1173,11 +1209,15 @@ const tempBox = new Bounds();
|
|
|
1173
1209
|
const tempScaleData = {};
|
|
1174
1210
|
const tempImage = {};
|
|
1175
1211
|
function createData(leafPaint, image, paint, box) {
|
|
1176
|
-
const { changeful, sync } = paint;
|
|
1212
|
+
const { changeful, sync, editing, scaleFixed } = paint;
|
|
1177
1213
|
if (changeful)
|
|
1178
1214
|
leafPaint.changeful = changeful;
|
|
1179
1215
|
if (sync)
|
|
1180
1216
|
leafPaint.sync = sync;
|
|
1217
|
+
if (editing)
|
|
1218
|
+
leafPaint.editing = editing;
|
|
1219
|
+
if (scaleFixed)
|
|
1220
|
+
leafPaint.scaleFixed = scaleFixed;
|
|
1181
1221
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1182
1222
|
}
|
|
1183
1223
|
function getPatternData(paint, box, image) {
|
|
@@ -1186,7 +1226,7 @@ function getPatternData(paint, box, image) {
|
|
|
1186
1226
|
if (paint.mode === 'strench')
|
|
1187
1227
|
paint.mode = 'stretch';
|
|
1188
1228
|
let { width, height } = image;
|
|
1189
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1229
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
|
|
1190
1230
|
const sameBox = box.width === width && box.height === height;
|
|
1191
1231
|
const data = { mode };
|
|
1192
1232
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1220,8 +1260,8 @@ function getPatternData(paint, box, image) {
|
|
|
1220
1260
|
break;
|
|
1221
1261
|
case 'normal':
|
|
1222
1262
|
case 'clip':
|
|
1223
|
-
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
1224
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1263
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1264
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
|
|
1225
1265
|
break;
|
|
1226
1266
|
case 'repeat':
|
|
1227
1267
|
if (!sameBox || scaleX || rotation)
|
|
@@ -1298,11 +1338,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1298
1338
|
}
|
|
1299
1339
|
onLoadSuccess(ui, event);
|
|
1300
1340
|
}
|
|
1301
|
-
leafPaint.loadId =
|
|
1341
|
+
leafPaint.loadId = undefined;
|
|
1302
1342
|
}, (error) => {
|
|
1303
1343
|
ignoreRender(ui, false);
|
|
1304
1344
|
onLoadError(ui, event, error);
|
|
1305
|
-
leafPaint.loadId =
|
|
1345
|
+
leafPaint.loadId = undefined;
|
|
1306
1346
|
});
|
|
1307
1347
|
if (ui.placeholderColor) {
|
|
1308
1348
|
if (!ui.placeholderDelay)
|
|
@@ -1358,16 +1398,16 @@ function ignoreRender(ui, value) {
|
|
|
1358
1398
|
}
|
|
1359
1399
|
|
|
1360
1400
|
const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
1361
|
-
const { ceil, abs
|
|
1401
|
+
const { ceil, abs } = Math;
|
|
1362
1402
|
function createPattern(ui, paint, pixelRatio) {
|
|
1363
|
-
let { scaleX, scaleY } =
|
|
1403
|
+
let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1364
1404
|
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1365
1405
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1366
|
-
scaleX = abs$1(scaleX);
|
|
1367
|
-
scaleY = abs$1(scaleY);
|
|
1368
1406
|
const { image, data } = paint;
|
|
1369
1407
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1370
1408
|
if (sx) {
|
|
1409
|
+
sx = abs(sx);
|
|
1410
|
+
sy = abs(sy);
|
|
1371
1411
|
imageMatrix = get$1();
|
|
1372
1412
|
copy$1(imageMatrix, transform);
|
|
1373
1413
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -1452,9 +1492,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1452
1492
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1453
1493
|
};
|
|
1454
1494
|
|
|
1455
|
-
const { abs } = Math;
|
|
1456
1495
|
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1457
|
-
const { scaleX, scaleY } =
|
|
1496
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1458
1497
|
const { pixelRatio } = canvas, { data } = paint;
|
|
1459
1498
|
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1460
1499
|
return false;
|
|
@@ -1467,8 +1506,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1467
1506
|
else {
|
|
1468
1507
|
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1469
1508
|
let { width, height } = data;
|
|
1470
|
-
width *=
|
|
1471
|
-
height *=
|
|
1509
|
+
width *= scaleX * pixelRatio;
|
|
1510
|
+
height *= scaleY * pixelRatio;
|
|
1472
1511
|
if (data.scaleX) {
|
|
1473
1512
|
width *= data.scaleX;
|
|
1474
1513
|
height *= data.scaleY;
|
|
@@ -1478,6 +1517,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1478
1517
|
}
|
|
1479
1518
|
}
|
|
1480
1519
|
if (allowDraw) {
|
|
1520
|
+
if (ui.__.__isFastShadow) {
|
|
1521
|
+
canvas.fillStyle = paint.style || '#000';
|
|
1522
|
+
canvas.fill();
|
|
1523
|
+
}
|
|
1481
1524
|
drawImage(ui, canvas, paint, data);
|
|
1482
1525
|
return true;
|
|
1483
1526
|
}
|
|
@@ -1666,10 +1709,7 @@ function shadow(ui, current, shape) {
|
|
|
1666
1709
|
}
|
|
1667
1710
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1668
1711
|
}
|
|
1669
|
-
|
|
1670
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1671
|
-
else
|
|
1672
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1712
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1673
1713
|
if (end && index < end)
|
|
1674
1714
|
other.clearWorld(copyBounds, true);
|
|
1675
1715
|
});
|
|
@@ -1728,10 +1768,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1728
1768
|
copyBounds = bounds;
|
|
1729
1769
|
}
|
|
1730
1770
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
|
|
1731
|
-
|
|
1732
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1733
|
-
else
|
|
1734
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1771
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1735
1772
|
if (end && index < end)
|
|
1736
1773
|
other.clearWorld(copyBounds, true);
|
|
1737
1774
|
});
|
|
@@ -1787,12 +1824,11 @@ Group.prototype.__renderMask = function (canvas, options) {
|
|
|
1787
1824
|
contentCanvas = getCanvas(canvas);
|
|
1788
1825
|
child.__render(maskCanvas, options);
|
|
1789
1826
|
}
|
|
1790
|
-
if (
|
|
1791
|
-
|
|
1792
|
-
}
|
|
1793
|
-
if (excludeRenderBounds(child, options))
|
|
1827
|
+
if (mask === 'clipping' || mask === 'clipping-path')
|
|
1828
|
+
excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
1794
1829
|
continue;
|
|
1795
|
-
|
|
1830
|
+
}
|
|
1831
|
+
excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
|
|
1796
1832
|
}
|
|
1797
1833
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
1798
1834
|
};
|