@leafer-ui/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 +240 -144
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +12 -12
package/dist/miniapp.cjs
CHANGED
|
@@ -1099,9 +1099,14 @@ function fills(fills, ui, canvas) {
|
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
1101
|
canvas.fillStyle = item.style;
|
|
1102
|
-
if (item.transform) {
|
|
1102
|
+
if (item.transform || item.scaleFixed) {
|
|
1103
1103
|
canvas.save();
|
|
1104
|
-
|
|
1104
|
+
if (item.transform)
|
|
1105
|
+
canvas.transform(item.transform);
|
|
1106
|
+
if (item.scaleFixed) {
|
|
1107
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true);
|
|
1108
|
+
canvas.scale(1 / scaleX, 1 / scaleY);
|
|
1109
|
+
}
|
|
1105
1110
|
if (item.blendMode)
|
|
1106
1111
|
canvas.blendMode = item.blendMode;
|
|
1107
1112
|
fillPathOrText(ui, canvas);
|
|
@@ -1137,8 +1142,13 @@ function strokeText(stroke, ui, canvas) {
|
|
|
1137
1142
|
}
|
|
1138
1143
|
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
1139
1144
|
const data = ui.__;
|
|
1140
|
-
|
|
1141
|
-
|
|
1145
|
+
if (typeof stroke === 'object') {
|
|
1146
|
+
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
1147
|
+
}
|
|
1148
|
+
else {
|
|
1149
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
1150
|
+
drawTextStroke(ui, canvas);
|
|
1151
|
+
}
|
|
1142
1152
|
}
|
|
1143
1153
|
function drawAlign(stroke, align, ui, canvas) {
|
|
1144
1154
|
const out = canvas.getSameCanvas(true, true);
|
|
@@ -1147,15 +1157,9 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
1147
1157
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
1148
1158
|
fillText(ui, out);
|
|
1149
1159
|
out.blendMode = 'normal';
|
|
1150
|
-
|
|
1160
|
+
core.LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
1151
1161
|
out.recycle(ui.__nowWorld);
|
|
1152
1162
|
}
|
|
1153
|
-
function copyWorld(canvas, out, ui) {
|
|
1154
|
-
if (ui.__worldFlipped || core.Platform.fullImageShadow)
|
|
1155
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1156
|
-
else
|
|
1157
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
1158
|
-
}
|
|
1159
1163
|
function drawTextStroke(ui, canvas) {
|
|
1160
1164
|
let row, data = ui.__.__textDrawData;
|
|
1161
1165
|
const { rows, decorationY } = data;
|
|
@@ -1171,14 +1175,21 @@ function drawTextStroke(ui, canvas) {
|
|
|
1171
1175
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
1172
1176
|
}
|
|
1173
1177
|
}
|
|
1174
|
-
function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
1178
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
1175
1179
|
let item;
|
|
1180
|
+
const data = ui.__, { __hasMultiStrokeStyle } = data;
|
|
1181
|
+
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
1176
1182
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
1177
1183
|
item = strokes[i];
|
|
1178
1184
|
if (item.image && draw.PaintImage.checkImage(ui, canvas, item, false))
|
|
1179
1185
|
continue;
|
|
1180
1186
|
if (item.style) {
|
|
1181
|
-
|
|
1187
|
+
if (__hasMultiStrokeStyle) {
|
|
1188
|
+
const { strokeStyle } = item;
|
|
1189
|
+
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
1190
|
+
}
|
|
1191
|
+
else
|
|
1192
|
+
canvas.strokeStyle = item.style;
|
|
1182
1193
|
if (item.blendMode) {
|
|
1183
1194
|
canvas.saveBlendMode(item.blendMode);
|
|
1184
1195
|
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
@@ -1217,8 +1228,13 @@ function strokes(strokes, ui, canvas) {
|
|
|
1217
1228
|
}
|
|
1218
1229
|
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
1219
1230
|
const data = ui.__;
|
|
1220
|
-
|
|
1221
|
-
|
|
1231
|
+
if (typeof stroke === 'object') {
|
|
1232
|
+
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
1233
|
+
}
|
|
1234
|
+
else {
|
|
1235
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
1236
|
+
canvas.stroke();
|
|
1237
|
+
}
|
|
1222
1238
|
if (data.__useArrow)
|
|
1223
1239
|
draw.Paint.strokeArrow(stroke, ui, canvas);
|
|
1224
1240
|
}
|
|
@@ -1240,7 +1256,7 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
1240
1256
|
drawCenter(stroke, 2, ui, out);
|
|
1241
1257
|
out.clipUI(data);
|
|
1242
1258
|
out.clearWorld(renderBounds);
|
|
1243
|
-
|
|
1259
|
+
core.LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
1244
1260
|
out.recycle(ui.__nowWorld);
|
|
1245
1261
|
}
|
|
1246
1262
|
}
|
|
@@ -1295,8 +1311,16 @@ function compute(attrName, ui) {
|
|
|
1295
1311
|
if (!(paints instanceof Array))
|
|
1296
1312
|
paints = [paints];
|
|
1297
1313
|
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
1314
|
+
let maxChildStrokeWidth;
|
|
1298
1315
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1299
|
-
(item = getLeafPaint(attrName, paints[i], ui))
|
|
1316
|
+
if (item = getLeafPaint(attrName, paints[i], ui)) {
|
|
1317
|
+
leafPaints.push(item);
|
|
1318
|
+
if (item.strokeStyle) {
|
|
1319
|
+
maxChildStrokeWidth || (maxChildStrokeWidth = 1);
|
|
1320
|
+
if (item.strokeStyle.strokeWidth)
|
|
1321
|
+
maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1300
1324
|
}
|
|
1301
1325
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1302
1326
|
if (leafPaints.length) {
|
|
@@ -1313,6 +1337,7 @@ function compute(attrName, ui) {
|
|
|
1313
1337
|
else {
|
|
1314
1338
|
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1315
1339
|
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1340
|
+
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
|
|
1316
1341
|
}
|
|
1317
1342
|
}
|
|
1318
1343
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -1344,6 +1369,11 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1344
1369
|
if (data) {
|
|
1345
1370
|
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1346
1371
|
data.isTransparent = true;
|
|
1372
|
+
if (paint.style) {
|
|
1373
|
+
if (paint.style.strokeWidth === 0)
|
|
1374
|
+
return undefined;
|
|
1375
|
+
data.strokeStyle = paint.style;
|
|
1376
|
+
}
|
|
1347
1377
|
if (paint.blendMode)
|
|
1348
1378
|
data.blendMode = paint.blendMode;
|
|
1349
1379
|
}
|
|
@@ -1363,8 +1393,8 @@ const PaintModule = {
|
|
|
1363
1393
|
shape
|
|
1364
1394
|
};
|
|
1365
1395
|
|
|
1366
|
-
let origin = {};
|
|
1367
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = core.MatrixHelper;
|
|
1396
|
+
let origin = {}, tempMatrix = core.getMatrixData();
|
|
1397
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = core.MatrixHelper;
|
|
1368
1398
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1369
1399
|
const transform = get$3();
|
|
1370
1400
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -1373,7 +1403,7 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1373
1403
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1374
1404
|
data.transform = transform;
|
|
1375
1405
|
}
|
|
1376
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
1406
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
|
|
1377
1407
|
const transform = get$3();
|
|
1378
1408
|
if (rotation)
|
|
1379
1409
|
rotate(transform, rotation);
|
|
@@ -1382,6 +1412,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
|
1382
1412
|
if (scaleX)
|
|
1383
1413
|
scaleHelper(transform, scaleX, scaleY);
|
|
1384
1414
|
translate$1(transform, box.x + x, box.y + y);
|
|
1415
|
+
if (clipSize) {
|
|
1416
|
+
tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
|
|
1417
|
+
multiplyParent(transform, tempMatrix);
|
|
1418
|
+
}
|
|
1385
1419
|
data.transform = transform;
|
|
1386
1420
|
}
|
|
1387
1421
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -1418,13 +1452,15 @@ const tempBox = new core.Bounds();
|
|
|
1418
1452
|
const tempScaleData = {};
|
|
1419
1453
|
const tempImage = {};
|
|
1420
1454
|
function createData(leafPaint, image, paint, box) {
|
|
1421
|
-
const { changeful, sync, editing } = paint;
|
|
1455
|
+
const { changeful, sync, editing, scaleFixed } = paint;
|
|
1422
1456
|
if (changeful)
|
|
1423
1457
|
leafPaint.changeful = changeful;
|
|
1424
1458
|
if (sync)
|
|
1425
1459
|
leafPaint.sync = sync;
|
|
1426
1460
|
if (editing)
|
|
1427
1461
|
leafPaint.editing = editing;
|
|
1462
|
+
if (scaleFixed)
|
|
1463
|
+
leafPaint.scaleFixed = scaleFixed;
|
|
1428
1464
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1429
1465
|
}
|
|
1430
1466
|
function getPatternData(paint, box, image) {
|
|
@@ -1433,7 +1469,7 @@ function getPatternData(paint, box, image) {
|
|
|
1433
1469
|
if (paint.mode === 'strench')
|
|
1434
1470
|
paint.mode = 'stretch';
|
|
1435
1471
|
let { width, height } = image;
|
|
1436
|
-
const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
|
|
1472
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
|
|
1437
1473
|
const sameBox = box.width === width && box.height === height;
|
|
1438
1474
|
const data = { mode };
|
|
1439
1475
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1467,8 +1503,8 @@ function getPatternData(paint, box, image) {
|
|
|
1467
1503
|
break;
|
|
1468
1504
|
case 'normal':
|
|
1469
1505
|
case 'clip':
|
|
1470
|
-
if (tempImage.x || tempImage.y || scaleX || rotation || skew)
|
|
1471
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
|
|
1506
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1507
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
|
|
1472
1508
|
break;
|
|
1473
1509
|
case 'repeat':
|
|
1474
1510
|
if (!sameBox || scaleX || rotation)
|
|
@@ -1605,18 +1641,16 @@ function ignoreRender(ui, value) {
|
|
|
1605
1641
|
}
|
|
1606
1642
|
|
|
1607
1643
|
const { get: get$1, scale, copy: copy$1 } = core.MatrixHelper;
|
|
1608
|
-
const { ceil, abs
|
|
1644
|
+
const { ceil, abs } = Math;
|
|
1609
1645
|
function createPattern(ui, paint, pixelRatio) {
|
|
1610
|
-
let { scaleX, scaleY } =
|
|
1646
|
+
let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1611
1647
|
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1612
1648
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1613
|
-
scaleX = abs$1(scaleX);
|
|
1614
|
-
scaleY = abs$1(scaleY);
|
|
1615
1649
|
const { image, data } = paint;
|
|
1616
1650
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1617
1651
|
if (sx) {
|
|
1618
|
-
sx = abs
|
|
1619
|
-
sy = abs
|
|
1652
|
+
sx = abs(sx);
|
|
1653
|
+
sy = abs(sy);
|
|
1620
1654
|
imageMatrix = get$1();
|
|
1621
1655
|
copy$1(imageMatrix, transform);
|
|
1622
1656
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -1701,9 +1735,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1701
1735
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1702
1736
|
};
|
|
1703
1737
|
|
|
1704
|
-
const { abs } = Math;
|
|
1705
1738
|
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1706
|
-
const { scaleX, scaleY } =
|
|
1739
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1707
1740
|
const { pixelRatio } = canvas, { data } = paint;
|
|
1708
1741
|
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
|
|
1709
1742
|
return false;
|
|
@@ -1716,8 +1749,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1716
1749
|
else {
|
|
1717
1750
|
if (!(paint.changeful || core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
|
|
1718
1751
|
let { width, height } = data;
|
|
1719
|
-
width *=
|
|
1720
|
-
height *=
|
|
1752
|
+
width *= scaleX * pixelRatio;
|
|
1753
|
+
height *= scaleY * pixelRatio;
|
|
1721
1754
|
if (data.scaleX) {
|
|
1722
1755
|
width *= data.scaleX;
|
|
1723
1756
|
height *= data.scaleY;
|
|
@@ -1727,6 +1760,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1727
1760
|
}
|
|
1728
1761
|
}
|
|
1729
1762
|
if (allowDraw) {
|
|
1763
|
+
if (ui.__.__isFastShadow) {
|
|
1764
|
+
canvas.fillStyle = paint.style || '#000';
|
|
1765
|
+
canvas.fill();
|
|
1766
|
+
}
|
|
1730
1767
|
drawImage(ui, canvas, paint, data);
|
|
1731
1768
|
return true;
|
|
1732
1769
|
}
|
|
@@ -1915,10 +1952,7 @@ function shadow(ui, current, shape) {
|
|
|
1915
1952
|
}
|
|
1916
1953
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1917
1954
|
}
|
|
1918
|
-
|
|
1919
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1920
|
-
else
|
|
1921
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1955
|
+
core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1922
1956
|
if (end && index < end)
|
|
1923
1957
|
other.clearWorld(copyBounds, true);
|
|
1924
1958
|
});
|
|
@@ -1977,10 +2011,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1977
2011
|
copyBounds = bounds;
|
|
1978
2012
|
}
|
|
1979
2013
|
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
1980
|
-
|
|
1981
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1982
|
-
else
|
|
1983
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
2014
|
+
core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1984
2015
|
if (end && index < end)
|
|
1985
2016
|
other.clearWorld(copyBounds, true);
|
|
1986
2017
|
});
|
|
@@ -2036,12 +2067,11 @@ draw.Group.prototype.__renderMask = function (canvas, options) {
|
|
|
2036
2067
|
contentCanvas = getCanvas(canvas);
|
|
2037
2068
|
child.__render(maskCanvas, options);
|
|
2038
2069
|
}
|
|
2039
|
-
if (
|
|
2040
|
-
|
|
2041
|
-
}
|
|
2042
|
-
if (excludeRenderBounds(child, options))
|
|
2070
|
+
if (mask === 'clipping' || mask === 'clipping-path')
|
|
2071
|
+
excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
2043
2072
|
continue;
|
|
2044
|
-
|
|
2073
|
+
}
|
|
2074
|
+
excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
|
|
2045
2075
|
}
|
|
2046
2076
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
2047
2077
|
};
|
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, Plugin, 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, 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 { InteractionHelper, InteractionBase, HitCanvasManager } from '@leafer-ui/core';
|
|
@@ -1100,9 +1100,14 @@ function fills(fills, ui, canvas) {
|
|
|
1100
1100
|
}
|
|
1101
1101
|
}
|
|
1102
1102
|
canvas.fillStyle = item.style;
|
|
1103
|
-
if (item.transform) {
|
|
1103
|
+
if (item.transform || item.scaleFixed) {
|
|
1104
1104
|
canvas.save();
|
|
1105
|
-
|
|
1105
|
+
if (item.transform)
|
|
1106
|
+
canvas.transform(item.transform);
|
|
1107
|
+
if (item.scaleFixed) {
|
|
1108
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true);
|
|
1109
|
+
canvas.scale(1 / scaleX, 1 / scaleY);
|
|
1110
|
+
}
|
|
1106
1111
|
if (item.blendMode)
|
|
1107
1112
|
canvas.blendMode = item.blendMode;
|
|
1108
1113
|
fillPathOrText(ui, canvas);
|
|
@@ -1138,8 +1143,13 @@ function strokeText(stroke, ui, canvas) {
|
|
|
1138
1143
|
}
|
|
1139
1144
|
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
1140
1145
|
const data = ui.__;
|
|
1141
|
-
|
|
1142
|
-
|
|
1146
|
+
if (typeof stroke === 'object') {
|
|
1147
|
+
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
1148
|
+
}
|
|
1149
|
+
else {
|
|
1150
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
1151
|
+
drawTextStroke(ui, canvas);
|
|
1152
|
+
}
|
|
1143
1153
|
}
|
|
1144
1154
|
function drawAlign(stroke, align, ui, canvas) {
|
|
1145
1155
|
const out = canvas.getSameCanvas(true, true);
|
|
@@ -1148,15 +1158,9 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
1148
1158
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
1149
1159
|
fillText(ui, out);
|
|
1150
1160
|
out.blendMode = 'normal';
|
|
1151
|
-
|
|
1161
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
1152
1162
|
out.recycle(ui.__nowWorld);
|
|
1153
1163
|
}
|
|
1154
|
-
function copyWorld(canvas, out, ui) {
|
|
1155
|
-
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
1156
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1157
|
-
else
|
|
1158
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
1159
|
-
}
|
|
1160
1164
|
function drawTextStroke(ui, canvas) {
|
|
1161
1165
|
let row, data = ui.__.__textDrawData;
|
|
1162
1166
|
const { rows, decorationY } = data;
|
|
@@ -1172,14 +1176,21 @@ function drawTextStroke(ui, canvas) {
|
|
|
1172
1176
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
1173
1177
|
}
|
|
1174
1178
|
}
|
|
1175
|
-
function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
1179
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
1176
1180
|
let item;
|
|
1181
|
+
const data = ui.__, { __hasMultiStrokeStyle } = data;
|
|
1182
|
+
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
1177
1183
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
1178
1184
|
item = strokes[i];
|
|
1179
1185
|
if (item.image && PaintImage.checkImage(ui, canvas, item, false))
|
|
1180
1186
|
continue;
|
|
1181
1187
|
if (item.style) {
|
|
1182
|
-
|
|
1188
|
+
if (__hasMultiStrokeStyle) {
|
|
1189
|
+
const { strokeStyle } = item;
|
|
1190
|
+
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
1191
|
+
}
|
|
1192
|
+
else
|
|
1193
|
+
canvas.strokeStyle = item.style;
|
|
1183
1194
|
if (item.blendMode) {
|
|
1184
1195
|
canvas.saveBlendMode(item.blendMode);
|
|
1185
1196
|
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
@@ -1218,8 +1229,13 @@ function strokes(strokes, ui, canvas) {
|
|
|
1218
1229
|
}
|
|
1219
1230
|
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
1220
1231
|
const data = ui.__;
|
|
1221
|
-
|
|
1222
|
-
|
|
1232
|
+
if (typeof stroke === 'object') {
|
|
1233
|
+
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
1234
|
+
}
|
|
1235
|
+
else {
|
|
1236
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
1237
|
+
canvas.stroke();
|
|
1238
|
+
}
|
|
1223
1239
|
if (data.__useArrow)
|
|
1224
1240
|
Paint.strokeArrow(stroke, ui, canvas);
|
|
1225
1241
|
}
|
|
@@ -1241,7 +1257,7 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
1241
1257
|
drawCenter(stroke, 2, ui, out);
|
|
1242
1258
|
out.clipUI(data);
|
|
1243
1259
|
out.clearWorld(renderBounds);
|
|
1244
|
-
|
|
1260
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
1245
1261
|
out.recycle(ui.__nowWorld);
|
|
1246
1262
|
}
|
|
1247
1263
|
}
|
|
@@ -1296,8 +1312,16 @@ function compute(attrName, ui) {
|
|
|
1296
1312
|
if (!(paints instanceof Array))
|
|
1297
1313
|
paints = [paints];
|
|
1298
1314
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
1315
|
+
let maxChildStrokeWidth;
|
|
1299
1316
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1300
|
-
(item = getLeafPaint(attrName, paints[i], ui))
|
|
1317
|
+
if (item = getLeafPaint(attrName, paints[i], ui)) {
|
|
1318
|
+
leafPaints.push(item);
|
|
1319
|
+
if (item.strokeStyle) {
|
|
1320
|
+
maxChildStrokeWidth || (maxChildStrokeWidth = 1);
|
|
1321
|
+
if (item.strokeStyle.strokeWidth)
|
|
1322
|
+
maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1301
1325
|
}
|
|
1302
1326
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1303
1327
|
if (leafPaints.length) {
|
|
@@ -1314,6 +1338,7 @@ function compute(attrName, ui) {
|
|
|
1314
1338
|
else {
|
|
1315
1339
|
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1316
1340
|
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1341
|
+
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
|
|
1317
1342
|
}
|
|
1318
1343
|
}
|
|
1319
1344
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -1345,6 +1370,11 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1345
1370
|
if (data) {
|
|
1346
1371
|
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1347
1372
|
data.isTransparent = true;
|
|
1373
|
+
if (paint.style) {
|
|
1374
|
+
if (paint.style.strokeWidth === 0)
|
|
1375
|
+
return undefined;
|
|
1376
|
+
data.strokeStyle = paint.style;
|
|
1377
|
+
}
|
|
1348
1378
|
if (paint.blendMode)
|
|
1349
1379
|
data.blendMode = paint.blendMode;
|
|
1350
1380
|
}
|
|
@@ -1364,8 +1394,8 @@ const PaintModule = {
|
|
|
1364
1394
|
shape
|
|
1365
1395
|
};
|
|
1366
1396
|
|
|
1367
|
-
let origin = {};
|
|
1368
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
|
|
1397
|
+
let origin = {}, tempMatrix = getMatrixData();
|
|
1398
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
|
|
1369
1399
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1370
1400
|
const transform = get$3();
|
|
1371
1401
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -1374,7 +1404,7 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1374
1404
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1375
1405
|
data.transform = transform;
|
|
1376
1406
|
}
|
|
1377
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
1407
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
|
|
1378
1408
|
const transform = get$3();
|
|
1379
1409
|
if (rotation)
|
|
1380
1410
|
rotate(transform, rotation);
|
|
@@ -1383,6 +1413,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
|
1383
1413
|
if (scaleX)
|
|
1384
1414
|
scaleHelper(transform, scaleX, scaleY);
|
|
1385
1415
|
translate$1(transform, box.x + x, box.y + y);
|
|
1416
|
+
if (clipSize) {
|
|
1417
|
+
tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
|
|
1418
|
+
multiplyParent(transform, tempMatrix);
|
|
1419
|
+
}
|
|
1386
1420
|
data.transform = transform;
|
|
1387
1421
|
}
|
|
1388
1422
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -1419,13 +1453,15 @@ const tempBox = new Bounds();
|
|
|
1419
1453
|
const tempScaleData = {};
|
|
1420
1454
|
const tempImage = {};
|
|
1421
1455
|
function createData(leafPaint, image, paint, box) {
|
|
1422
|
-
const { changeful, sync, editing } = paint;
|
|
1456
|
+
const { changeful, sync, editing, scaleFixed } = paint;
|
|
1423
1457
|
if (changeful)
|
|
1424
1458
|
leafPaint.changeful = changeful;
|
|
1425
1459
|
if (sync)
|
|
1426
1460
|
leafPaint.sync = sync;
|
|
1427
1461
|
if (editing)
|
|
1428
1462
|
leafPaint.editing = editing;
|
|
1463
|
+
if (scaleFixed)
|
|
1464
|
+
leafPaint.scaleFixed = scaleFixed;
|
|
1429
1465
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1430
1466
|
}
|
|
1431
1467
|
function getPatternData(paint, box, image) {
|
|
@@ -1434,7 +1470,7 @@ function getPatternData(paint, box, image) {
|
|
|
1434
1470
|
if (paint.mode === 'strench')
|
|
1435
1471
|
paint.mode = 'stretch';
|
|
1436
1472
|
let { width, height } = image;
|
|
1437
|
-
const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
|
|
1473
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
|
|
1438
1474
|
const sameBox = box.width === width && box.height === height;
|
|
1439
1475
|
const data = { mode };
|
|
1440
1476
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1468,8 +1504,8 @@ function getPatternData(paint, box, image) {
|
|
|
1468
1504
|
break;
|
|
1469
1505
|
case 'normal':
|
|
1470
1506
|
case 'clip':
|
|
1471
|
-
if (tempImage.x || tempImage.y || scaleX || rotation || skew)
|
|
1472
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
|
|
1507
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1508
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
|
|
1473
1509
|
break;
|
|
1474
1510
|
case 'repeat':
|
|
1475
1511
|
if (!sameBox || scaleX || rotation)
|
|
@@ -1606,18 +1642,16 @@ function ignoreRender(ui, value) {
|
|
|
1606
1642
|
}
|
|
1607
1643
|
|
|
1608
1644
|
const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
1609
|
-
const { ceil, abs
|
|
1645
|
+
const { ceil, abs } = Math;
|
|
1610
1646
|
function createPattern(ui, paint, pixelRatio) {
|
|
1611
|
-
let { scaleX, scaleY } =
|
|
1647
|
+
let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1612
1648
|
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1613
1649
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1614
|
-
scaleX = abs$1(scaleX);
|
|
1615
|
-
scaleY = abs$1(scaleY);
|
|
1616
1650
|
const { image, data } = paint;
|
|
1617
1651
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1618
1652
|
if (sx) {
|
|
1619
|
-
sx = abs
|
|
1620
|
-
sy = abs
|
|
1653
|
+
sx = abs(sx);
|
|
1654
|
+
sy = abs(sy);
|
|
1621
1655
|
imageMatrix = get$1();
|
|
1622
1656
|
copy$1(imageMatrix, transform);
|
|
1623
1657
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -1702,9 +1736,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1702
1736
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1703
1737
|
};
|
|
1704
1738
|
|
|
1705
|
-
const { abs } = Math;
|
|
1706
1739
|
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1707
|
-
const { scaleX, scaleY } =
|
|
1740
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
1708
1741
|
const { pixelRatio } = canvas, { data } = paint;
|
|
1709
1742
|
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1710
1743
|
return false;
|
|
@@ -1717,8 +1750,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1717
1750
|
else {
|
|
1718
1751
|
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1719
1752
|
let { width, height } = data;
|
|
1720
|
-
width *=
|
|
1721
|
-
height *=
|
|
1753
|
+
width *= scaleX * pixelRatio;
|
|
1754
|
+
height *= scaleY * pixelRatio;
|
|
1722
1755
|
if (data.scaleX) {
|
|
1723
1756
|
width *= data.scaleX;
|
|
1724
1757
|
height *= data.scaleY;
|
|
@@ -1728,6 +1761,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1728
1761
|
}
|
|
1729
1762
|
}
|
|
1730
1763
|
if (allowDraw) {
|
|
1764
|
+
if (ui.__.__isFastShadow) {
|
|
1765
|
+
canvas.fillStyle = paint.style || '#000';
|
|
1766
|
+
canvas.fill();
|
|
1767
|
+
}
|
|
1731
1768
|
drawImage(ui, canvas, paint, data);
|
|
1732
1769
|
return true;
|
|
1733
1770
|
}
|
|
@@ -1916,10 +1953,7 @@ function shadow(ui, current, shape) {
|
|
|
1916
1953
|
}
|
|
1917
1954
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1918
1955
|
}
|
|
1919
|
-
|
|
1920
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1921
|
-
else
|
|
1922
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1956
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1923
1957
|
if (end && index < end)
|
|
1924
1958
|
other.clearWorld(copyBounds, true);
|
|
1925
1959
|
});
|
|
@@ -1978,10 +2012,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1978
2012
|
copyBounds = bounds;
|
|
1979
2013
|
}
|
|
1980
2014
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
|
|
1981
|
-
|
|
1982
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1983
|
-
else
|
|
1984
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
2015
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1985
2016
|
if (end && index < end)
|
|
1986
2017
|
other.clearWorld(copyBounds, true);
|
|
1987
2018
|
});
|
|
@@ -2037,12 +2068,11 @@ Group.prototype.__renderMask = function (canvas, options) {
|
|
|
2037
2068
|
contentCanvas = getCanvas(canvas);
|
|
2038
2069
|
child.__render(maskCanvas, options);
|
|
2039
2070
|
}
|
|
2040
|
-
if (
|
|
2041
|
-
|
|
2042
|
-
}
|
|
2043
|
-
if (excludeRenderBounds(child, options))
|
|
2071
|
+
if (mask === 'clipping' || mask === 'clipping-path')
|
|
2072
|
+
excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
2044
2073
|
continue;
|
|
2045
|
-
|
|
2074
|
+
}
|
|
2075
|
+
excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
|
|
2046
2076
|
}
|
|
2047
2077
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
2048
2078
|
};
|