leafer-ui 1.9.6 → 1.9.8

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.
@@ -247,18 +247,34 @@ class LeafData {
247
247
  }
248
248
  }
249
249
 
250
- const {round: round$3, pow: pow$1, PI: PI$3} = Math;
251
-
252
- const MathHelper = {
253
- within(value, min, max) {
254
- if (isObject(min)) max = min.max, min = min.min;
255
- if (!isUndefined(min) && value < min) value = min;
256
- if (!isUndefined(max) && value > max) value = max;
257
- return value;
250
+ let tempA, tempB, tempTo;
251
+
252
+ const {max: max$4} = Math, tempFour = [ 0, 0, 0, 0 ];
253
+
254
+ const FourNumberHelper = {
255
+ zero: [ ...tempFour ],
256
+ tempFour: tempFour,
257
+ set(to, top, right, bottom, left) {
258
+ if (right === undefined) right = bottom = left = top;
259
+ to[0] = top;
260
+ to[1] = right;
261
+ to[2] = bottom;
262
+ to[3] = left;
263
+ return to;
258
264
  },
259
- fourNumber(num, maxValue) {
265
+ setTemp(top, right, bottom, left) {
266
+ return set$1(tempFour, top, right, bottom, left);
267
+ },
268
+ toTempAB(a, b, change) {
269
+ tempTo = change ? isNumber(a) ? b : a : [];
270
+ if (isNumber(a)) tempA = setTemp(a), tempB = b; else if (isNumber(b)) tempA = a,
271
+ tempB = setTemp(b); else tempA = a, tempB = b;
272
+ if (tempA.length !== 4) tempA = get$5(tempA);
273
+ if (tempB.length !== 4) tempB = get$5(tempB);
274
+ },
275
+ get(num, maxValue) {
260
276
  let data;
261
- if (isArray(num)) {
277
+ if (!isNumber(num)) {
262
278
  switch (num.length) {
263
279
  case 4:
264
280
  data = isUndefined(maxValue) ? num : [ ...num ];
@@ -281,9 +297,39 @@ const MathHelper = {
281
297
  }
282
298
  }
283
299
  if (!data) data = [ num, num, num, num ];
284
- if (maxValue) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
300
+ if (!isUndefined(maxValue)) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
285
301
  return data;
286
302
  },
303
+ max(t, other, change) {
304
+ if (isNumber(t) && isNumber(other)) return max$4(t, other);
305
+ toTempAB(t, other, change);
306
+ return set$1(tempTo, max$4(tempA[0], tempB[0]), max$4(tempA[1], tempB[1]), max$4(tempA[2], tempB[2]), max$4(tempA[3], tempB[3]));
307
+ },
308
+ add(t, other, change) {
309
+ if (isNumber(t) && isNumber(other)) return t + other;
310
+ toTempAB(t, other, change);
311
+ return set$1(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
312
+ },
313
+ swapAndScale(t, scaleX, scaleY, change) {
314
+ if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [ t * scaleY, t * scaleX ];
315
+ const to = change ? t : [];
316
+ const [top, right, bottom, left] = t.length === 4 ? t : get$5(t);
317
+ return set$1(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
318
+ }
319
+ };
320
+
321
+ const {set: set$1, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
322
+
323
+ const {round: round$3, pow: pow$1, PI: PI$3} = Math;
324
+
325
+ const MathHelper = {
326
+ within(value, min, max) {
327
+ if (isObject(min)) max = min.max, min = min.min;
328
+ if (!isUndefined(min) && value < min) value = min;
329
+ if (!isUndefined(max) && value > max) value = max;
330
+ return value;
331
+ },
332
+ fourNumber: FourNumberHelper.get,
287
333
  formatRotation(rotation, unsign) {
288
334
  rotation %= 360;
289
335
  if (unsign) {
@@ -423,6 +469,15 @@ const MatrixHelper = {
423
469
  t.c *= scaleY;
424
470
  t.d *= scaleY;
425
471
  },
472
+ pixelScale(t, pixelRatio, to) {
473
+ to || (to = t);
474
+ to.a = t.a * pixelRatio;
475
+ to.b = t.b * pixelRatio;
476
+ to.c = t.c * pixelRatio;
477
+ to.d = t.d * pixelRatio;
478
+ to.e = t.e * pixelRatio;
479
+ to.f = t.f * pixelRatio;
480
+ },
426
481
  scaleOfOuter(t, origin, scaleX, scaleY) {
427
482
  M$6.toInnerPoint(t, origin, tempPoint$3);
428
483
  M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
@@ -922,6 +977,10 @@ class Matrix {
922
977
  this.scaleY *= y || x;
923
978
  return this;
924
979
  }
980
+ pixelScale(pixelRatio) {
981
+ MatrixHelper.pixelScale(this, pixelRatio);
982
+ return this;
983
+ }
925
984
  scaleOfOuter(origin, x, y) {
926
985
  MatrixHelper.scaleOfOuter(this, origin, x, y);
927
986
  return this;
@@ -1001,7 +1060,7 @@ class Matrix {
1001
1060
  }
1002
1061
  }
1003
1062
 
1004
- const tempMatrix$1 = new Matrix;
1063
+ const tempMatrix$2 = new Matrix;
1005
1064
 
1006
1065
  const TwoPointBoundsHelper = {
1007
1066
  tempPointBounds: {},
@@ -1151,10 +1210,10 @@ const point = {};
1151
1210
 
1152
1211
  const toPoint$4 = {};
1153
1212
 
1154
- const tempBounds$2 = {};
1213
+ const tempBounds$3 = {};
1155
1214
 
1156
1215
  const BoundsHelper = {
1157
- tempBounds: tempBounds$2,
1216
+ tempBounds: tempBounds$3,
1158
1217
  set(t, x = 0, y = 0, width = 0, height = 0) {
1159
1218
  t.x = x;
1160
1219
  t.y = y;
@@ -1205,19 +1264,11 @@ const BoundsHelper = {
1205
1264
  B.move(t, x, y);
1206
1265
  return t;
1207
1266
  },
1208
- toOffsetOutBounds(t, to, parent) {
1209
- if (!to) {
1210
- to = t;
1211
- } else {
1212
- copy$9(to, t);
1213
- }
1214
- if (parent) {
1215
- to.offsetX = -(B.maxX(parent) - t.x);
1216
- to.offsetY = -(B.maxY(parent) - t.y);
1217
- } else {
1218
- to.offsetX = t.x + t.width;
1219
- to.offsetY = t.y + t.height;
1220
- }
1267
+ toOffsetOutBounds(t, to, offsetBounds) {
1268
+ if (!to) to = t; else copy$9(to, t);
1269
+ if (!offsetBounds) offsetBounds = t;
1270
+ to.offsetX = B.maxX(offsetBounds);
1271
+ to.offsetY = B.maxY(offsetBounds);
1221
1272
  B.move(to, -to.offsetX, -to.offsetY);
1222
1273
  },
1223
1274
  scale(t, scaleX, scaleY = scaleX, onlySize) {
@@ -1231,9 +1282,9 @@ const BoundsHelper = {
1231
1282
  t.height *= scaleY;
1232
1283
  },
1233
1284
  tempToOuterOf(t, matrix) {
1234
- B.copy(tempBounds$2, t);
1235
- B.toOuterOf(tempBounds$2, matrix);
1236
- return tempBounds$2;
1285
+ B.copy(tempBounds$3, t);
1286
+ B.toOuterOf(tempBounds$3, matrix);
1287
+ return tempBounds$3;
1237
1288
  },
1238
1289
  getOuterOf(t, matrix) {
1239
1290
  t = Object.assign({}, t);
@@ -1291,9 +1342,9 @@ const BoundsHelper = {
1291
1342
  put(t, put, align = "center", putScale = 1, changeSize = true, to) {
1292
1343
  to || (to = put);
1293
1344
  if (isString(putScale)) putScale = B.getFitScale(t, put, putScale === "cover");
1294
- tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
1295
- tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
1296
- AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
1345
+ tempBounds$3.width = changeSize ? put.width *= putScale : put.width * putScale;
1346
+ tempBounds$3.height = changeSize ? put.height *= putScale : put.height * putScale;
1347
+ AlignHelper.toPoint(align, tempBounds$3, t, to, true, true);
1297
1348
  },
1298
1349
  getSpread(t, spread, side) {
1299
1350
  const n = {};
@@ -1363,7 +1414,7 @@ const BoundsHelper = {
1363
1414
  first = false;
1364
1415
  if (!addMode) copy$9(t, bounds);
1365
1416
  } else {
1366
- add$1(t, bounds);
1417
+ add$2(t, bounds);
1367
1418
  }
1368
1419
  }
1369
1420
  }
@@ -1377,7 +1428,7 @@ const BoundsHelper = {
1377
1428
  B.set(t, point.x, point.y);
1378
1429
  },
1379
1430
  addPoint(t, point) {
1380
- add$1(t, point, true);
1431
+ add$2(t, point, true);
1381
1432
  },
1382
1433
  getPoints(t) {
1383
1434
  const {x: x, y: y, width: width, height: height} = t;
@@ -1448,7 +1499,7 @@ const BoundsHelper = {
1448
1499
 
1449
1500
  const B = BoundsHelper;
1450
1501
 
1451
- const {add: add$1, copy: copy$9} = B;
1502
+ const {add: add$2, copy: copy$9} = B;
1452
1503
 
1453
1504
  class Bounds {
1454
1505
  get minX() {
@@ -1593,7 +1644,7 @@ class Bounds {
1593
1644
  }
1594
1645
  }
1595
1646
 
1596
- const tempBounds$1 = new Bounds;
1647
+ const tempBounds$2 = new Bounds;
1597
1648
 
1598
1649
  class AutoBounds {
1599
1650
  constructor(top, right, bottom, left, width, height) {
@@ -2146,7 +2197,7 @@ __decorate([ contextMethod() ], Canvas$1.prototype, "measureText", null);
2146
2197
 
2147
2198
  __decorate([ contextMethod() ], Canvas$1.prototype, "strokeText", null);
2148
2199
 
2149
- const {copy: copy$8, multiplyParent: multiplyParent$4} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2200
+ const {copy: copy$8, multiplyParent: multiplyParent$4, pixelScale: pixelScale} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2150
2201
 
2151
2202
  const minSize = {
2152
2203
  width: 1,
@@ -2247,13 +2298,8 @@ class LeaferCanvasBase extends Canvas$1 {
2247
2298
  setWorld(matrix, parentMatrix) {
2248
2299
  const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
2249
2300
  if (parentMatrix) multiplyParent$4(matrix, parentMatrix, w);
2250
- w.a = matrix.a * pixelRatio;
2251
- w.b = matrix.b * pixelRatio;
2252
- w.c = matrix.c * pixelRatio;
2253
- w.d = matrix.d * pixelRatio;
2254
- w.e = matrix.e * pixelRatio;
2255
- w.f = matrix.f * pixelRatio;
2256
- if (pixelSnap) {
2301
+ pixelScale(matrix, pixelRatio, w);
2302
+ if (pixelSnap && !matrix.ignorePixelSnap) {
2257
2303
  if (matrix.half && matrix.half * pixelRatio % 2) w.e = round$1(w.e - .5) + .5, w.f = round$1(w.f - .5) + .5; else w.e = round$1(w.e),
2258
2304
  w.f = round$1(w.f);
2259
2305
  }
@@ -3977,7 +4023,7 @@ const I$1 = ImageManager;
3977
4023
 
3978
4024
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3979
4025
 
3980
- const {floor: floor$1, max: max$1} = Math;
4026
+ const {floor: floor$1, max: max$3} = Math;
3981
4027
 
3982
4028
  class LeaferImage {
3983
4029
  get url() {
@@ -4066,7 +4112,7 @@ class LeaferImage {
4066
4112
  }
4067
4113
  if (data) return data;
4068
4114
  }
4069
- const canvas = Platform.origin.createCanvas(max$1(floor$1(width + (xGap || 0)), 1), max$1(floor$1(height + (yGap || 0)), 1));
4115
+ const canvas = Platform.origin.createCanvas(max$3(floor$1(width + (xGap || 0)), 1), max$3(floor$1(height + (yGap || 0)), 1));
4070
4116
  const ctx = canvas.getContext("2d");
4071
4117
  if (opacity) ctx.globalAlpha = opacity;
4072
4118
  ctx.imageSmoothingEnabled = smooth === false ? false : true;
@@ -4265,6 +4311,18 @@ function surfaceType(defaultValue) {
4265
4311
  }));
4266
4312
  }
4267
4313
 
4314
+ function dimType(defaultValue) {
4315
+ return decorateLeafAttr(defaultValue, key => attr({
4316
+ set(value) {
4317
+ if (this.__setAttr(key, value)) {
4318
+ const data = this.__;
4319
+ DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
4320
+ this.__layout.surfaceChange();
4321
+ }
4322
+ }
4323
+ }));
4324
+ }
4325
+
4268
4326
  function opacityType(defaultValue) {
4269
4327
  return decorateLeafAttr(defaultValue, key => attr({
4270
4328
  set(value) {
@@ -4309,7 +4367,7 @@ function sortType(defaultValue) {
4309
4367
  return decorateLeafAttr(defaultValue, key => attr({
4310
4368
  set(value) {
4311
4369
  if (this.__setAttr(key, value)) {
4312
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
4370
+ this.__layout.surfaceChange();
4313
4371
  this.waitParent(() => {
4314
4372
  this.parent.__layout.childrenSortChange();
4315
4373
  });
@@ -4346,7 +4404,7 @@ function hitType(defaultValue) {
4346
4404
  set(value) {
4347
4405
  if (this.__setAttr(key, value)) {
4348
4406
  this.__layout.hitCanvasChanged = true;
4349
- if (Debug.showBounds === "hit") this.__layout.surfaceChanged || this.__layout.surfaceChange();
4407
+ if (Debug.showBounds === "hit") this.__layout.surfaceChange();
4350
4408
  if (this.leafer) this.leafer.updateCursor();
4351
4409
  }
4352
4410
  }
@@ -4848,7 +4906,7 @@ const WaitHelper = {
4848
4906
 
4849
4907
  const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2} = LeafHelper;
4850
4908
 
4851
- const {toOuterOf: toOuterOf$2, getPoints: getPoints, copy: copy$5} = BoundsHelper;
4909
+ const {toOuterOf: toOuterOf$3, getPoints: getPoints, copy: copy$5} = BoundsHelper;
4852
4910
 
4853
4911
  const localContent = "_localContentBounds";
4854
4912
 
@@ -4871,7 +4929,7 @@ class LeafLayout {
4871
4929
  this._renderBounds = bounds;
4872
4930
  }
4873
4931
  get localContentBounds() {
4874
- toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
4932
+ toOuterOf$3(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
4875
4933
  return this[localContent];
4876
4934
  }
4877
4935
  get localStrokeBounds() {
@@ -4881,15 +4939,15 @@ class LeafLayout {
4881
4939
  return this._localRenderBounds || this;
4882
4940
  }
4883
4941
  get worldContentBounds() {
4884
- toOuterOf$2(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
4942
+ toOuterOf$3(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
4885
4943
  return this[worldContent];
4886
4944
  }
4887
4945
  get worldBoxBounds() {
4888
- toOuterOf$2(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
4946
+ toOuterOf$3(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
4889
4947
  return this[worldBox];
4890
4948
  }
4891
4949
  get worldStrokeBounds() {
4892
- toOuterOf$2(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
4950
+ toOuterOf$3(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
4893
4951
  return this[worldStroke];
4894
4952
  }
4895
4953
  get a() {
@@ -5741,14 +5799,14 @@ const {updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2} = LeafH
5741
5799
 
5742
5800
  const {updateBounds: updateBounds$1} = BranchHelper;
5743
5801
 
5744
- const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4} = BoundsHelper;
5802
+ const {toOuterOf: toOuterOf$2, copyAndSpread: copyAndSpread$2, copy: copy$4} = BoundsHelper;
5745
5803
 
5746
5804
  const {toBounds: toBounds} = PathBounds;
5747
5805
 
5748
5806
  const LeafBounds = {
5749
5807
  __updateWorldBounds() {
5750
5808
  const layout = this.__layout;
5751
- toOuterOf$1(layout.renderBounds, this.__world, this.__world);
5809
+ toOuterOf$2(layout.renderBounds, this.__world, this.__world);
5752
5810
  if (layout.resized) {
5753
5811
  if (layout.resized === "inner") this.__onUpdateSize();
5754
5812
  if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
@@ -5804,13 +5862,13 @@ const LeafBounds = {
5804
5862
  __updateLocalBoxBounds() {
5805
5863
  if (this.__hasMotionPath) this.__updateMotionPath();
5806
5864
  if (this.__hasAutoLayout) this.__updateAutoLayout();
5807
- toOuterOf$1(this.__layout.boxBounds, this.__local, this.__local);
5865
+ toOuterOf$2(this.__layout.boxBounds, this.__local, this.__local);
5808
5866
  },
5809
5867
  __updateLocalStrokeBounds() {
5810
- toOuterOf$1(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5868
+ toOuterOf$2(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5811
5869
  },
5812
5870
  __updateLocalRenderBounds() {
5813
- toOuterOf$1(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5871
+ toOuterOf$2(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5814
5872
  },
5815
5873
  __updateBoxBounds(_secondLayout, _bounds) {
5816
5874
  const b = this.__layout.boxBounds;
@@ -5848,11 +5906,11 @@ const LeafBounds = {
5848
5906
  },
5849
5907
  __updateStrokeBounds(_bounds) {
5850
5908
  const layout = this.__layout;
5851
- copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5909
+ copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5852
5910
  },
5853
5911
  __updateRenderBounds(_bounds) {
5854
- const layout = this.__layout;
5855
- layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$4(layout.renderBounds, layout.strokeBounds);
5912
+ const layout = this.__layout, {renderSpread: renderSpread} = layout;
5913
+ isNumber(renderSpread) && renderSpread <= 0 ? copy$4(layout.renderBounds, layout.strokeBounds) : copyAndSpread$2(layout.renderBounds, layout.boxBounds, renderSpread);
5856
5914
  }
5857
5915
  };
5858
5916
 
@@ -5861,6 +5919,7 @@ const LeafRender = {
5861
5919
  if (options.shape) return this.__renderShape(canvas, options);
5862
5920
  if (this.__worldOpacity) {
5863
5921
  const data = this.__;
5922
+ if (data.bright && !options.topRendering) return options.topList.add(this);
5864
5923
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5865
5924
  canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5866
5925
  if (this.__.__single) {
@@ -5909,7 +5968,9 @@ const BranchRender = {
5909
5968
  this.__nowWorld = this.__getNowWorld(options);
5910
5969
  if (this.__worldOpacity) {
5911
5970
  const data = this.__;
5912
- if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5971
+ if (data.__useDim) {
5972
+ if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5973
+ }
5913
5974
  if (data.__single && !this.isBranchLeaf) {
5914
5975
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5915
5976
  const tempCanvas = canvas.getSameCanvas(false, true);
@@ -5947,11 +6008,13 @@ const tempScaleData$1 = {};
5947
6008
 
5948
6009
  const {LEAF: LEAF, create: create} = IncrementId;
5949
6010
 
6011
+ const {stintSet: stintSet$3} = DataHelper;
6012
+
5950
6013
  const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
5951
6014
 
5952
- const {toOuterOf: toOuterOf} = BoundsHelper;
6015
+ const {toOuterOf: toOuterOf$1} = BoundsHelper;
5953
6016
 
5954
- const {copy: copy$3, move: move} = PointHelper;
6017
+ const {copy: copy$3, move: move$2} = PointHelper;
5955
6018
 
5956
6019
  const {moveLocal: moveLocal, zoomOfLocal: zoomOfLocal, rotateOfLocal: rotateOfLocal, skewOfLocal: skewOfLocal, moveWorld: moveWorld, zoomOfWorld: zoomOfWorld, rotateOfWorld: rotateOfWorld, skewOfWorld: skewOfWorld, transform: transform, transformWorld: transformWorld, setTransform: setTransform, getFlipTransform: getFlipTransform, getLocalOrigin: getLocalOrigin, getRelativeWorld: getRelativeWorld, drop: drop} = LeafHelper;
5957
6020
 
@@ -6227,8 +6290,9 @@ let Leaf = class Leaf {
6227
6290
  if (!this.__cameraWorld) this.__cameraWorld = {};
6228
6291
  const cameraWorld = this.__cameraWorld, world = this.__world;
6229
6292
  multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
6230
- toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
6231
- cameraWorld.half !== world.half && (cameraWorld.half = world.half);
6293
+ toOuterOf$1(this.__layout.renderBounds, cameraWorld, cameraWorld);
6294
+ stintSet$3(cameraWorld, "half", world.half);
6295
+ stintSet$3(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
6232
6296
  return cameraWorld;
6233
6297
  } else {
6234
6298
  return this.__world;
@@ -6262,7 +6326,7 @@ let Leaf = class Leaf {
6262
6326
  getWorldBounds(inner, relative, change) {
6263
6327
  const matrix = relative ? getRelativeWorld(this, relative) : this.worldTransform;
6264
6328
  const to = change ? inner : {};
6265
- toOuterOf(inner, matrix, to);
6329
+ toOuterOf$1(inner, matrix, to);
6266
6330
  return to;
6267
6331
  }
6268
6332
  worldToLocal(world, to, distance, relative) {
@@ -6295,7 +6359,7 @@ let Leaf = class Leaf {
6295
6359
  }
6296
6360
  getBoxPointByInner(inner, _relative, _distance, change) {
6297
6361
  const point = change ? inner : Object.assign({}, inner), {x: x, y: y} = this.boxBounds;
6298
- move(point, -x, -y);
6362
+ move$2(point, -x, -y);
6299
6363
  return point;
6300
6364
  }
6301
6365
  getInnerPoint(world, relative, distance, change) {
@@ -6305,7 +6369,7 @@ let Leaf = class Leaf {
6305
6369
  }
6306
6370
  getInnerPointByBox(box, _relative, _distance, change) {
6307
6371
  const point = change ? box : Object.assign({}, box), {x: x, y: y} = this.boxBounds;
6308
- move(point, x, y);
6372
+ move$2(point, x, y);
6309
6373
  return point;
6310
6374
  }
6311
6375
  getInnerPointByLocal(local, _relative, distance, change) {
@@ -6751,7 +6815,7 @@ class LeafLevelList {
6751
6815
  }
6752
6816
  }
6753
6817
 
6754
- const version = "1.9.6";
6818
+ const version = "1.9.8";
6755
6819
 
6756
6820
  const debug$5 = Debug.get("LeaferCanvas");
6757
6821
 
@@ -6786,7 +6850,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6786
6850
  }
6787
6851
  if (Platform.syncDomFont && !this.parentView) {
6788
6852
  style.display = "none";
6789
- document.body.appendChild(this.view);
6853
+ if (document.body) document.body.appendChild(this.view);
6790
6854
  }
6791
6855
  this.__createContext();
6792
6856
  if (!this.autoLayout) this.resize(config);
@@ -7382,6 +7446,7 @@ class Renderer {
7382
7446
  usePartRender: true,
7383
7447
  maxFPS: 120
7384
7448
  };
7449
+ this.frames = [];
7385
7450
  this.target = target;
7386
7451
  this.canvas = canvas;
7387
7452
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -7511,7 +7576,7 @@ class Renderer {
7511
7576
  };
7512
7577
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
7513
7578
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
7514
- this.target.__render(canvas, options);
7579
+ Platform.render(this.target, canvas, options);
7515
7580
  this.renderBounds = realBounds = realBounds || bounds;
7516
7581
  this.renderOptions = options;
7517
7582
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
@@ -7534,12 +7599,15 @@ class Renderer {
7534
7599
  const target = this.target;
7535
7600
  if (this.requestTime || !target) return;
7536
7601
  if (target.parentApp) return target.parentApp.requestRender(false);
7537
- const requestTime = this.requestTime = Date.now();
7602
+ this.requestTime = this.frameTime || Date.now();
7538
7603
  const render = () => {
7539
- const nowFPS = 1e3 / (Date.now() - requestTime);
7604
+ const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
7540
7605
  const {maxFPS: maxFPS} = this.config;
7541
- if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7542
- this.FPS = Math.min(120, Math.ceil(nowFPS));
7606
+ if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
7607
+ const {frames: frames} = this;
7608
+ if (frames.length > 30) frames.shift();
7609
+ frames.push(nowFPS);
7610
+ this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
7543
7611
  this.requestTime = 0;
7544
7612
  this.checkRender();
7545
7613
  };
@@ -7787,6 +7855,15 @@ Object.assign(Creator, {
7787
7855
 
7788
7856
  Platform.layout = Layouter.fullLayout;
7789
7857
 
7858
+ Platform.render = function(target, canvas, options) {
7859
+ const topOptions = Object.assign(Object.assign({}, options), {
7860
+ topRendering: true
7861
+ });
7862
+ options.topList = new LeafList;
7863
+ target.__render(canvas, options);
7864
+ if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
7865
+ };
7866
+
7790
7867
  function effectType(defaultValue) {
7791
7868
  return decorateLeafAttr(defaultValue, key => attr({
7792
7869
  set(value) {
@@ -8186,39 +8263,41 @@ class CanvasData extends RectData {
8186
8263
  }
8187
8264
  }
8188
8265
 
8266
+ const {max: max$2, add: add$1} = FourNumberHelper;
8267
+
8189
8268
  const UIBounds = {
8190
8269
  __updateStrokeSpread() {
8191
- let width = 0, boxWidth = 0;
8270
+ let spread = 0, boxSpread = 0;
8192
8271
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
8193
8272
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
8194
- boxWidth = width = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
8273
+ boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
8195
8274
  if (!data.__boxStroke) {
8196
- const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * width;
8275
+ const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
8197
8276
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
8198
- width += Math.max(miterLimitAddWidth, storkeCapAddWidth);
8277
+ spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
8199
8278
  }
8200
8279
  }
8201
- if (data.__useArrow) width += strokeWidth * 5;
8280
+ if (data.__useArrow) spread += strokeWidth * 5;
8202
8281
  if (box) {
8203
- width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
8204
- boxWidth = box.__layout.strokeBoxSpread;
8282
+ spread = max$2(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
8283
+ boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
8205
8284
  }
8206
- this.__layout.strokeBoxSpread = boxWidth;
8207
- return width;
8285
+ this.__layout.strokeBoxSpread = boxSpread;
8286
+ return spread;
8208
8287
  },
8209
8288
  __updateRenderSpread() {
8210
- let width = 0;
8211
- const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
8212
- if (shadow) width = Effect.getShadowSpread(this, shadow);
8213
- if (blur) width = Math.max(width, blur);
8214
- if (filter) width += Filter.getSpread(filter);
8215
- if (renderSpread) width += renderSpread;
8216
- let shapeWidth = width = Math.ceil(width);
8217
- if (innerShadow) innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
8218
- if (backgroundBlur) shapeWidth = Math.max(shapeWidth, backgroundBlur);
8219
- this.__layout.renderShapeSpread = shapeWidth;
8220
- width += this.__layout.strokeSpread || 0;
8221
- return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
8289
+ let spread = 0;
8290
+ const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
8291
+ if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
8292
+ if (blur) spread = max$2(spread, blur);
8293
+ if (filter) spread = add$1(spread, Filter.getSpread(filter));
8294
+ if (renderSpread) spread = add$1(spread, renderSpread);
8295
+ if (strokeSpread) spread = add$1(spread, strokeSpread);
8296
+ let shapeSpread = spread;
8297
+ if (innerShadow) shapeSpread = max$2(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
8298
+ if (backgroundBlur) shapeSpread = max$2(shapeSpread, backgroundBlur);
8299
+ this.__layout.renderShapeSpread = shapeSpread;
8300
+ return box ? max$2(box.__updateRenderSpread(), spread) : spread;
8222
8301
  }
8223
8302
  };
8224
8303
 
@@ -8562,9 +8641,9 @@ __decorate([ visibleType(true) ], UI.prototype, "visible", void 0);
8562
8641
 
8563
8642
  __decorate([ surfaceType(false) ], UI.prototype, "locked", void 0);
8564
8643
 
8565
- __decorate([ surfaceType(false) ], UI.prototype, "dim", void 0);
8644
+ __decorate([ dimType(false) ], UI.prototype, "dim", void 0);
8566
8645
 
8567
- __decorate([ surfaceType(false) ], UI.prototype, "dimskip", void 0);
8646
+ __decorate([ dimType(false) ], UI.prototype, "dimskip", void 0);
8568
8647
 
8569
8648
  __decorate([ sortType(0) ], UI.prototype, "zIndex", void 0);
8570
8649
 
@@ -9529,7 +9608,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
9529
9608
 
9530
9609
  Canvas = __decorate([ registerUI() ], Canvas);
9531
9610
 
9532
- const {copyAndSpread: copyAndSpread, includes: includes, spread: spread, setList: setList} = BoundsHelper;
9611
+ const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
9533
9612
 
9534
9613
  let Text = class Text extends UI {
9535
9614
  get __tag() {
@@ -9576,13 +9655,13 @@ let Text = class Text extends UI {
9576
9655
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9577
9656
  }
9578
9657
  __updateRenderSpread() {
9579
- let width = super.__updateRenderSpread();
9580
- if (!width) width = this.isOverflow ? 1 : 0;
9581
- return width;
9658
+ let spread = super.__updateRenderSpread();
9659
+ if (!spread) spread = this.isOverflow ? 1 : 0;
9660
+ return spread;
9582
9661
  }
9583
9662
  __updateRenderBounds() {
9584
9663
  const {renderBounds: renderBounds, renderSpread: renderSpread} = this.__layout;
9585
- copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
9664
+ copyAndSpread$1(renderBounds, this.__.__textBoxBounds, renderSpread);
9586
9665
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
9587
9666
  }
9588
9667
  __updateChange() {
@@ -10008,9 +10087,9 @@ let DragEvent$1 = class DragEvent extends PointerEvent$1 {
10008
10087
  static setData(data) {
10009
10088
  this.data = data;
10010
10089
  }
10011
- static getValidMove(leaf, start, total, checkLimit = true) {
10012
- const move = leaf.getLocalPoint(total, null, true);
10013
- PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
10090
+ static getValidMove(leaf, localStart, worldTotal, checkLimit = true) {
10091
+ const move = leaf.getLocalPoint(worldTotal, null, true);
10092
+ PointHelper.move(move, localStart.x - leaf.x, localStart.y - leaf.y);
10014
10093
  if (checkLimit) this.limitMove(leaf, move);
10015
10094
  DragBoundsHelper.axisMove(leaf, move);
10016
10095
  return move;
@@ -11040,8 +11119,8 @@ ui$1.__updateHitCanvas = function() {
11040
11119
  if (isHitPixel) {
11041
11120
  const {renderBounds: renderBounds} = this.__layout;
11042
11121
  const size = Platform.image.hitCanvasSize;
11043
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
11044
- const {x: x, y: y, width: width, height: height} = tempBounds$1.set(renderBounds).scale(scale);
11122
+ const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
11123
+ const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
11045
11124
  h.resize({
11046
11125
  width: width,
11047
11126
  height: height,
@@ -11138,8 +11217,8 @@ canvas.hitStroke = function(point, strokeWidth) {
11138
11217
  canvas.hitPixel = function(radiusPoint, offset, scale = 1) {
11139
11218
  let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
11140
11219
  if (offset) x -= offset.x, y -= offset.y;
11141
- tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11142
- const {data: data} = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
11220
+ tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11221
+ const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
11143
11222
  for (let i = 0, len = data.length; i < len; i += 4) {
11144
11223
  if (data[i + 3] > 0) return true;
11145
11224
  }
@@ -11667,24 +11746,29 @@ function drawOutside(stroke, ui, canvas) {
11667
11746
  }
11668
11747
  }
11669
11748
 
11670
- const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
11749
+ const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
11750
+
11751
+ const tempBounds$1 = {};
11671
11752
 
11672
11753
  function shape(ui, current, options) {
11673
11754
  const canvas = current.getSameCanvas();
11674
- const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
11675
- let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
11755
+ const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
11756
+ const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
11757
+ toOuterOf(layout.strokeSpread ? (copyAndSpread(tempBounds$1, layout.boxBounds, layout.strokeSpread),
11758
+ tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
11759
+ let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
11676
11760
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
11677
- if (currentBounds.includes(nowWorld)) {
11761
+ if (currentBounds.includes(nowWorldShapeBounds)) {
11678
11762
  worldCanvas = canvas;
11679
- bounds = shapeBounds = nowWorld;
11763
+ bounds = shapeBounds = nowWorldShapeBounds;
11764
+ renderBounds = nowWorld;
11680
11765
  } else {
11681
- const {renderShapeSpread: spread} = ui.__layout;
11682
11766
  let worldClipBounds;
11683
11767
  if (Platform.fullImageShadow) {
11684
- worldClipBounds = nowWorld;
11768
+ worldClipBounds = nowWorldShapeBounds;
11685
11769
  } else {
11686
- const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
11687
- worldClipBounds = getIntersectData(spreadBounds, nowWorld);
11770
+ const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
11771
+ worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
11688
11772
  }
11689
11773
  fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
11690
11774
  let {a: fitScaleX, d: fitScaleY} = fitMatrix;
@@ -11694,8 +11778,10 @@ function shape(ui, current, options) {
11694
11778
  scaleX *= fitScaleX;
11695
11779
  scaleY *= fitScaleY;
11696
11780
  }
11697
- shapeBounds = getOuterOf(nowWorld, fitMatrix);
11781
+ shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
11698
11782
  bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
11783
+ renderBounds = getOuterOf(nowWorld, fitMatrix);
11784
+ move$1(renderBounds, -fitMatrix.e, -fitMatrix.f);
11699
11785
  const userMatrix = options.matrix;
11700
11786
  if (userMatrix) {
11701
11787
  matrix = new Matrix(fitMatrix);
@@ -11714,6 +11800,7 @@ function shape(ui, current, options) {
11714
11800
  matrix: matrix,
11715
11801
  fitMatrix: fitMatrix,
11716
11802
  bounds: bounds,
11803
+ renderBounds: renderBounds,
11717
11804
  worldCanvas: worldCanvas,
11718
11805
  shapeBounds: shapeBounds,
11719
11806
  scaleX: scaleX,
@@ -11817,7 +11904,7 @@ const PaintModule = {
11817
11904
  shape: shape
11818
11905
  };
11819
11906
 
11820
- let origin = {}, tempMatrix = getMatrixData();
11907
+ let origin = {}, tempMatrix$1 = getMatrixData();
11821
11908
 
11822
11909
  const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
11823
11910
 
@@ -11832,12 +11919,12 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
11832
11919
  data.transform = transform;
11833
11920
  }
11834
11921
 
11835
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
11922
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
11836
11923
  const transform = get$3();
11837
11924
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
11838
- if (clipSize) {
11839
- tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
11840
- multiplyParent(transform, tempMatrix);
11925
+ if (clipScaleX) {
11926
+ tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
11927
+ multiplyParent(transform, tempMatrix$1);
11841
11928
  }
11842
11929
  data.transform = transform;
11843
11930
  }
@@ -11938,7 +12025,12 @@ function getPatternData(paint, box, image) {
11938
12025
 
11939
12026
  case "normal":
11940
12027
  case "clip":
11941
- if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
12028
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
12029
+ let clipScaleX, clipScaleY;
12030
+ if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
12031
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
12032
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
12033
+ }
11942
12034
  break;
11943
12035
 
11944
12036
  case "repeat":
@@ -12096,7 +12188,7 @@ function ignoreRender(ui, value) {
12096
12188
 
12097
12189
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
12098
12190
 
12099
- const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
12191
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
12100
12192
 
12101
12193
  function createPattern(ui, paint, pixelRatio) {
12102
12194
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -12145,8 +12237,8 @@ function createPattern(ui, paint, pixelRatio) {
12145
12237
  if (transform || scaleX !== 1 || scaleY !== 1) {
12146
12238
  const canvasWidth = width + (xGap || 0);
12147
12239
  const canvasHeight = height + (yGap || 0);
12148
- scaleX /= canvasWidth / max(floor(canvasWidth), 1);
12149
- scaleY /= canvasHeight / max(floor(canvasHeight), 1);
12240
+ scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
12241
+ scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
12150
12242
  if (!imageMatrix) {
12151
12243
  imageMatrix = get$1();
12152
12244
  if (transform) copy$1(imageMatrix, transform);
@@ -12172,17 +12264,15 @@ function checkImage(ui, canvas, paint, allowDraw) {
12172
12264
  if (allowDraw) {
12173
12265
  if (data.repeat) {
12174
12266
  allowDraw = false;
12175
- } else {
12176
- if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
12177
- let {width: width, height: height} = data;
12178
- width *= scaleX * pixelRatio;
12179
- height *= scaleY * pixelRatio;
12180
- if (data.scaleX) {
12181
- width *= data.scaleX;
12182
- height *= data.scaleY;
12183
- }
12184
- allowDraw = width * height > Platform.image.maxCacheSize;
12267
+ } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
12268
+ let {width: width, height: height} = data;
12269
+ width *= scaleX * pixelRatio;
12270
+ height *= scaleY * pixelRatio;
12271
+ if (data.scaleX) {
12272
+ width *= data.scaleX;
12273
+ height *= data.scaleY;
12185
12274
  }
12275
+ allowDraw = width * height > Platform.image.maxCacheSize;
12186
12276
  }
12187
12277
  }
12188
12278
  if (allowDraw) {
@@ -12362,20 +12452,20 @@ const PaintGradientModule = {
12362
12452
  getTransform: getTransform
12363
12453
  };
12364
12454
 
12365
- const {copy: copy, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
12455
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
12366
12456
 
12367
- const tempBounds = {};
12457
+ const tempBounds = {}, tempMatrix = new Matrix;
12368
12458
 
12369
12459
  const offsetOutBounds$1 = {};
12370
12460
 
12371
12461
  function shadow(ui, current, shape) {
12372
- let copyBounds, spreadScale;
12373
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
12462
+ let copyBounds, transform;
12463
+ const {__nowWorld: nowWorld} = ui;
12374
12464
  const {shadow: shadow} = ui.__;
12375
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
12465
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
12376
12466
  const other = current.getSameCanvas();
12377
12467
  const end = shadow.length - 1;
12378
- toOffsetOutBounds$1(bounds, offsetOutBounds$1);
12468
+ toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
12379
12469
  shadow.forEach((item, index) => {
12380
12470
  let otherScale = 1;
12381
12471
  if (item.scaleFixed) {
@@ -12383,54 +12473,61 @@ function shadow(ui, current, shape) {
12383
12473
  if (sx > 1) otherScale = 1 / sx;
12384
12474
  }
12385
12475
  other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
12386
- spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
12387
- drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
12388
- copyBounds = bounds;
12476
+ transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
12477
+ if (transform) other.setTransform(transform);
12478
+ drawWorldShadow(other, offsetOutBounds$1, shape);
12479
+ if (transform) other.resetTransform();
12480
+ copyBounds = renderBounds;
12389
12481
  if (item.box) {
12390
12482
  other.restore();
12391
12483
  other.save();
12392
12484
  if (worldCanvas) {
12393
- other.copyWorld(other, bounds, nowWorld, "copy");
12485
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
12394
12486
  copyBounds = nowWorld;
12395
12487
  }
12396
12488
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
12397
12489
  }
12398
- if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
12490
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
12399
12491
  if (end && index < end) other.clearWorld(copyBounds);
12400
12492
  });
12401
12493
  other.recycle(copyBounds);
12402
12494
  }
12403
12495
 
12404
- function getShadowSpread(_ui, shadow) {
12405
- let width = 0;
12406
- shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
12407
- return width;
12496
+ function getShadowRenderSpread(_ui, shadow) {
12497
+ let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
12498
+ shadow.forEach(item => {
12499
+ x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
12500
+ top = max(top, spread + blur - y);
12501
+ right = max(right, spread + blur + x);
12502
+ bottom = max(bottom, spread + blur + y);
12503
+ left = max(left, spread + blur - x);
12504
+ });
12505
+ return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
12506
+ }
12507
+
12508
+ function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
12509
+ if (shadow.spread) {
12510
+ const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
12511
+ tempMatrix.set().scaleOfOuter({
12512
+ x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
12513
+ y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
12514
+ }, spreadScale);
12515
+ return tempMatrix;
12516
+ }
12517
+ return undefined;
12408
12518
  }
12409
12519
 
12410
- function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
12411
- const {bounds: bounds, shapeBounds: shapeBounds} = shape;
12520
+ function drawWorldShadow(canvas, outBounds, shape) {
12521
+ const {shapeBounds: shapeBounds} = shape;
12522
+ let from, to;
12412
12523
  if (Platform.fullImageShadow) {
12413
12524
  copy(tempBounds, canvas.bounds);
12414
- tempBounds.x += outBounds.x - shapeBounds.x;
12415
- tempBounds.y += outBounds.y - shapeBounds.y;
12416
- if (spreadScale) {
12417
- const {fitMatrix: fitMatrix} = shape;
12418
- tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
12419
- tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
12420
- tempBounds.width *= spreadScale;
12421
- tempBounds.height *= spreadScale;
12422
- }
12423
- canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
12525
+ move(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
12526
+ from = canvas.bounds, to = tempBounds;
12424
12527
  } else {
12425
- if (spreadScale) {
12426
- copy(tempBounds, outBounds);
12427
- tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
12428
- tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
12429
- tempBounds.width *= spreadScale;
12430
- tempBounds.height *= spreadScale;
12431
- }
12432
- canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
12528
+ from = shapeBounds, to = outBounds;
12433
12529
  }
12530
+ canvas.copyWorld(shape.canvas, from, to);
12434
12531
  }
12435
12532
 
12436
12533
  const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
@@ -12438,13 +12535,13 @@ const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
12438
12535
  const offsetOutBounds = {};
12439
12536
 
12440
12537
  function innerShadow(ui, current, shape) {
12441
- let copyBounds, spreadScale;
12442
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
12538
+ let copyBounds, transform;
12539
+ const {__nowWorld: nowWorld} = ui;
12443
12540
  const {innerShadow: innerShadow} = ui.__;
12444
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
12541
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
12445
12542
  const other = current.getSameCanvas();
12446
12543
  const end = innerShadow.length - 1;
12447
- toOffsetOutBounds(bounds, offsetOutBounds);
12544
+ toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
12448
12545
  innerShadow.forEach((item, index) => {
12449
12546
  let otherScale = 1;
12450
12547
  if (item.scaleFixed) {
@@ -12453,16 +12550,17 @@ function innerShadow(ui, current, shape) {
12453
12550
  }
12454
12551
  other.save();
12455
12552
  other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
12456
- spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
12457
- drawWorldShadow(other, offsetOutBounds, spreadScale, shape);
12553
+ transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
12554
+ if (transform) other.setTransform(transform);
12555
+ drawWorldShadow(other, offsetOutBounds, shape);
12458
12556
  other.restore();
12459
12557
  if (worldCanvas) {
12460
- other.copyWorld(other, bounds, nowWorld, "copy");
12558
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
12461
12559
  other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
12462
12560
  copyBounds = nowWorld;
12463
12561
  } else {
12464
12562
  other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
12465
- copyBounds = bounds;
12563
+ copyBounds = renderBounds;
12466
12564
  }
12467
12565
  other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
12468
12566
  LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
@@ -12471,6 +12569,8 @@ function innerShadow(ui, current, shape) {
12471
12569
  other.recycle(copyBounds);
12472
12570
  }
12473
12571
 
12572
+ const getInnerShadowSpread = getShadowRenderSpread;
12573
+
12474
12574
  function blur(ui, current, origin) {
12475
12575
  const {blur: blur} = ui.__;
12476
12576
  origin.setWorldBlur(blur * ui.__nowWorld.a);
@@ -12485,10 +12585,12 @@ const EffectModule = {
12485
12585
  innerShadow: innerShadow,
12486
12586
  blur: blur,
12487
12587
  backgroundBlur: backgroundBlur,
12488
- getShadowSpread: getShadowSpread,
12588
+ getShadowRenderSpread: getShadowRenderSpread,
12589
+ getShadowTransform: getShadowTransform,
12489
12590
  isTransformShadow(_shadow) {
12490
12591
  return undefined;
12491
- }
12592
+ },
12593
+ getInnerShadowSpread: getInnerShadowSpread
12492
12594
  };
12493
12595
 
12494
12596
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
@@ -12505,6 +12607,7 @@ Group.prototype.__renderMask = function(canvas, options) {
12505
12607
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
12506
12608
  maskCanvas = contentCanvas = null;
12507
12609
  }
12610
+ if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
12508
12611
  maskOpacity = child.__.opacity;
12509
12612
  usedGrayscaleAlpha = false;
12510
12613
  if (mask === "path" || mask === "clipping-path") {
@@ -12522,7 +12625,6 @@ Group.prototype.__renderMask = function(canvas, options) {
12522
12625
  if (!contentCanvas) contentCanvas = getCanvas(canvas);
12523
12626
  child.__render(maskCanvas, options);
12524
12627
  }
12525
- if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
12526
12628
  continue;
12527
12629
  }
12528
12630
  const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
@@ -13118,4 +13220,4 @@ Object.assign(Creator, {
13118
13220
 
13119
13221
  useCanvas();
13120
13222
 
13121
- export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
13223
+ export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };