@leafer-draw/worker 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.
package/dist/worker.js CHANGED
@@ -229,17 +229,32 @@ var LeaferUI = function(exports) {
229
229
  this.__input = this.__middle = null;
230
230
  }
231
231
  }
232
- const {round: round$3, pow: pow$1, PI: PI$3} = Math;
233
- const MathHelper = {
234
- within(value, min, max) {
235
- if (isObject(min)) max = min.max, min = min.min;
236
- if (!isUndefined(min) && value < min) value = min;
237
- if (!isUndefined(max) && value > max) value = max;
238
- return value;
232
+ let tempA, tempB, tempTo;
233
+ const {max: max$4} = Math, tempFour = [ 0, 0, 0, 0 ];
234
+ const FourNumberHelper = {
235
+ zero: [ ...tempFour ],
236
+ tempFour: tempFour,
237
+ set(to, top, right, bottom, left) {
238
+ if (right === undefined) right = bottom = left = top;
239
+ to[0] = top;
240
+ to[1] = right;
241
+ to[2] = bottom;
242
+ to[3] = left;
243
+ return to;
244
+ },
245
+ setTemp(top, right, bottom, left) {
246
+ return set$1(tempFour, top, right, bottom, left);
239
247
  },
240
- fourNumber(num, maxValue) {
248
+ toTempAB(a, b, change) {
249
+ tempTo = change ? isNumber(a) ? b : a : [];
250
+ if (isNumber(a)) tempA = setTemp(a), tempB = b; else if (isNumber(b)) tempA = a,
251
+ tempB = setTemp(b); else tempA = a, tempB = b;
252
+ if (tempA.length !== 4) tempA = get$5(tempA);
253
+ if (tempB.length !== 4) tempB = get$5(tempB);
254
+ },
255
+ get(num, maxValue) {
241
256
  let data;
242
- if (isArray(num)) {
257
+ if (!isNumber(num)) {
243
258
  switch (num.length) {
244
259
  case 4:
245
260
  data = isUndefined(maxValue) ? num : [ ...num ];
@@ -262,9 +277,36 @@ var LeaferUI = function(exports) {
262
277
  }
263
278
  }
264
279
  if (!data) data = [ num, num, num, num ];
265
- if (maxValue) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
280
+ if (!isUndefined(maxValue)) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
266
281
  return data;
267
282
  },
283
+ max(t, other, change) {
284
+ if (isNumber(t) && isNumber(other)) return max$4(t, other);
285
+ toTempAB(t, other, change);
286
+ 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]));
287
+ },
288
+ add(t, other, change) {
289
+ if (isNumber(t) && isNumber(other)) return t + other;
290
+ toTempAB(t, other, change);
291
+ return set$1(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
292
+ },
293
+ swapAndScale(t, scaleX, scaleY, change) {
294
+ if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [ t * scaleY, t * scaleX ];
295
+ const to = change ? t : [];
296
+ const [top, right, bottom, left] = t.length === 4 ? t : get$5(t);
297
+ return set$1(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
298
+ }
299
+ };
300
+ const {set: set$1, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
301
+ const {round: round$3, pow: pow$1, PI: PI$3} = Math;
302
+ const MathHelper = {
303
+ within(value, min, max) {
304
+ if (isObject(min)) max = min.max, min = min.min;
305
+ if (!isUndefined(min) && value < min) value = min;
306
+ if (!isUndefined(max) && value > max) value = max;
307
+ return value;
308
+ },
309
+ fourNumber: FourNumberHelper.get,
268
310
  formatRotation(rotation, unsign) {
269
311
  rotation %= 360;
270
312
  if (unsign) {
@@ -392,6 +434,15 @@ var LeaferUI = function(exports) {
392
434
  t.c *= scaleY;
393
435
  t.d *= scaleY;
394
436
  },
437
+ pixelScale(t, pixelRatio, to) {
438
+ to || (to = t);
439
+ to.a = t.a * pixelRatio;
440
+ to.b = t.b * pixelRatio;
441
+ to.c = t.c * pixelRatio;
442
+ to.d = t.d * pixelRatio;
443
+ to.e = t.e * pixelRatio;
444
+ to.f = t.f * pixelRatio;
445
+ },
395
446
  scaleOfOuter(t, origin, scaleX, scaleY) {
396
447
  M$6.toInnerPoint(t, origin, tempPoint$3);
397
448
  M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
@@ -882,6 +933,10 @@ var LeaferUI = function(exports) {
882
933
  this.scaleY *= y || x;
883
934
  return this;
884
935
  }
936
+ pixelScale(pixelRatio) {
937
+ MatrixHelper.pixelScale(this, pixelRatio);
938
+ return this;
939
+ }
885
940
  scaleOfOuter(origin, x, y) {
886
941
  MatrixHelper.scaleOfOuter(this, origin, x, y);
887
942
  return this;
@@ -960,7 +1015,7 @@ var LeaferUI = function(exports) {
960
1015
  MatrixHelper.reset(this);
961
1016
  }
962
1017
  }
963
- const tempMatrix$1 = new Matrix;
1018
+ const tempMatrix$2 = new Matrix;
964
1019
  const TwoPointBoundsHelper = {
965
1020
  tempPointBounds: {},
966
1021
  setPoint(t, minX, minY) {
@@ -1090,9 +1145,9 @@ var LeaferUI = function(exports) {
1090
1145
  let right$1, bottom$1, boundsRight, boundsBottom;
1091
1146
  const point = {};
1092
1147
  const toPoint$4 = {};
1093
- const tempBounds$2 = {};
1148
+ const tempBounds$3 = {};
1094
1149
  const BoundsHelper = {
1095
- tempBounds: tempBounds$2,
1150
+ tempBounds: tempBounds$3,
1096
1151
  set(t, x = 0, y = 0, width = 0, height = 0) {
1097
1152
  t.x = x;
1098
1153
  t.y = y;
@@ -1143,19 +1198,11 @@ var LeaferUI = function(exports) {
1143
1198
  B.move(t, x, y);
1144
1199
  return t;
1145
1200
  },
1146
- toOffsetOutBounds(t, to, parent) {
1147
- if (!to) {
1148
- to = t;
1149
- } else {
1150
- copy$8(to, t);
1151
- }
1152
- if (parent) {
1153
- to.offsetX = -(B.maxX(parent) - t.x);
1154
- to.offsetY = -(B.maxY(parent) - t.y);
1155
- } else {
1156
- to.offsetX = t.x + t.width;
1157
- to.offsetY = t.y + t.height;
1158
- }
1201
+ toOffsetOutBounds(t, to, offsetBounds) {
1202
+ if (!to) to = t; else copy$8(to, t);
1203
+ if (!offsetBounds) offsetBounds = t;
1204
+ to.offsetX = B.maxX(offsetBounds);
1205
+ to.offsetY = B.maxY(offsetBounds);
1159
1206
  B.move(to, -to.offsetX, -to.offsetY);
1160
1207
  },
1161
1208
  scale(t, scaleX, scaleY = scaleX, onlySize) {
@@ -1169,9 +1216,9 @@ var LeaferUI = function(exports) {
1169
1216
  t.height *= scaleY;
1170
1217
  },
1171
1218
  tempToOuterOf(t, matrix) {
1172
- B.copy(tempBounds$2, t);
1173
- B.toOuterOf(tempBounds$2, matrix);
1174
- return tempBounds$2;
1219
+ B.copy(tempBounds$3, t);
1220
+ B.toOuterOf(tempBounds$3, matrix);
1221
+ return tempBounds$3;
1175
1222
  },
1176
1223
  getOuterOf(t, matrix) {
1177
1224
  t = Object.assign({}, t);
@@ -1229,9 +1276,9 @@ var LeaferUI = function(exports) {
1229
1276
  put(t, put, align = "center", putScale = 1, changeSize = true, to) {
1230
1277
  to || (to = put);
1231
1278
  if (isString(putScale)) putScale = B.getFitScale(t, put, putScale === "cover");
1232
- tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
1233
- tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
1234
- AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
1279
+ tempBounds$3.width = changeSize ? put.width *= putScale : put.width * putScale;
1280
+ tempBounds$3.height = changeSize ? put.height *= putScale : put.height * putScale;
1281
+ AlignHelper.toPoint(align, tempBounds$3, t, to, true, true);
1235
1282
  },
1236
1283
  getSpread(t, spread, side) {
1237
1284
  const n = {};
@@ -1301,7 +1348,7 @@ var LeaferUI = function(exports) {
1301
1348
  first = false;
1302
1349
  if (!addMode) copy$8(t, bounds);
1303
1350
  } else {
1304
- add$1(t, bounds);
1351
+ add$2(t, bounds);
1305
1352
  }
1306
1353
  }
1307
1354
  }
@@ -1315,7 +1362,7 @@ var LeaferUI = function(exports) {
1315
1362
  B.set(t, point.x, point.y);
1316
1363
  },
1317
1364
  addPoint(t, point) {
1318
- add$1(t, point, true);
1365
+ add$2(t, point, true);
1319
1366
  },
1320
1367
  getPoints(t) {
1321
1368
  const {x: x, y: y, width: width, height: height} = t;
@@ -1384,7 +1431,7 @@ var LeaferUI = function(exports) {
1384
1431
  }
1385
1432
  };
1386
1433
  const B = BoundsHelper;
1387
- const {add: add$1, copy: copy$8} = B;
1434
+ const {add: add$2, copy: copy$8} = B;
1388
1435
  class Bounds {
1389
1436
  get minX() {
1390
1437
  return BoundsHelper.minX(this);
@@ -1527,7 +1574,7 @@ var LeaferUI = function(exports) {
1527
1574
  BoundsHelper.reset(this);
1528
1575
  }
1529
1576
  }
1530
- const tempBounds$1 = new Bounds;
1577
+ const tempBounds$2 = new Bounds;
1531
1578
  class AutoBounds {
1532
1579
  constructor(top, right, bottom, left, width, height) {
1533
1580
  isObject(top) ? this.copy(top) : this.set(top, right, bottom, left, width, height);
@@ -1991,7 +2038,7 @@ var LeaferUI = function(exports) {
1991
2038
  __decorate([ contextMethod() ], Canvas.prototype, "fillText", null);
1992
2039
  __decorate([ contextMethod() ], Canvas.prototype, "measureText", null);
1993
2040
  __decorate([ contextMethod() ], Canvas.prototype, "strokeText", null);
1994
- const {copy: copy$7, multiplyParent: multiplyParent$4} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2041
+ const {copy: copy$7, multiplyParent: multiplyParent$4, pixelScale: pixelScale} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
1995
2042
  const minSize = {
1996
2043
  width: 1,
1997
2044
  height: 1,
@@ -2089,13 +2136,8 @@ var LeaferUI = function(exports) {
2089
2136
  setWorld(matrix, parentMatrix) {
2090
2137
  const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
2091
2138
  if (parentMatrix) multiplyParent$4(matrix, parentMatrix, w);
2092
- w.a = matrix.a * pixelRatio;
2093
- w.b = matrix.b * pixelRatio;
2094
- w.c = matrix.c * pixelRatio;
2095
- w.d = matrix.d * pixelRatio;
2096
- w.e = matrix.e * pixelRatio;
2097
- w.f = matrix.f * pixelRatio;
2098
- if (pixelSnap) {
2139
+ pixelScale(matrix, pixelRatio, w);
2140
+ if (pixelSnap && !matrix.ignorePixelSnap) {
2099
2141
  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),
2100
2142
  w.f = round$1(w.f);
2101
2143
  }
@@ -3745,7 +3787,7 @@ var LeaferUI = function(exports) {
3745
3787
  };
3746
3788
  const I = ImageManager;
3747
3789
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3748
- const {floor: floor$1, max: max$1} = Math;
3790
+ const {floor: floor$1, max: max$3} = Math;
3749
3791
  class LeaferImage {
3750
3792
  get url() {
3751
3793
  return this.config.url;
@@ -3833,7 +3875,7 @@ var LeaferUI = function(exports) {
3833
3875
  }
3834
3876
  if (data) return data;
3835
3877
  }
3836
- const canvas = Platform.origin.createCanvas(max$1(floor$1(width + (xGap || 0)), 1), max$1(floor$1(height + (yGap || 0)), 1));
3878
+ const canvas = Platform.origin.createCanvas(max$3(floor$1(width + (xGap || 0)), 1), max$3(floor$1(height + (yGap || 0)), 1));
3837
3879
  const ctx = canvas.getContext("2d");
3838
3880
  if (opacity) ctx.globalAlpha = opacity;
3839
3881
  ctx.imageSmoothingEnabled = smooth === false ? false : true;
@@ -4008,6 +4050,17 @@ var LeaferUI = function(exports) {
4008
4050
  }
4009
4051
  }));
4010
4052
  }
4053
+ function dimType(defaultValue) {
4054
+ return decorateLeafAttr(defaultValue, key => attr({
4055
+ set(value) {
4056
+ if (this.__setAttr(key, value)) {
4057
+ const data = this.__;
4058
+ DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
4059
+ this.__layout.surfaceChange();
4060
+ }
4061
+ }
4062
+ }));
4063
+ }
4011
4064
  function opacityType(defaultValue) {
4012
4065
  return decorateLeafAttr(defaultValue, key => attr({
4013
4066
  set(value) {
@@ -4048,7 +4101,7 @@ var LeaferUI = function(exports) {
4048
4101
  return decorateLeafAttr(defaultValue, key => attr({
4049
4102
  set(value) {
4050
4103
  if (this.__setAttr(key, value)) {
4051
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
4104
+ this.__layout.surfaceChange();
4052
4105
  this.waitParent(() => {
4053
4106
  this.parent.__layout.childrenSortChange();
4054
4107
  });
@@ -4082,7 +4135,7 @@ var LeaferUI = function(exports) {
4082
4135
  set(value) {
4083
4136
  if (this.__setAttr(key, value)) {
4084
4137
  this.__layout.hitCanvasChanged = true;
4085
- if (Debug.showBounds === "hit") this.__layout.surfaceChanged || this.__layout.surfaceChange();
4138
+ if (Debug.showBounds === "hit") this.__layout.surfaceChange();
4086
4139
  if (this.leafer) this.leafer.updateCursor();
4087
4140
  }
4088
4141
  }
@@ -4554,7 +4607,7 @@ var LeaferUI = function(exports) {
4554
4607
  }
4555
4608
  };
4556
4609
  const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2} = LeafHelper;
4557
- const {toOuterOf: toOuterOf$2, getPoints: getPoints, copy: copy$4} = BoundsHelper;
4610
+ const {toOuterOf: toOuterOf$3, getPoints: getPoints, copy: copy$4} = BoundsHelper;
4558
4611
  const localContent = "_localContentBounds";
4559
4612
  const worldContent = "_worldContentBounds", worldBox = "_worldBoxBounds", worldStroke = "_worldStrokeBounds";
4560
4613
  class LeafLayout {
@@ -4574,7 +4627,7 @@ var LeaferUI = function(exports) {
4574
4627
  this._renderBounds = bounds;
4575
4628
  }
4576
4629
  get localContentBounds() {
4577
- toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
4630
+ toOuterOf$3(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
4578
4631
  return this[localContent];
4579
4632
  }
4580
4633
  get localStrokeBounds() {
@@ -4584,15 +4637,15 @@ var LeaferUI = function(exports) {
4584
4637
  return this._localRenderBounds || this;
4585
4638
  }
4586
4639
  get worldContentBounds() {
4587
- toOuterOf$2(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
4640
+ toOuterOf$3(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
4588
4641
  return this[worldContent];
4589
4642
  }
4590
4643
  get worldBoxBounds() {
4591
- toOuterOf$2(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
4644
+ toOuterOf$3(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
4592
4645
  return this[worldBox];
4593
4646
  }
4594
4647
  get worldStrokeBounds() {
4595
- toOuterOf$2(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
4648
+ toOuterOf$3(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
4596
4649
  return this[worldStroke];
4597
4650
  }
4598
4651
  get a() {
@@ -5363,12 +5416,12 @@ var LeaferUI = function(exports) {
5363
5416
  };
5364
5417
  const {updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2} = LeafHelper;
5365
5418
  const {updateBounds: updateBounds$1} = BranchHelper;
5366
- const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$3} = BoundsHelper;
5419
+ const {toOuterOf: toOuterOf$2, copyAndSpread: copyAndSpread$2, copy: copy$3} = BoundsHelper;
5367
5420
  const {toBounds: toBounds} = PathBounds;
5368
5421
  const LeafBounds = {
5369
5422
  __updateWorldBounds() {
5370
5423
  const layout = this.__layout;
5371
- toOuterOf$1(layout.renderBounds, this.__world, this.__world);
5424
+ toOuterOf$2(layout.renderBounds, this.__world, this.__world);
5372
5425
  if (layout.resized) {
5373
5426
  if (layout.resized === "inner") this.__onUpdateSize();
5374
5427
  if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
@@ -5424,13 +5477,13 @@ var LeaferUI = function(exports) {
5424
5477
  __updateLocalBoxBounds() {
5425
5478
  if (this.__hasMotionPath) this.__updateMotionPath();
5426
5479
  if (this.__hasAutoLayout) this.__updateAutoLayout();
5427
- toOuterOf$1(this.__layout.boxBounds, this.__local, this.__local);
5480
+ toOuterOf$2(this.__layout.boxBounds, this.__local, this.__local);
5428
5481
  },
5429
5482
  __updateLocalStrokeBounds() {
5430
- toOuterOf$1(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5483
+ toOuterOf$2(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5431
5484
  },
5432
5485
  __updateLocalRenderBounds() {
5433
- toOuterOf$1(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5486
+ toOuterOf$2(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5434
5487
  },
5435
5488
  __updateBoxBounds(_secondLayout, _bounds) {
5436
5489
  const b = this.__layout.boxBounds;
@@ -5468,11 +5521,11 @@ var LeaferUI = function(exports) {
5468
5521
  },
5469
5522
  __updateStrokeBounds(_bounds) {
5470
5523
  const layout = this.__layout;
5471
- copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5524
+ copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5472
5525
  },
5473
5526
  __updateRenderBounds(_bounds) {
5474
- const layout = this.__layout;
5475
- layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$3(layout.renderBounds, layout.strokeBounds);
5527
+ const layout = this.__layout, {renderSpread: renderSpread} = layout;
5528
+ isNumber(renderSpread) && renderSpread <= 0 ? copy$3(layout.renderBounds, layout.strokeBounds) : copyAndSpread$2(layout.renderBounds, layout.boxBounds, renderSpread);
5476
5529
  }
5477
5530
  };
5478
5531
  const LeafRender = {
@@ -5480,6 +5533,7 @@ var LeaferUI = function(exports) {
5480
5533
  if (options.shape) return this.__renderShape(canvas, options);
5481
5534
  if (this.__worldOpacity) {
5482
5535
  const data = this.__;
5536
+ if (data.bright && !options.topRendering) return options.topList.add(this);
5483
5537
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5484
5538
  canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5485
5539
  if (this.__.__single) {
@@ -5526,7 +5580,9 @@ var LeaferUI = function(exports) {
5526
5580
  this.__nowWorld = this.__getNowWorld(options);
5527
5581
  if (this.__worldOpacity) {
5528
5582
  const data = this.__;
5529
- if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5583
+ if (data.__useDim) {
5584
+ 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);
5585
+ }
5530
5586
  if (data.__single && !this.isBranchLeaf) {
5531
5587
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5532
5588
  const tempCanvas = canvas.getSameCanvas(false, true);
@@ -5561,9 +5617,10 @@ var LeaferUI = function(exports) {
5561
5617
  };
5562
5618
  const tempScaleData$1 = {};
5563
5619
  const {LEAF: LEAF, create: create} = IncrementId;
5620
+ const {stintSet: stintSet$3} = DataHelper;
5564
5621
  const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
5565
- const {toOuterOf: toOuterOf} = BoundsHelper;
5566
- const {copy: copy$2, move: move} = PointHelper;
5622
+ const {toOuterOf: toOuterOf$1} = BoundsHelper;
5623
+ const {copy: copy$2, move: move$2} = PointHelper;
5567
5624
  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;
5568
5625
  exports.Leaf = class Leaf {
5569
5626
  get tag() {
@@ -5837,8 +5894,9 @@ var LeaferUI = function(exports) {
5837
5894
  if (!this.__cameraWorld) this.__cameraWorld = {};
5838
5895
  const cameraWorld = this.__cameraWorld, world = this.__world;
5839
5896
  multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
5840
- toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
5841
- cameraWorld.half !== world.half && (cameraWorld.half = world.half);
5897
+ toOuterOf$1(this.__layout.renderBounds, cameraWorld, cameraWorld);
5898
+ stintSet$3(cameraWorld, "half", world.half);
5899
+ stintSet$3(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
5842
5900
  return cameraWorld;
5843
5901
  } else {
5844
5902
  return this.__world;
@@ -5872,7 +5930,7 @@ var LeaferUI = function(exports) {
5872
5930
  getWorldBounds(inner, relative, change) {
5873
5931
  const matrix = relative ? getRelativeWorld(this, relative) : this.worldTransform;
5874
5932
  const to = change ? inner : {};
5875
- toOuterOf(inner, matrix, to);
5933
+ toOuterOf$1(inner, matrix, to);
5876
5934
  return to;
5877
5935
  }
5878
5936
  worldToLocal(world, to, distance, relative) {
@@ -5905,7 +5963,7 @@ var LeaferUI = function(exports) {
5905
5963
  }
5906
5964
  getBoxPointByInner(inner, _relative, _distance, change) {
5907
5965
  const point = change ? inner : Object.assign({}, inner), {x: x, y: y} = this.boxBounds;
5908
- move(point, -x, -y);
5966
+ move$2(point, -x, -y);
5909
5967
  return point;
5910
5968
  }
5911
5969
  getInnerPoint(world, relative, distance, change) {
@@ -5915,7 +5973,7 @@ var LeaferUI = function(exports) {
5915
5973
  }
5916
5974
  getInnerPointByBox(box, _relative, _distance, change) {
5917
5975
  const point = change ? box : Object.assign({}, box), {x: x, y: y} = this.boxBounds;
5918
- move(point, x, y);
5976
+ move$2(point, x, y);
5919
5977
  return point;
5920
5978
  }
5921
5979
  getInnerPointByLocal(local, _relative, distance, change) {
@@ -6351,7 +6409,7 @@ var LeaferUI = function(exports) {
6351
6409
  this.levelMap = null;
6352
6410
  }
6353
6411
  }
6354
- const version = "1.9.6";
6412
+ const version = "1.9.8";
6355
6413
  class LeaferCanvas extends LeaferCanvasBase {
6356
6414
  get allowBackgroundColor() {
6357
6415
  return true;
@@ -6749,6 +6807,7 @@ var LeaferUI = function(exports) {
6749
6807
  usePartRender: true,
6750
6808
  maxFPS: 120
6751
6809
  };
6810
+ this.frames = [];
6752
6811
  this.target = target;
6753
6812
  this.canvas = canvas;
6754
6813
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -6878,7 +6937,7 @@ var LeaferUI = function(exports) {
6878
6937
  };
6879
6938
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
6880
6939
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
6881
- this.target.__render(canvas, options);
6940
+ Platform.render(this.target, canvas, options);
6882
6941
  this.renderBounds = realBounds = realBounds || bounds;
6883
6942
  this.renderOptions = options;
6884
6943
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
@@ -6901,12 +6960,15 @@ var LeaferUI = function(exports) {
6901
6960
  const target = this.target;
6902
6961
  if (this.requestTime || !target) return;
6903
6962
  if (target.parentApp) return target.parentApp.requestRender(false);
6904
- const requestTime = this.requestTime = Date.now();
6963
+ this.requestTime = this.frameTime || Date.now();
6905
6964
  const render = () => {
6906
- const nowFPS = 1e3 / (Date.now() - requestTime);
6965
+ const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
6907
6966
  const {maxFPS: maxFPS} = this.config;
6908
- if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
6909
- this.FPS = Math.min(120, Math.ceil(nowFPS));
6967
+ if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
6968
+ const {frames: frames} = this;
6969
+ if (frames.length > 30) frames.shift();
6970
+ frames.push(nowFPS);
6971
+ this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
6910
6972
  this.requestTime = 0;
6911
6973
  this.checkRender();
6912
6974
  };
@@ -6967,6 +7029,14 @@ var LeaferUI = function(exports) {
6967
7029
  interaction: (_target, _canvas, _selector, _options) => undefined
6968
7030
  });
6969
7031
  Platform.layout = Layouter.fullLayout;
7032
+ Platform.render = function(target, canvas, options) {
7033
+ const topOptions = Object.assign(Object.assign({}, options), {
7034
+ topRendering: true
7035
+ });
7036
+ options.topList = new LeafList;
7037
+ target.__render(canvas, options);
7038
+ if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
7039
+ };
6970
7040
  function effectType(defaultValue) {
6971
7041
  return decorateLeafAttr(defaultValue, key => attr({
6972
7042
  set(value) {
@@ -7328,39 +7398,40 @@ var LeaferUI = function(exports) {
7328
7398
  return data;
7329
7399
  }
7330
7400
  }
7401
+ const {max: max$2, add: add$1} = FourNumberHelper;
7331
7402
  const UIBounds = {
7332
7403
  __updateStrokeSpread() {
7333
- let width = 0, boxWidth = 0;
7404
+ let spread = 0, boxSpread = 0;
7334
7405
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
7335
7406
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
7336
- boxWidth = width = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7407
+ boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7337
7408
  if (!data.__boxStroke) {
7338
- const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * width;
7409
+ const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
7339
7410
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
7340
- width += Math.max(miterLimitAddWidth, storkeCapAddWidth);
7411
+ spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
7341
7412
  }
7342
7413
  }
7343
- if (data.__useArrow) width += strokeWidth * 5;
7414
+ if (data.__useArrow) spread += strokeWidth * 5;
7344
7415
  if (box) {
7345
- width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
7346
- boxWidth = box.__layout.strokeBoxSpread;
7416
+ spread = max$2(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
7417
+ boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
7347
7418
  }
7348
- this.__layout.strokeBoxSpread = boxWidth;
7349
- return width;
7419
+ this.__layout.strokeBoxSpread = boxSpread;
7420
+ return spread;
7350
7421
  },
7351
7422
  __updateRenderSpread() {
7352
- let width = 0;
7353
- const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7354
- if (shadow) width = Effect.getShadowSpread(this, shadow);
7355
- if (blur) width = Math.max(width, blur);
7356
- if (filter) width += Filter.getSpread(filter);
7357
- if (renderSpread) width += renderSpread;
7358
- let shapeWidth = width = Math.ceil(width);
7359
- 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));
7360
- if (backgroundBlur) shapeWidth = Math.max(shapeWidth, backgroundBlur);
7361
- this.__layout.renderShapeSpread = shapeWidth;
7362
- width += this.__layout.strokeSpread || 0;
7363
- return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7423
+ let spread = 0;
7424
+ const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
7425
+ if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
7426
+ if (blur) spread = max$2(spread, blur);
7427
+ if (filter) spread = add$1(spread, Filter.getSpread(filter));
7428
+ if (renderSpread) spread = add$1(spread, renderSpread);
7429
+ if (strokeSpread) spread = add$1(spread, strokeSpread);
7430
+ let shapeSpread = spread;
7431
+ if (innerShadow) shapeSpread = max$2(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
7432
+ if (backgroundBlur) shapeSpread = max$2(shapeSpread, backgroundBlur);
7433
+ this.__layout.renderShapeSpread = shapeSpread;
7434
+ return box ? max$2(box.__updateRenderSpread(), spread) : spread;
7364
7435
  }
7365
7436
  };
7366
7437
  const {float: float} = MathHelper;
@@ -7684,8 +7755,8 @@ var LeaferUI = function(exports) {
7684
7755
  __decorate([ opacityType(1) ], exports.UI.prototype, "opacity", void 0);
7685
7756
  __decorate([ visibleType(true) ], exports.UI.prototype, "visible", void 0);
7686
7757
  __decorate([ surfaceType(false) ], exports.UI.prototype, "locked", void 0);
7687
- __decorate([ surfaceType(false) ], exports.UI.prototype, "dim", void 0);
7688
- __decorate([ surfaceType(false) ], exports.UI.prototype, "dimskip", void 0);
7758
+ __decorate([ dimType(false) ], exports.UI.prototype, "dim", void 0);
7759
+ __decorate([ dimType(false) ], exports.UI.prototype, "dimskip", void 0);
7689
7760
  __decorate([ sortType(0) ], exports.UI.prototype, "zIndex", void 0);
7690
7761
  __decorate([ maskType(false) ], exports.UI.prototype, "mask", void 0);
7691
7762
  __decorate([ eraserType(false) ], exports.UI.prototype, "eraser", void 0);
@@ -8502,7 +8573,7 @@ var LeaferUI = function(exports) {
8502
8573
  __decorate([ dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
8503
8574
  __decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
8504
8575
  exports.Canvas = __decorate([ registerUI() ], exports.Canvas);
8505
- const {copyAndSpread: copyAndSpread, includes: includes, spread: spread, setList: setList} = BoundsHelper;
8576
+ const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
8506
8577
  exports.Text = class Text extends exports.UI {
8507
8578
  get __tag() {
8508
8579
  return "Text";
@@ -8548,13 +8619,13 @@ var LeaferUI = function(exports) {
8548
8619
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
8549
8620
  }
8550
8621
  __updateRenderSpread() {
8551
- let width = super.__updateRenderSpread();
8552
- if (!width) width = this.isOverflow ? 1 : 0;
8553
- return width;
8622
+ let spread = super.__updateRenderSpread();
8623
+ if (!spread) spread = this.isOverflow ? 1 : 0;
8624
+ return spread;
8554
8625
  }
8555
8626
  __updateRenderBounds() {
8556
8627
  const {renderBounds: renderBounds, renderSpread: renderSpread} = this.__layout;
8557
- copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
8628
+ copyAndSpread$1(renderBounds, this.__.__textBoxBounds, renderSpread);
8558
8629
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
8559
8630
  }
8560
8631
  __updateChange() {
@@ -8870,23 +8941,27 @@ var LeaferUI = function(exports) {
8870
8941
  out.recycle(ui.__nowWorld);
8871
8942
  }
8872
8943
  }
8873
- const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
8944
+ const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
8945
+ const tempBounds$1 = {};
8874
8946
  function shape(ui, current, options) {
8875
8947
  const canvas = current.getSameCanvas();
8876
- const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
8877
- let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
8948
+ const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
8949
+ const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
8950
+ toOuterOf(layout.strokeSpread ? (copyAndSpread(tempBounds$1, layout.boxBounds, layout.strokeSpread),
8951
+ tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
8952
+ let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
8878
8953
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
8879
- if (currentBounds.includes(nowWorld)) {
8954
+ if (currentBounds.includes(nowWorldShapeBounds)) {
8880
8955
  worldCanvas = canvas;
8881
- bounds = shapeBounds = nowWorld;
8956
+ bounds = shapeBounds = nowWorldShapeBounds;
8957
+ renderBounds = nowWorld;
8882
8958
  } else {
8883
- const {renderShapeSpread: spread} = ui.__layout;
8884
8959
  let worldClipBounds;
8885
8960
  if (Platform.fullImageShadow) {
8886
- worldClipBounds = nowWorld;
8961
+ worldClipBounds = nowWorldShapeBounds;
8887
8962
  } else {
8888
- const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
8889
- worldClipBounds = getIntersectData(spreadBounds, nowWorld);
8963
+ const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
8964
+ worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
8890
8965
  }
8891
8966
  fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
8892
8967
  let {a: fitScaleX, d: fitScaleY} = fitMatrix;
@@ -8896,8 +8971,10 @@ var LeaferUI = function(exports) {
8896
8971
  scaleX *= fitScaleX;
8897
8972
  scaleY *= fitScaleY;
8898
8973
  }
8899
- shapeBounds = getOuterOf(nowWorld, fitMatrix);
8974
+ shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
8900
8975
  bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
8976
+ renderBounds = getOuterOf(nowWorld, fitMatrix);
8977
+ move$1(renderBounds, -fitMatrix.e, -fitMatrix.f);
8901
8978
  const userMatrix = options.matrix;
8902
8979
  if (userMatrix) {
8903
8980
  matrix = new Matrix(fitMatrix);
@@ -8916,6 +8993,7 @@ var LeaferUI = function(exports) {
8916
8993
  matrix: matrix,
8917
8994
  fitMatrix: fitMatrix,
8918
8995
  bounds: bounds,
8996
+ renderBounds: renderBounds,
8919
8997
  worldCanvas: worldCanvas,
8920
8998
  shapeBounds: shapeBounds,
8921
8999
  scaleX: scaleX,
@@ -9013,7 +9091,7 @@ var LeaferUI = function(exports) {
9013
9091
  drawTextStroke: drawTextStroke,
9014
9092
  shape: shape
9015
9093
  };
9016
- let origin = {}, tempMatrix = getMatrixData();
9094
+ let origin = {}, tempMatrix$1 = getMatrixData();
9017
9095
  const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
9018
9096
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
9019
9097
  const transform = get$3();
@@ -9025,12 +9103,12 @@ var LeaferUI = function(exports) {
9025
9103
  }, rotation);
9026
9104
  data.transform = transform;
9027
9105
  }
9028
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
9106
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
9029
9107
  const transform = get$3();
9030
9108
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
9031
- if (clipSize) {
9032
- tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
9033
- multiplyParent(transform, tempMatrix);
9109
+ if (clipScaleX) {
9110
+ tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
9111
+ multiplyParent(transform, tempMatrix$1);
9034
9112
  }
9035
9113
  data.transform = transform;
9036
9114
  }
@@ -9123,7 +9201,12 @@ var LeaferUI = function(exports) {
9123
9201
 
9124
9202
  case "normal":
9125
9203
  case "clip":
9126
- if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
9204
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
9205
+ let clipScaleX, clipScaleY;
9206
+ if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
9207
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
9208
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
9209
+ }
9127
9210
  break;
9128
9211
 
9129
9212
  case "repeat":
@@ -9268,7 +9351,7 @@ var LeaferUI = function(exports) {
9268
9351
  if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
9269
9352
  }
9270
9353
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
9271
- const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
9354
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
9272
9355
  function createPattern(ui, paint, pixelRatio) {
9273
9356
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
9274
9357
  const id = scaleX + "-" + scaleY + "-" + pixelRatio;
@@ -9316,8 +9399,8 @@ var LeaferUI = function(exports) {
9316
9399
  if (transform || scaleX !== 1 || scaleY !== 1) {
9317
9400
  const canvasWidth = width + (xGap || 0);
9318
9401
  const canvasHeight = height + (yGap || 0);
9319
- scaleX /= canvasWidth / max(floor(canvasWidth), 1);
9320
- scaleY /= canvasHeight / max(floor(canvasHeight), 1);
9402
+ scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
9403
+ scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
9321
9404
  if (!imageMatrix) {
9322
9405
  imageMatrix = get$1();
9323
9406
  if (transform) copy$1(imageMatrix, transform);
@@ -9342,17 +9425,15 @@ var LeaferUI = function(exports) {
9342
9425
  if (allowDraw) {
9343
9426
  if (data.repeat) {
9344
9427
  allowDraw = false;
9345
- } else {
9346
- if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
9347
- let {width: width, height: height} = data;
9348
- width *= scaleX * pixelRatio;
9349
- height *= scaleY * pixelRatio;
9350
- if (data.scaleX) {
9351
- width *= data.scaleX;
9352
- height *= data.scaleY;
9353
- }
9354
- allowDraw = width * height > Platform.image.maxCacheSize;
9428
+ } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
9429
+ let {width: width, height: height} = data;
9430
+ width *= scaleX * pixelRatio;
9431
+ height *= scaleY * pixelRatio;
9432
+ if (data.scaleX) {
9433
+ width *= data.scaleX;
9434
+ height *= data.scaleY;
9355
9435
  }
9436
+ allowDraw = width * height > Platform.image.maxCacheSize;
9356
9437
  }
9357
9438
  }
9358
9439
  if (allowDraw) {
@@ -9510,17 +9591,17 @@ var LeaferUI = function(exports) {
9510
9591
  conicGradient: conicGradient,
9511
9592
  getTransform: getTransform
9512
9593
  };
9513
- const {copy: copy, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
9514
- const tempBounds = {};
9594
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
9595
+ const tempBounds = {}, tempMatrix = new Matrix;
9515
9596
  const offsetOutBounds$1 = {};
9516
9597
  function shadow(ui, current, shape) {
9517
- let copyBounds, spreadScale;
9518
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
9598
+ let copyBounds, transform;
9599
+ const {__nowWorld: nowWorld} = ui;
9519
9600
  const {shadow: shadow} = ui.__;
9520
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
9601
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
9521
9602
  const other = current.getSameCanvas();
9522
9603
  const end = shadow.length - 1;
9523
- toOffsetOutBounds$1(bounds, offsetOutBounds$1);
9604
+ toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
9524
9605
  shadow.forEach((item, index) => {
9525
9606
  let otherScale = 1;
9526
9607
  if (item.scaleFixed) {
@@ -9528,63 +9609,69 @@ var LeaferUI = function(exports) {
9528
9609
  if (sx > 1) otherScale = 1 / sx;
9529
9610
  }
9530
9611
  other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
9531
- spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
9532
- drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
9533
- copyBounds = bounds;
9612
+ transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
9613
+ if (transform) other.setTransform(transform);
9614
+ drawWorldShadow(other, offsetOutBounds$1, shape);
9615
+ if (transform) other.resetTransform();
9616
+ copyBounds = renderBounds;
9534
9617
  if (item.box) {
9535
9618
  other.restore();
9536
9619
  other.save();
9537
9620
  if (worldCanvas) {
9538
- other.copyWorld(other, bounds, nowWorld, "copy");
9621
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
9539
9622
  copyBounds = nowWorld;
9540
9623
  }
9541
9624
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
9542
9625
  }
9543
- if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9626
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9544
9627
  if (end && index < end) other.clearWorld(copyBounds);
9545
9628
  });
9546
9629
  other.recycle(copyBounds);
9547
9630
  }
9548
- function getShadowSpread(_ui, shadow) {
9549
- let width = 0;
9550
- 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));
9551
- return width;
9631
+ function getShadowRenderSpread(_ui, shadow) {
9632
+ let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
9633
+ shadow.forEach(item => {
9634
+ x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
9635
+ top = max(top, spread + blur - y);
9636
+ right = max(right, spread + blur + x);
9637
+ bottom = max(bottom, spread + blur + y);
9638
+ left = max(left, spread + blur - x);
9639
+ });
9640
+ return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
9641
+ }
9642
+ function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
9643
+ if (shadow.spread) {
9644
+ const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
9645
+ tempMatrix.set().scaleOfOuter({
9646
+ x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
9647
+ y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
9648
+ }, spreadScale);
9649
+ return tempMatrix;
9650
+ }
9651
+ return undefined;
9552
9652
  }
9553
- function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
9554
- const {bounds: bounds, shapeBounds: shapeBounds} = shape;
9653
+ function drawWorldShadow(canvas, outBounds, shape) {
9654
+ const {shapeBounds: shapeBounds} = shape;
9655
+ let from, to;
9555
9656
  if (Platform.fullImageShadow) {
9556
9657
  copy(tempBounds, canvas.bounds);
9557
- tempBounds.x += outBounds.x - shapeBounds.x;
9558
- tempBounds.y += outBounds.y - shapeBounds.y;
9559
- if (spreadScale) {
9560
- const {fitMatrix: fitMatrix} = shape;
9561
- tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
9562
- tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
9563
- tempBounds.width *= spreadScale;
9564
- tempBounds.height *= spreadScale;
9565
- }
9566
- canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
9658
+ move(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
9659
+ from = canvas.bounds, to = tempBounds;
9567
9660
  } else {
9568
- if (spreadScale) {
9569
- copy(tempBounds, outBounds);
9570
- tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
9571
- tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
9572
- tempBounds.width *= spreadScale;
9573
- tempBounds.height *= spreadScale;
9574
- }
9575
- canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
9661
+ from = shapeBounds, to = outBounds;
9576
9662
  }
9663
+ canvas.copyWorld(shape.canvas, from, to);
9577
9664
  }
9578
9665
  const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
9579
9666
  const offsetOutBounds = {};
9580
9667
  function innerShadow(ui, current, shape) {
9581
- let copyBounds, spreadScale;
9582
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
9668
+ let copyBounds, transform;
9669
+ const {__nowWorld: nowWorld} = ui;
9583
9670
  const {innerShadow: innerShadow} = ui.__;
9584
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
9671
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
9585
9672
  const other = current.getSameCanvas();
9586
9673
  const end = innerShadow.length - 1;
9587
- toOffsetOutBounds(bounds, offsetOutBounds);
9674
+ toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
9588
9675
  innerShadow.forEach((item, index) => {
9589
9676
  let otherScale = 1;
9590
9677
  if (item.scaleFixed) {
@@ -9593,16 +9680,17 @@ var LeaferUI = function(exports) {
9593
9680
  }
9594
9681
  other.save();
9595
9682
  other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
9596
- spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
9597
- drawWorldShadow(other, offsetOutBounds, spreadScale, shape);
9683
+ transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
9684
+ if (transform) other.setTransform(transform);
9685
+ drawWorldShadow(other, offsetOutBounds, shape);
9598
9686
  other.restore();
9599
9687
  if (worldCanvas) {
9600
- other.copyWorld(other, bounds, nowWorld, "copy");
9688
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
9601
9689
  other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
9602
9690
  copyBounds = nowWorld;
9603
9691
  } else {
9604
9692
  other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
9605
- copyBounds = bounds;
9693
+ copyBounds = renderBounds;
9606
9694
  }
9607
9695
  other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
9608
9696
  LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
@@ -9610,6 +9698,7 @@ var LeaferUI = function(exports) {
9610
9698
  });
9611
9699
  other.recycle(copyBounds);
9612
9700
  }
9701
+ const getInnerShadowSpread = getShadowRenderSpread;
9613
9702
  function blur(ui, current, origin) {
9614
9703
  const {blur: blur} = ui.__;
9615
9704
  origin.setWorldBlur(blur * ui.__nowWorld.a);
@@ -9622,10 +9711,12 @@ var LeaferUI = function(exports) {
9622
9711
  innerShadow: innerShadow,
9623
9712
  blur: blur,
9624
9713
  backgroundBlur: backgroundBlur,
9625
- getShadowSpread: getShadowSpread,
9714
+ getShadowRenderSpread: getShadowRenderSpread,
9715
+ getShadowTransform: getShadowTransform,
9626
9716
  isTransformShadow(_shadow) {
9627
9717
  return undefined;
9628
- }
9718
+ },
9719
+ getInnerShadowSpread: getInnerShadowSpread
9629
9720
  };
9630
9721
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
9631
9722
  let usedGrayscaleAlpha;
@@ -9639,6 +9730,7 @@ var LeaferUI = function(exports) {
9639
9730
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
9640
9731
  maskCanvas = contentCanvas = null;
9641
9732
  }
9733
+ if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
9642
9734
  maskOpacity = child.__.opacity;
9643
9735
  usedGrayscaleAlpha = false;
9644
9736
  if (mask === "path" || mask === "clipping-path") {
@@ -9656,7 +9748,6 @@ var LeaferUI = function(exports) {
9656
9748
  if (!contentCanvas) contentCanvas = getCanvas(canvas);
9657
9749
  child.__render(maskCanvas, options);
9658
9750
  }
9659
- if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
9660
9751
  continue;
9661
9752
  }
9662
9753
  const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
@@ -10209,6 +10300,7 @@ var LeaferUI = function(exports) {
10209
10300
  exports.Export = Export;
10210
10301
  exports.FileHelper = FileHelper;
10211
10302
  exports.Filter = Filter;
10303
+ exports.FourNumberHelper = FourNumberHelper;
10212
10304
  exports.FrameData = FrameData;
10213
10305
  exports.GroupData = GroupData;
10214
10306
  exports.ImageData = ImageData;
@@ -10305,6 +10397,7 @@ var LeaferUI = function(exports) {
10305
10397
  exports.defineDataProcessor = defineDataProcessor;
10306
10398
  exports.defineKey = defineKey;
10307
10399
  exports.defineLeafAttr = defineLeafAttr;
10400
+ exports.dimType = dimType;
10308
10401
  exports.doBoundsType = doBoundsType;
10309
10402
  exports.doStrokeType = doStrokeType;
10310
10403
  exports.effectType = effectType;
@@ -10346,8 +10439,8 @@ var LeaferUI = function(exports) {
10346
10439
  exports.sortType = sortType;
10347
10440
  exports.strokeType = strokeType;
10348
10441
  exports.surfaceType = surfaceType;
10349
- exports.tempBounds = tempBounds$1;
10350
- exports.tempMatrix = tempMatrix$1;
10442
+ exports.tempBounds = tempBounds$2;
10443
+ exports.tempMatrix = tempMatrix$2;
10351
10444
  exports.tempPoint = tempPoint$2;
10352
10445
  exports.tryToNumber = tryToNumber;
10353
10446
  exports.useCanvas = useCanvas;