leafer-draw 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/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
- canvas.transform(item.transform);
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
- canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
920
- data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
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
- copyWorld(canvas, out, ui);
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
- canvas.strokeStyle = item.style;
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
- canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
1000
- data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
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
- copyWorld(canvas, out, ui);
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)) && leafPaints.push(item);
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, skew: skewHelper } = 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,7 +1182,7 @@ 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, skew) {
1185
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
1156
1186
  const transform = get$3();
1157
1187
  if (rotation)
1158
1188
  rotate(transform, rotation);
@@ -1161,6 +1191,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
1161
1191
  if (scaleX)
1162
1192
  scaleHelper(transform, scaleX, scaleY);
1163
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
+ }
1164
1198
  data.transform = transform;
1165
1199
  }
1166
1200
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -1197,13 +1231,15 @@ const tempBox = new core.Bounds();
1197
1231
  const tempScaleData = {};
1198
1232
  const tempImage = {};
1199
1233
  function createData(leafPaint, image, paint, box) {
1200
- const { changeful, sync, editing } = paint;
1234
+ const { changeful, sync, editing, scaleFixed } = paint;
1201
1235
  if (changeful)
1202
1236
  leafPaint.changeful = changeful;
1203
1237
  if (sync)
1204
1238
  leafPaint.sync = sync;
1205
1239
  if (editing)
1206
1240
  leafPaint.editing = editing;
1241
+ if (scaleFixed)
1242
+ leafPaint.scaleFixed = scaleFixed;
1207
1243
  leafPaint.data = getPatternData(paint, box, image);
1208
1244
  }
1209
1245
  function getPatternData(paint, box, image) {
@@ -1212,7 +1248,7 @@ function getPatternData(paint, box, image) {
1212
1248
  if (paint.mode === 'strench')
1213
1249
  paint.mode = 'stretch';
1214
1250
  let { width, height } = image;
1215
- const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
1251
+ const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
1216
1252
  const sameBox = box.width === width && box.height === height;
1217
1253
  const data = { mode };
1218
1254
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -1246,8 +1282,8 @@ function getPatternData(paint, box, image) {
1246
1282
  break;
1247
1283
  case 'normal':
1248
1284
  case 'clip':
1249
- if (tempImage.x || tempImage.y || scaleX || rotation || skew)
1250
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
1285
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
1286
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
1251
1287
  break;
1252
1288
  case 'repeat':
1253
1289
  if (!sameBox || scaleX || rotation)
@@ -1384,18 +1420,16 @@ function ignoreRender(ui, value) {
1384
1420
  }
1385
1421
 
1386
1422
  const { get: get$1, scale, copy: copy$1 } = core.MatrixHelper;
1387
- const { ceil, abs: abs$1 } = Math;
1423
+ const { ceil, abs } = Math;
1388
1424
  function createPattern(ui, paint, pixelRatio) {
1389
- let { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1425
+ let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
1390
1426
  const id = scaleX + '-' + scaleY + '-' + pixelRatio;
1391
1427
  if (paint.patternId !== id && !ui.destroyed) {
1392
- scaleX = abs$1(scaleX);
1393
- scaleY = abs$1(scaleY);
1394
1428
  const { image, data } = paint;
1395
1429
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1396
1430
  if (sx) {
1397
- sx = abs$1(sx);
1398
- sy = abs$1(sy);
1431
+ sx = abs(sx);
1432
+ sy = abs(sy);
1399
1433
  imageMatrix = get$1();
1400
1434
  copy$1(imageMatrix, transform);
1401
1435
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -1480,9 +1514,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1480
1514
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1481
1515
  };
1482
1516
 
1483
- const { abs } = Math;
1484
1517
  function checkImage(ui, canvas, paint, allowDraw) {
1485
- const { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1518
+ const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
1486
1519
  const { pixelRatio } = canvas, { data } = paint;
1487
1520
  if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
1488
1521
  return false;
@@ -1495,8 +1528,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
1495
1528
  else {
1496
1529
  if (!(paint.changeful || core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
1497
1530
  let { width, height } = data;
1498
- width *= abs(scaleX) * pixelRatio;
1499
- height *= abs(scaleY) * pixelRatio;
1531
+ width *= scaleX * pixelRatio;
1532
+ height *= scaleY * pixelRatio;
1500
1533
  if (data.scaleX) {
1501
1534
  width *= data.scaleX;
1502
1535
  height *= data.scaleY;
@@ -1506,6 +1539,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
1506
1539
  }
1507
1540
  }
1508
1541
  if (allowDraw) {
1542
+ if (ui.__.__isFastShadow) {
1543
+ canvas.fillStyle = paint.style || '#000';
1544
+ canvas.fill();
1545
+ }
1509
1546
  drawImage(ui, canvas, paint, data);
1510
1547
  return true;
1511
1548
  }
@@ -1694,10 +1731,7 @@ function shadow(ui, current, shape) {
1694
1731
  }
1695
1732
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
1696
1733
  }
1697
- if (ui.__worldFlipped)
1698
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
1699
- else
1700
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
1734
+ core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1701
1735
  if (end && index < end)
1702
1736
  other.clearWorld(copyBounds, true);
1703
1737
  });
@@ -1756,10 +1790,7 @@ function innerShadow(ui, current, shape) {
1756
1790
  copyBounds = bounds;
1757
1791
  }
1758
1792
  other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
1759
- if (ui.__worldFlipped)
1760
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
1761
- else
1762
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
1793
+ core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1763
1794
  if (end && index < end)
1764
1795
  other.clearWorld(copyBounds, true);
1765
1796
  });
@@ -1815,12 +1846,11 @@ draw.Group.prototype.__renderMask = function (canvas, options) {
1815
1846
  contentCanvas = getCanvas(canvas);
1816
1847
  child.__render(maskCanvas, options);
1817
1848
  }
1818
- if (!(mask === 'clipping' || mask === 'clipping-path'))
1819
- continue;
1820
- }
1821
- if (excludeRenderBounds(child, options))
1849
+ if (mask === 'clipping' || mask === 'clipping-path')
1850
+ excludeRenderBounds(child, options) || child.__render(canvas, options);
1822
1851
  continue;
1823
- child.__render(contentCanvas || canvas, options);
1852
+ }
1853
+ excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
1824
1854
  }
1825
1855
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
1826
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
- canvas.transform(item.transform);
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
- canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
921
- data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
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
- copyWorld(canvas, out, ui);
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
- canvas.strokeStyle = item.style;
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
- canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
1001
- data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
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
- copyWorld(canvas, out, ui);
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)) && leafPaints.push(item);
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, skew: skewHelper } = 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,7 +1183,7 @@ 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, skew) {
1186
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
1157
1187
  const transform = get$3();
1158
1188
  if (rotation)
1159
1189
  rotate(transform, rotation);
@@ -1162,6 +1192,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
1162
1192
  if (scaleX)
1163
1193
  scaleHelper(transform, scaleX, scaleY);
1164
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
+ }
1165
1199
  data.transform = transform;
1166
1200
  }
1167
1201
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -1198,13 +1232,15 @@ const tempBox = new Bounds();
1198
1232
  const tempScaleData = {};
1199
1233
  const tempImage = {};
1200
1234
  function createData(leafPaint, image, paint, box) {
1201
- const { changeful, sync, editing } = paint;
1235
+ const { changeful, sync, editing, scaleFixed } = paint;
1202
1236
  if (changeful)
1203
1237
  leafPaint.changeful = changeful;
1204
1238
  if (sync)
1205
1239
  leafPaint.sync = sync;
1206
1240
  if (editing)
1207
1241
  leafPaint.editing = editing;
1242
+ if (scaleFixed)
1243
+ leafPaint.scaleFixed = scaleFixed;
1208
1244
  leafPaint.data = getPatternData(paint, box, image);
1209
1245
  }
1210
1246
  function getPatternData(paint, box, image) {
@@ -1213,7 +1249,7 @@ function getPatternData(paint, box, image) {
1213
1249
  if (paint.mode === 'strench')
1214
1250
  paint.mode = 'stretch';
1215
1251
  let { width, height } = image;
1216
- const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
1252
+ const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
1217
1253
  const sameBox = box.width === width && box.height === height;
1218
1254
  const data = { mode };
1219
1255
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -1247,8 +1283,8 @@ function getPatternData(paint, box, image) {
1247
1283
  break;
1248
1284
  case 'normal':
1249
1285
  case 'clip':
1250
- if (tempImage.x || tempImage.y || scaleX || rotation || skew)
1251
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
1286
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
1287
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
1252
1288
  break;
1253
1289
  case 'repeat':
1254
1290
  if (!sameBox || scaleX || rotation)
@@ -1385,18 +1421,16 @@ function ignoreRender(ui, value) {
1385
1421
  }
1386
1422
 
1387
1423
  const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
1388
- const { ceil, abs: abs$1 } = Math;
1424
+ const { ceil, abs } = Math;
1389
1425
  function createPattern(ui, paint, pixelRatio) {
1390
- let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1426
+ let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
1391
1427
  const id = scaleX + '-' + scaleY + '-' + pixelRatio;
1392
1428
  if (paint.patternId !== id && !ui.destroyed) {
1393
- scaleX = abs$1(scaleX);
1394
- scaleY = abs$1(scaleY);
1395
1429
  const { image, data } = paint;
1396
1430
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1397
1431
  if (sx) {
1398
- sx = abs$1(sx);
1399
- sy = abs$1(sy);
1432
+ sx = abs(sx);
1433
+ sy = abs(sy);
1400
1434
  imageMatrix = get$1();
1401
1435
  copy$1(imageMatrix, transform);
1402
1436
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -1481,9 +1515,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1481
1515
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1482
1516
  };
1483
1517
 
1484
- const { abs } = Math;
1485
1518
  function checkImage(ui, canvas, paint, allowDraw) {
1486
- const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1519
+ const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
1487
1520
  const { pixelRatio } = canvas, { data } = paint;
1488
1521
  if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
1489
1522
  return false;
@@ -1496,8 +1529,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
1496
1529
  else {
1497
1530
  if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
1498
1531
  let { width, height } = data;
1499
- width *= abs(scaleX) * pixelRatio;
1500
- height *= abs(scaleY) * pixelRatio;
1532
+ width *= scaleX * pixelRatio;
1533
+ height *= scaleY * pixelRatio;
1501
1534
  if (data.scaleX) {
1502
1535
  width *= data.scaleX;
1503
1536
  height *= data.scaleY;
@@ -1507,6 +1540,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
1507
1540
  }
1508
1541
  }
1509
1542
  if (allowDraw) {
1543
+ if (ui.__.__isFastShadow) {
1544
+ canvas.fillStyle = paint.style || '#000';
1545
+ canvas.fill();
1546
+ }
1510
1547
  drawImage(ui, canvas, paint, data);
1511
1548
  return true;
1512
1549
  }
@@ -1695,10 +1732,7 @@ function shadow(ui, current, shape) {
1695
1732
  }
1696
1733
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
1697
1734
  }
1698
- if (ui.__worldFlipped)
1699
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
1700
- else
1701
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
1735
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1702
1736
  if (end && index < end)
1703
1737
  other.clearWorld(copyBounds, true);
1704
1738
  });
@@ -1757,10 +1791,7 @@ function innerShadow(ui, current, shape) {
1757
1791
  copyBounds = bounds;
1758
1792
  }
1759
1793
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
1760
- if (ui.__worldFlipped)
1761
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
1762
- else
1763
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
1794
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1764
1795
  if (end && index < end)
1765
1796
  other.clearWorld(copyBounds, true);
1766
1797
  });
@@ -1816,12 +1847,11 @@ Group.prototype.__renderMask = function (canvas, options) {
1816
1847
  contentCanvas = getCanvas(canvas);
1817
1848
  child.__render(maskCanvas, options);
1818
1849
  }
1819
- if (!(mask === 'clipping' || mask === 'clipping-path'))
1820
- continue;
1821
- }
1822
- if (excludeRenderBounds(child, options))
1850
+ if (mask === 'clipping' || mask === 'clipping-path')
1851
+ excludeRenderBounds(child, options) || child.__render(canvas, options);
1823
1852
  continue;
1824
- child.__render(contentCanvas || canvas, options);
1853
+ }
1854
+ excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
1825
1855
  }
1826
1856
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
1827
1857
  };