leafer-draw 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/web.cjs +86 -50
- package/dist/web.esm.js +87 -51
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +301 -181
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +299 -181
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +3 -3
package/dist/web.cjs
CHANGED
|
@@ -878,9 +878,14 @@ function fills(fills, ui, canvas) {
|
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
880
|
canvas.fillStyle = item.style;
|
|
881
|
-
if (item.transform) {
|
|
881
|
+
if (item.transform || item.scaleFixed) {
|
|
882
882
|
canvas.save();
|
|
883
|
-
|
|
883
|
+
if (item.transform)
|
|
884
|
+
canvas.transform(item.transform);
|
|
885
|
+
if (item.scaleFixed) {
|
|
886
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true);
|
|
887
|
+
canvas.scale(1 / scaleX, 1 / scaleY);
|
|
888
|
+
}
|
|
884
889
|
if (item.blendMode)
|
|
885
890
|
canvas.blendMode = item.blendMode;
|
|
886
891
|
fillPathOrText(ui, canvas);
|
|
@@ -916,8 +921,13 @@ function strokeText(stroke, ui, canvas) {
|
|
|
916
921
|
}
|
|
917
922
|
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
918
923
|
const data = ui.__;
|
|
919
|
-
|
|
920
|
-
|
|
924
|
+
if (typeof stroke === 'object') {
|
|
925
|
+
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
929
|
+
drawTextStroke(ui, canvas);
|
|
930
|
+
}
|
|
921
931
|
}
|
|
922
932
|
function drawAlign(stroke, align, ui, canvas) {
|
|
923
933
|
const out = canvas.getSameCanvas(true, true);
|
|
@@ -926,15 +936,9 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
926
936
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
927
937
|
fillText(ui, out);
|
|
928
938
|
out.blendMode = 'normal';
|
|
929
|
-
|
|
939
|
+
core.LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
930
940
|
out.recycle(ui.__nowWorld);
|
|
931
941
|
}
|
|
932
|
-
function copyWorld(canvas, out, ui) {
|
|
933
|
-
if (ui.__worldFlipped || core.Platform.fullImageShadow)
|
|
934
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
935
|
-
else
|
|
936
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
937
|
-
}
|
|
938
942
|
function drawTextStroke(ui, canvas) {
|
|
939
943
|
let row, data = ui.__.__textDrawData;
|
|
940
944
|
const { rows, decorationY } = data;
|
|
@@ -950,14 +954,21 @@ function drawTextStroke(ui, canvas) {
|
|
|
950
954
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
951
955
|
}
|
|
952
956
|
}
|
|
953
|
-
function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
957
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
954
958
|
let item;
|
|
959
|
+
const data = ui.__, { __hasMultiStrokeStyle } = data;
|
|
960
|
+
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
955
961
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
956
962
|
item = strokes[i];
|
|
957
963
|
if (item.image && draw.PaintImage.checkImage(ui, canvas, item, false))
|
|
958
964
|
continue;
|
|
959
965
|
if (item.style) {
|
|
960
|
-
|
|
966
|
+
if (__hasMultiStrokeStyle) {
|
|
967
|
+
const { strokeStyle } = item;
|
|
968
|
+
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
969
|
+
}
|
|
970
|
+
else
|
|
971
|
+
canvas.strokeStyle = item.style;
|
|
961
972
|
if (item.blendMode) {
|
|
962
973
|
canvas.saveBlendMode(item.blendMode);
|
|
963
974
|
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
@@ -996,8 +1007,13 @@ function strokes(strokes, ui, canvas) {
|
|
|
996
1007
|
}
|
|
997
1008
|
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
998
1009
|
const data = ui.__;
|
|
999
|
-
|
|
1000
|
-
|
|
1010
|
+
if (typeof stroke === 'object') {
|
|
1011
|
+
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
1012
|
+
}
|
|
1013
|
+
else {
|
|
1014
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
1015
|
+
canvas.stroke();
|
|
1016
|
+
}
|
|
1001
1017
|
if (data.__useArrow)
|
|
1002
1018
|
draw.Paint.strokeArrow(stroke, ui, canvas);
|
|
1003
1019
|
}
|
|
@@ -1019,7 +1035,7 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
1019
1035
|
drawCenter(stroke, 2, ui, out);
|
|
1020
1036
|
out.clipUI(data);
|
|
1021
1037
|
out.clearWorld(renderBounds);
|
|
1022
|
-
|
|
1038
|
+
core.LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
1023
1039
|
out.recycle(ui.__nowWorld);
|
|
1024
1040
|
}
|
|
1025
1041
|
}
|
|
@@ -1074,8 +1090,16 @@ function compute(attrName, ui) {
|
|
|
1074
1090
|
if (!(paints instanceof Array))
|
|
1075
1091
|
paints = [paints];
|
|
1076
1092
|
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
1093
|
+
let maxChildStrokeWidth;
|
|
1077
1094
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1078
|
-
(item = getLeafPaint(attrName, paints[i], ui))
|
|
1095
|
+
if (item = getLeafPaint(attrName, paints[i], ui)) {
|
|
1096
|
+
leafPaints.push(item);
|
|
1097
|
+
if (item.strokeStyle) {
|
|
1098
|
+
maxChildStrokeWidth || (maxChildStrokeWidth = 1);
|
|
1099
|
+
if (item.strokeStyle.strokeWidth)
|
|
1100
|
+
maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1079
1103
|
}
|
|
1080
1104
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1081
1105
|
if (leafPaints.length) {
|
|
@@ -1092,6 +1116,7 @@ function compute(attrName, ui) {
|
|
|
1092
1116
|
else {
|
|
1093
1117
|
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1094
1118
|
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1119
|
+
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
|
|
1095
1120
|
}
|
|
1096
1121
|
}
|
|
1097
1122
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -1123,6 +1148,11 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1123
1148
|
if (data) {
|
|
1124
1149
|
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1125
1150
|
data.isTransparent = true;
|
|
1151
|
+
if (paint.style) {
|
|
1152
|
+
if (paint.style.strokeWidth === 0)
|
|
1153
|
+
return undefined;
|
|
1154
|
+
data.strokeStyle = paint.style;
|
|
1155
|
+
}
|
|
1126
1156
|
if (paint.blendMode)
|
|
1127
1157
|
data.blendMode = paint.blendMode;
|
|
1128
1158
|
}
|
|
@@ -1142,8 +1172,8 @@ const PaintModule = {
|
|
|
1142
1172
|
shape
|
|
1143
1173
|
};
|
|
1144
1174
|
|
|
1145
|
-
let origin = {};
|
|
1146
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = core.MatrixHelper;
|
|
1175
|
+
let origin = {}, tempMatrix = core.getMatrixData();
|
|
1176
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = core.MatrixHelper;
|
|
1147
1177
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1148
1178
|
const transform = get$3();
|
|
1149
1179
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -1152,13 +1182,19 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1152
1182
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1153
1183
|
data.transform = transform;
|
|
1154
1184
|
}
|
|
1155
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1185
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
|
|
1156
1186
|
const transform = get$3();
|
|
1157
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
1158
|
-
if (scaleX)
|
|
1159
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
1160
1187
|
if (rotation)
|
|
1161
1188
|
rotate(transform, rotation);
|
|
1189
|
+
if (skew)
|
|
1190
|
+
skewHelper(transform, skew.x, skew.y);
|
|
1191
|
+
if (scaleX)
|
|
1192
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
1193
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
1194
|
+
if (clipSize) {
|
|
1195
|
+
tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
|
|
1196
|
+
multiplyParent(transform, tempMatrix);
|
|
1197
|
+
}
|
|
1162
1198
|
data.transform = transform;
|
|
1163
1199
|
}
|
|
1164
1200
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -1195,11 +1231,15 @@ const tempBox = new core.Bounds();
|
|
|
1195
1231
|
const tempScaleData = {};
|
|
1196
1232
|
const tempImage = {};
|
|
1197
1233
|
function createData(leafPaint, image, paint, box) {
|
|
1198
|
-
const { changeful, sync } = paint;
|
|
1234
|
+
const { changeful, sync, editing, scaleFixed } = paint;
|
|
1199
1235
|
if (changeful)
|
|
1200
1236
|
leafPaint.changeful = changeful;
|
|
1201
1237
|
if (sync)
|
|
1202
1238
|
leafPaint.sync = sync;
|
|
1239
|
+
if (editing)
|
|
1240
|
+
leafPaint.editing = editing;
|
|
1241
|
+
if (scaleFixed)
|
|
1242
|
+
leafPaint.scaleFixed = scaleFixed;
|
|
1203
1243
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1204
1244
|
}
|
|
1205
1245
|
function getPatternData(paint, box, image) {
|
|
@@ -1208,7 +1248,7 @@ function getPatternData(paint, box, image) {
|
|
|
1208
1248
|
if (paint.mode === 'strench')
|
|
1209
1249
|
paint.mode = 'stretch';
|
|
1210
1250
|
let { width, height } = image;
|
|
1211
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1251
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
|
|
1212
1252
|
const sameBox = box.width === width && box.height === height;
|
|
1213
1253
|
const data = { mode };
|
|
1214
1254
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1242,8 +1282,8 @@ function getPatternData(paint, box, image) {
|
|
|
1242
1282
|
break;
|
|
1243
1283
|
case 'normal':
|
|
1244
1284
|
case 'clip':
|
|
1245
|
-
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
1246
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1285
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1286
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
|
|
1247
1287
|
break;
|
|
1248
1288
|
case 'repeat':
|
|
1249
1289
|
if (!sameBox || scaleX || rotation)
|
|
@@ -1320,11 +1360,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1320
1360
|
}
|
|
1321
1361
|
onLoadSuccess(ui, event);
|
|
1322
1362
|
}
|
|
1323
|
-
leafPaint.loadId =
|
|
1363
|
+
leafPaint.loadId = undefined;
|
|
1324
1364
|
}, (error) => {
|
|
1325
1365
|
ignoreRender(ui, false);
|
|
1326
1366
|
onLoadError(ui, event, error);
|
|
1327
|
-
leafPaint.loadId =
|
|
1367
|
+
leafPaint.loadId = undefined;
|
|
1328
1368
|
});
|
|
1329
1369
|
if (ui.placeholderColor) {
|
|
1330
1370
|
if (!ui.placeholderDelay)
|
|
@@ -1380,16 +1420,16 @@ function ignoreRender(ui, value) {
|
|
|
1380
1420
|
}
|
|
1381
1421
|
|
|
1382
1422
|
const { get: get$1, scale, copy: copy$1 } = core.MatrixHelper;
|
|
1383
|
-
const { ceil, abs
|
|
1423
|
+
const { ceil, abs } = Math;
|
|
1384
1424
|
function createPattern(ui, paint, pixelRatio) {
|
|
1385
|
-
let { scaleX, scaleY } =
|
|
1425
|
+
let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1386
1426
|
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1387
1427
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1388
|
-
scaleX = abs$1(scaleX);
|
|
1389
|
-
scaleY = abs$1(scaleY);
|
|
1390
1428
|
const { image, data } = paint;
|
|
1391
1429
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1392
1430
|
if (sx) {
|
|
1431
|
+
sx = abs(sx);
|
|
1432
|
+
sy = abs(sy);
|
|
1393
1433
|
imageMatrix = get$1();
|
|
1394
1434
|
copy$1(imageMatrix, transform);
|
|
1395
1435
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -1474,9 +1514,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1474
1514
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1475
1515
|
};
|
|
1476
1516
|
|
|
1477
|
-
const { abs } = Math;
|
|
1478
1517
|
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1479
|
-
const { scaleX, scaleY } =
|
|
1518
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1480
1519
|
const { pixelRatio } = canvas, { data } = paint;
|
|
1481
1520
|
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
|
|
1482
1521
|
return false;
|
|
@@ -1489,8 +1528,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1489
1528
|
else {
|
|
1490
1529
|
if (!(paint.changeful || core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
|
|
1491
1530
|
let { width, height } = data;
|
|
1492
|
-
width *=
|
|
1493
|
-
height *=
|
|
1531
|
+
width *= scaleX * pixelRatio;
|
|
1532
|
+
height *= scaleY * pixelRatio;
|
|
1494
1533
|
if (data.scaleX) {
|
|
1495
1534
|
width *= data.scaleX;
|
|
1496
1535
|
height *= data.scaleY;
|
|
@@ -1500,6 +1539,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1500
1539
|
}
|
|
1501
1540
|
}
|
|
1502
1541
|
if (allowDraw) {
|
|
1542
|
+
if (ui.__.__isFastShadow) {
|
|
1543
|
+
canvas.fillStyle = paint.style || '#000';
|
|
1544
|
+
canvas.fill();
|
|
1545
|
+
}
|
|
1503
1546
|
drawImage(ui, canvas, paint, data);
|
|
1504
1547
|
return true;
|
|
1505
1548
|
}
|
|
@@ -1688,10 +1731,7 @@ function shadow(ui, current, shape) {
|
|
|
1688
1731
|
}
|
|
1689
1732
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1690
1733
|
}
|
|
1691
|
-
|
|
1692
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1693
|
-
else
|
|
1694
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1734
|
+
core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1695
1735
|
if (end && index < end)
|
|
1696
1736
|
other.clearWorld(copyBounds, true);
|
|
1697
1737
|
});
|
|
@@ -1750,10 +1790,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1750
1790
|
copyBounds = bounds;
|
|
1751
1791
|
}
|
|
1752
1792
|
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
1753
|
-
|
|
1754
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1755
|
-
else
|
|
1756
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1793
|
+
core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1757
1794
|
if (end && index < end)
|
|
1758
1795
|
other.clearWorld(copyBounds, true);
|
|
1759
1796
|
});
|
|
@@ -1809,12 +1846,11 @@ draw.Group.prototype.__renderMask = function (canvas, options) {
|
|
|
1809
1846
|
contentCanvas = getCanvas(canvas);
|
|
1810
1847
|
child.__render(maskCanvas, options);
|
|
1811
1848
|
}
|
|
1812
|
-
if (
|
|
1813
|
-
|
|
1814
|
-
}
|
|
1815
|
-
if (excludeRenderBounds(child, options))
|
|
1849
|
+
if (mask === 'clipping' || mask === 'clipping-path')
|
|
1850
|
+
excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
1816
1851
|
continue;
|
|
1817
|
-
|
|
1852
|
+
}
|
|
1853
|
+
excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
|
|
1818
1854
|
}
|
|
1819
1855
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
1820
1856
|
};
|
package/dist/web.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Debug, LeaferCanvasBase, Platform, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4 } from '@leafer/core';
|
|
1
|
+
import { Debug, LeaferCanvasBase, Platform, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, 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';
|
|
@@ -879,9 +879,14 @@ function fills(fills, ui, canvas) {
|
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
881
|
canvas.fillStyle = item.style;
|
|
882
|
-
if (item.transform) {
|
|
882
|
+
if (item.transform || item.scaleFixed) {
|
|
883
883
|
canvas.save();
|
|
884
|
-
|
|
884
|
+
if (item.transform)
|
|
885
|
+
canvas.transform(item.transform);
|
|
886
|
+
if (item.scaleFixed) {
|
|
887
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true);
|
|
888
|
+
canvas.scale(1 / scaleX, 1 / scaleY);
|
|
889
|
+
}
|
|
885
890
|
if (item.blendMode)
|
|
886
891
|
canvas.blendMode = item.blendMode;
|
|
887
892
|
fillPathOrText(ui, canvas);
|
|
@@ -917,8 +922,13 @@ function strokeText(stroke, ui, canvas) {
|
|
|
917
922
|
}
|
|
918
923
|
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
919
924
|
const data = ui.__;
|
|
920
|
-
|
|
921
|
-
|
|
925
|
+
if (typeof stroke === 'object') {
|
|
926
|
+
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
927
|
+
}
|
|
928
|
+
else {
|
|
929
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
930
|
+
drawTextStroke(ui, canvas);
|
|
931
|
+
}
|
|
922
932
|
}
|
|
923
933
|
function drawAlign(stroke, align, ui, canvas) {
|
|
924
934
|
const out = canvas.getSameCanvas(true, true);
|
|
@@ -927,15 +937,9 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
927
937
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
928
938
|
fillText(ui, out);
|
|
929
939
|
out.blendMode = 'normal';
|
|
930
|
-
|
|
940
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
931
941
|
out.recycle(ui.__nowWorld);
|
|
932
942
|
}
|
|
933
|
-
function copyWorld(canvas, out, ui) {
|
|
934
|
-
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
935
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
936
|
-
else
|
|
937
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
938
|
-
}
|
|
939
943
|
function drawTextStroke(ui, canvas) {
|
|
940
944
|
let row, data = ui.__.__textDrawData;
|
|
941
945
|
const { rows, decorationY } = data;
|
|
@@ -951,14 +955,21 @@ function drawTextStroke(ui, canvas) {
|
|
|
951
955
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
952
956
|
}
|
|
953
957
|
}
|
|
954
|
-
function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
958
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
955
959
|
let item;
|
|
960
|
+
const data = ui.__, { __hasMultiStrokeStyle } = data;
|
|
961
|
+
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
956
962
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
957
963
|
item = strokes[i];
|
|
958
964
|
if (item.image && PaintImage.checkImage(ui, canvas, item, false))
|
|
959
965
|
continue;
|
|
960
966
|
if (item.style) {
|
|
961
|
-
|
|
967
|
+
if (__hasMultiStrokeStyle) {
|
|
968
|
+
const { strokeStyle } = item;
|
|
969
|
+
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
970
|
+
}
|
|
971
|
+
else
|
|
972
|
+
canvas.strokeStyle = item.style;
|
|
962
973
|
if (item.blendMode) {
|
|
963
974
|
canvas.saveBlendMode(item.blendMode);
|
|
964
975
|
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
@@ -997,8 +1008,13 @@ function strokes(strokes, ui, canvas) {
|
|
|
997
1008
|
}
|
|
998
1009
|
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
999
1010
|
const data = ui.__;
|
|
1000
|
-
|
|
1001
|
-
|
|
1011
|
+
if (typeof stroke === 'object') {
|
|
1012
|
+
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
1013
|
+
}
|
|
1014
|
+
else {
|
|
1015
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
1016
|
+
canvas.stroke();
|
|
1017
|
+
}
|
|
1002
1018
|
if (data.__useArrow)
|
|
1003
1019
|
Paint.strokeArrow(stroke, ui, canvas);
|
|
1004
1020
|
}
|
|
@@ -1020,7 +1036,7 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
1020
1036
|
drawCenter(stroke, 2, ui, out);
|
|
1021
1037
|
out.clipUI(data);
|
|
1022
1038
|
out.clearWorld(renderBounds);
|
|
1023
|
-
|
|
1039
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
1024
1040
|
out.recycle(ui.__nowWorld);
|
|
1025
1041
|
}
|
|
1026
1042
|
}
|
|
@@ -1075,8 +1091,16 @@ function compute(attrName, ui) {
|
|
|
1075
1091
|
if (!(paints instanceof Array))
|
|
1076
1092
|
paints = [paints];
|
|
1077
1093
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
1094
|
+
let maxChildStrokeWidth;
|
|
1078
1095
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1079
|
-
(item = getLeafPaint(attrName, paints[i], ui))
|
|
1096
|
+
if (item = getLeafPaint(attrName, paints[i], ui)) {
|
|
1097
|
+
leafPaints.push(item);
|
|
1098
|
+
if (item.strokeStyle) {
|
|
1099
|
+
maxChildStrokeWidth || (maxChildStrokeWidth = 1);
|
|
1100
|
+
if (item.strokeStyle.strokeWidth)
|
|
1101
|
+
maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1080
1104
|
}
|
|
1081
1105
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1082
1106
|
if (leafPaints.length) {
|
|
@@ -1093,6 +1117,7 @@ function compute(attrName, ui) {
|
|
|
1093
1117
|
else {
|
|
1094
1118
|
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1095
1119
|
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1120
|
+
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
|
|
1096
1121
|
}
|
|
1097
1122
|
}
|
|
1098
1123
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -1124,6 +1149,11 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1124
1149
|
if (data) {
|
|
1125
1150
|
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1126
1151
|
data.isTransparent = true;
|
|
1152
|
+
if (paint.style) {
|
|
1153
|
+
if (paint.style.strokeWidth === 0)
|
|
1154
|
+
return undefined;
|
|
1155
|
+
data.strokeStyle = paint.style;
|
|
1156
|
+
}
|
|
1127
1157
|
if (paint.blendMode)
|
|
1128
1158
|
data.blendMode = paint.blendMode;
|
|
1129
1159
|
}
|
|
@@ -1143,8 +1173,8 @@ const PaintModule = {
|
|
|
1143
1173
|
shape
|
|
1144
1174
|
};
|
|
1145
1175
|
|
|
1146
|
-
let origin = {};
|
|
1147
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
|
|
1176
|
+
let origin = {}, tempMatrix = getMatrixData();
|
|
1177
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
|
|
1148
1178
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1149
1179
|
const transform = get$3();
|
|
1150
1180
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -1153,13 +1183,19 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1153
1183
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1154
1184
|
data.transform = transform;
|
|
1155
1185
|
}
|
|
1156
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1186
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
|
|
1157
1187
|
const transform = get$3();
|
|
1158
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
1159
|
-
if (scaleX)
|
|
1160
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
1161
1188
|
if (rotation)
|
|
1162
1189
|
rotate(transform, rotation);
|
|
1190
|
+
if (skew)
|
|
1191
|
+
skewHelper(transform, skew.x, skew.y);
|
|
1192
|
+
if (scaleX)
|
|
1193
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
1194
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
1195
|
+
if (clipSize) {
|
|
1196
|
+
tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
|
|
1197
|
+
multiplyParent(transform, tempMatrix);
|
|
1198
|
+
}
|
|
1163
1199
|
data.transform = transform;
|
|
1164
1200
|
}
|
|
1165
1201
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -1196,11 +1232,15 @@ const tempBox = new Bounds();
|
|
|
1196
1232
|
const tempScaleData = {};
|
|
1197
1233
|
const tempImage = {};
|
|
1198
1234
|
function createData(leafPaint, image, paint, box) {
|
|
1199
|
-
const { changeful, sync } = paint;
|
|
1235
|
+
const { changeful, sync, editing, scaleFixed } = paint;
|
|
1200
1236
|
if (changeful)
|
|
1201
1237
|
leafPaint.changeful = changeful;
|
|
1202
1238
|
if (sync)
|
|
1203
1239
|
leafPaint.sync = sync;
|
|
1240
|
+
if (editing)
|
|
1241
|
+
leafPaint.editing = editing;
|
|
1242
|
+
if (scaleFixed)
|
|
1243
|
+
leafPaint.scaleFixed = scaleFixed;
|
|
1204
1244
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1205
1245
|
}
|
|
1206
1246
|
function getPatternData(paint, box, image) {
|
|
@@ -1209,7 +1249,7 @@ function getPatternData(paint, box, image) {
|
|
|
1209
1249
|
if (paint.mode === 'strench')
|
|
1210
1250
|
paint.mode = 'stretch';
|
|
1211
1251
|
let { width, height } = image;
|
|
1212
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1252
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
|
|
1213
1253
|
const sameBox = box.width === width && box.height === height;
|
|
1214
1254
|
const data = { mode };
|
|
1215
1255
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1243,8 +1283,8 @@ function getPatternData(paint, box, image) {
|
|
|
1243
1283
|
break;
|
|
1244
1284
|
case 'normal':
|
|
1245
1285
|
case 'clip':
|
|
1246
|
-
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
1247
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1286
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1287
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
|
|
1248
1288
|
break;
|
|
1249
1289
|
case 'repeat':
|
|
1250
1290
|
if (!sameBox || scaleX || rotation)
|
|
@@ -1321,11 +1361,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1321
1361
|
}
|
|
1322
1362
|
onLoadSuccess(ui, event);
|
|
1323
1363
|
}
|
|
1324
|
-
leafPaint.loadId =
|
|
1364
|
+
leafPaint.loadId = undefined;
|
|
1325
1365
|
}, (error) => {
|
|
1326
1366
|
ignoreRender(ui, false);
|
|
1327
1367
|
onLoadError(ui, event, error);
|
|
1328
|
-
leafPaint.loadId =
|
|
1368
|
+
leafPaint.loadId = undefined;
|
|
1329
1369
|
});
|
|
1330
1370
|
if (ui.placeholderColor) {
|
|
1331
1371
|
if (!ui.placeholderDelay)
|
|
@@ -1381,16 +1421,16 @@ function ignoreRender(ui, value) {
|
|
|
1381
1421
|
}
|
|
1382
1422
|
|
|
1383
1423
|
const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
1384
|
-
const { ceil, abs
|
|
1424
|
+
const { ceil, abs } = Math;
|
|
1385
1425
|
function createPattern(ui, paint, pixelRatio) {
|
|
1386
|
-
let { scaleX, scaleY } =
|
|
1426
|
+
let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1387
1427
|
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1388
1428
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1389
|
-
scaleX = abs$1(scaleX);
|
|
1390
|
-
scaleY = abs$1(scaleY);
|
|
1391
1429
|
const { image, data } = paint;
|
|
1392
1430
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1393
1431
|
if (sx) {
|
|
1432
|
+
sx = abs(sx);
|
|
1433
|
+
sy = abs(sy);
|
|
1394
1434
|
imageMatrix = get$1();
|
|
1395
1435
|
copy$1(imageMatrix, transform);
|
|
1396
1436
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -1475,9 +1515,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1475
1515
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1476
1516
|
};
|
|
1477
1517
|
|
|
1478
|
-
const { abs } = Math;
|
|
1479
1518
|
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1480
|
-
const { scaleX, scaleY } =
|
|
1519
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1481
1520
|
const { pixelRatio } = canvas, { data } = paint;
|
|
1482
1521
|
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1483
1522
|
return false;
|
|
@@ -1490,8 +1529,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1490
1529
|
else {
|
|
1491
1530
|
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1492
1531
|
let { width, height } = data;
|
|
1493
|
-
width *=
|
|
1494
|
-
height *=
|
|
1532
|
+
width *= scaleX * pixelRatio;
|
|
1533
|
+
height *= scaleY * pixelRatio;
|
|
1495
1534
|
if (data.scaleX) {
|
|
1496
1535
|
width *= data.scaleX;
|
|
1497
1536
|
height *= data.scaleY;
|
|
@@ -1501,6 +1540,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1501
1540
|
}
|
|
1502
1541
|
}
|
|
1503
1542
|
if (allowDraw) {
|
|
1543
|
+
if (ui.__.__isFastShadow) {
|
|
1544
|
+
canvas.fillStyle = paint.style || '#000';
|
|
1545
|
+
canvas.fill();
|
|
1546
|
+
}
|
|
1504
1547
|
drawImage(ui, canvas, paint, data);
|
|
1505
1548
|
return true;
|
|
1506
1549
|
}
|
|
@@ -1689,10 +1732,7 @@ function shadow(ui, current, shape) {
|
|
|
1689
1732
|
}
|
|
1690
1733
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1691
1734
|
}
|
|
1692
|
-
|
|
1693
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1694
|
-
else
|
|
1695
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1735
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1696
1736
|
if (end && index < end)
|
|
1697
1737
|
other.clearWorld(copyBounds, true);
|
|
1698
1738
|
});
|
|
@@ -1751,10 +1791,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1751
1791
|
copyBounds = bounds;
|
|
1752
1792
|
}
|
|
1753
1793
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
|
|
1754
|
-
|
|
1755
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1756
|
-
else
|
|
1757
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1794
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1758
1795
|
if (end && index < end)
|
|
1759
1796
|
other.clearWorld(copyBounds, true);
|
|
1760
1797
|
});
|
|
@@ -1810,12 +1847,11 @@ Group.prototype.__renderMask = function (canvas, options) {
|
|
|
1810
1847
|
contentCanvas = getCanvas(canvas);
|
|
1811
1848
|
child.__render(maskCanvas, options);
|
|
1812
1849
|
}
|
|
1813
|
-
if (
|
|
1814
|
-
|
|
1815
|
-
}
|
|
1816
|
-
if (excludeRenderBounds(child, options))
|
|
1850
|
+
if (mask === 'clipping' || mask === 'clipping-path')
|
|
1851
|
+
excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
1817
1852
|
continue;
|
|
1818
|
-
|
|
1853
|
+
}
|
|
1854
|
+
excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
|
|
1819
1855
|
}
|
|
1820
1856
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
1821
1857
|
};
|