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.
package/dist/web.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$9(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$9(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$9(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$9} = B;
1434
+ const {add: add$2, copy: copy$9} = 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$8, multiplyParent: multiplyParent$4} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2041
+ const {copy: copy$8, 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$1 = 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$5} = BoundsHelper;
4610
+ const {toOuterOf: toOuterOf$3, getPoints: getPoints, copy: copy$5} = 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$4} = BoundsHelper;
5419
+ const {toOuterOf: toOuterOf$2, copyAndSpread: copyAndSpread$2, copy: copy$4} = 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$4(layout.renderBounds, layout.strokeBounds);
5527
+ const layout = this.__layout, {renderSpread: renderSpread} = layout;
5528
+ isNumber(renderSpread) && renderSpread <= 0 ? copy$4(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$3, move: move} = PointHelper;
5622
+ const {toOuterOf: toOuterOf$1} = BoundsHelper;
5623
+ const {copy: copy$3, 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
  const debug$5 = Debug.get("LeaferCanvas");
6356
6414
  class LeaferCanvas extends LeaferCanvasBase {
6357
6415
  set zIndex(zIndex) {
@@ -6384,7 +6442,7 @@ var LeaferUI = function(exports) {
6384
6442
  }
6385
6443
  if (Platform.syncDomFont && !this.parentView) {
6386
6444
  style.display = "none";
6387
- document.body.appendChild(this.view);
6445
+ if (document.body) document.body.appendChild(this.view);
6388
6446
  }
6389
6447
  this.__createContext();
6390
6448
  if (!this.autoLayout) this.resize(config);
@@ -6955,6 +7013,7 @@ var LeaferUI = function(exports) {
6955
7013
  usePartRender: true,
6956
7014
  maxFPS: 120
6957
7015
  };
7016
+ this.frames = [];
6958
7017
  this.target = target;
6959
7018
  this.canvas = canvas;
6960
7019
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -7084,7 +7143,7 @@ var LeaferUI = function(exports) {
7084
7143
  };
7085
7144
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
7086
7145
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
7087
- this.target.__render(canvas, options);
7146
+ Platform.render(this.target, canvas, options);
7088
7147
  this.renderBounds = realBounds = realBounds || bounds;
7089
7148
  this.renderOptions = options;
7090
7149
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
@@ -7107,12 +7166,15 @@ var LeaferUI = function(exports) {
7107
7166
  const target = this.target;
7108
7167
  if (this.requestTime || !target) return;
7109
7168
  if (target.parentApp) return target.parentApp.requestRender(false);
7110
- const requestTime = this.requestTime = Date.now();
7169
+ this.requestTime = this.frameTime || Date.now();
7111
7170
  const render = () => {
7112
- const nowFPS = 1e3 / (Date.now() - requestTime);
7171
+ const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
7113
7172
  const {maxFPS: maxFPS} = this.config;
7114
- if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7115
- this.FPS = Math.min(120, Math.ceil(nowFPS));
7173
+ if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
7174
+ const {frames: frames} = this;
7175
+ if (frames.length > 30) frames.shift();
7176
+ frames.push(nowFPS);
7177
+ this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
7116
7178
  this.requestTime = 0;
7117
7179
  this.checkRender();
7118
7180
  };
@@ -7353,6 +7415,14 @@ var LeaferUI = function(exports) {
7353
7415
  selector: (target, options) => new Selector(target, options)
7354
7416
  });
7355
7417
  Platform.layout = Layouter.fullLayout;
7418
+ Platform.render = function(target, canvas, options) {
7419
+ const topOptions = Object.assign(Object.assign({}, options), {
7420
+ topRendering: true
7421
+ });
7422
+ options.topList = new LeafList;
7423
+ target.__render(canvas, options);
7424
+ if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
7425
+ };
7356
7426
  function effectType(defaultValue) {
7357
7427
  return decorateLeafAttr(defaultValue, key => attr({
7358
7428
  set(value) {
@@ -7714,39 +7784,40 @@ var LeaferUI = function(exports) {
7714
7784
  return data;
7715
7785
  }
7716
7786
  }
7787
+ const {max: max$2, add: add$1} = FourNumberHelper;
7717
7788
  const UIBounds = {
7718
7789
  __updateStrokeSpread() {
7719
- let width = 0, boxWidth = 0;
7790
+ let spread = 0, boxSpread = 0;
7720
7791
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
7721
7792
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
7722
- boxWidth = width = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7793
+ boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7723
7794
  if (!data.__boxStroke) {
7724
- const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * width;
7795
+ const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
7725
7796
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
7726
- width += Math.max(miterLimitAddWidth, storkeCapAddWidth);
7797
+ spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
7727
7798
  }
7728
7799
  }
7729
- if (data.__useArrow) width += strokeWidth * 5;
7800
+ if (data.__useArrow) spread += strokeWidth * 5;
7730
7801
  if (box) {
7731
- width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
7732
- boxWidth = box.__layout.strokeBoxSpread;
7802
+ spread = max$2(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
7803
+ boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
7733
7804
  }
7734
- this.__layout.strokeBoxSpread = boxWidth;
7735
- return width;
7805
+ this.__layout.strokeBoxSpread = boxSpread;
7806
+ return spread;
7736
7807
  },
7737
7808
  __updateRenderSpread() {
7738
- let width = 0;
7739
- const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7740
- if (shadow) width = Effect.getShadowSpread(this, shadow);
7741
- if (blur) width = Math.max(width, blur);
7742
- if (filter) width += Filter.getSpread(filter);
7743
- if (renderSpread) width += renderSpread;
7744
- let shapeWidth = width = Math.ceil(width);
7745
- 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));
7746
- if (backgroundBlur) shapeWidth = Math.max(shapeWidth, backgroundBlur);
7747
- this.__layout.renderShapeSpread = shapeWidth;
7748
- width += this.__layout.strokeSpread || 0;
7749
- return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7809
+ let spread = 0;
7810
+ const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
7811
+ if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
7812
+ if (blur) spread = max$2(spread, blur);
7813
+ if (filter) spread = add$1(spread, Filter.getSpread(filter));
7814
+ if (renderSpread) spread = add$1(spread, renderSpread);
7815
+ if (strokeSpread) spread = add$1(spread, strokeSpread);
7816
+ let shapeSpread = spread;
7817
+ if (innerShadow) shapeSpread = max$2(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
7818
+ if (backgroundBlur) shapeSpread = max$2(shapeSpread, backgroundBlur);
7819
+ this.__layout.renderShapeSpread = shapeSpread;
7820
+ return box ? max$2(box.__updateRenderSpread(), spread) : spread;
7750
7821
  }
7751
7822
  };
7752
7823
  const {float: float} = MathHelper;
@@ -8070,8 +8141,8 @@ var LeaferUI = function(exports) {
8070
8141
  __decorate([ opacityType(1) ], exports.UI.prototype, "opacity", void 0);
8071
8142
  __decorate([ visibleType(true) ], exports.UI.prototype, "visible", void 0);
8072
8143
  __decorate([ surfaceType(false) ], exports.UI.prototype, "locked", void 0);
8073
- __decorate([ surfaceType(false) ], exports.UI.prototype, "dim", void 0);
8074
- __decorate([ surfaceType(false) ], exports.UI.prototype, "dimskip", void 0);
8144
+ __decorate([ dimType(false) ], exports.UI.prototype, "dim", void 0);
8145
+ __decorate([ dimType(false) ], exports.UI.prototype, "dimskip", void 0);
8075
8146
  __decorate([ sortType(0) ], exports.UI.prototype, "zIndex", void 0);
8076
8147
  __decorate([ maskType(false) ], exports.UI.prototype, "mask", void 0);
8077
8148
  __decorate([ eraserType(false) ], exports.UI.prototype, "eraser", void 0);
@@ -8888,7 +8959,7 @@ var LeaferUI = function(exports) {
8888
8959
  __decorate([ dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
8889
8960
  __decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
8890
8961
  exports.Canvas = __decorate([ registerUI() ], exports.Canvas);
8891
- const {copyAndSpread: copyAndSpread, includes: includes, spread: spread, setList: setList} = BoundsHelper;
8962
+ const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
8892
8963
  exports.Text = class Text extends exports.UI {
8893
8964
  get __tag() {
8894
8965
  return "Text";
@@ -8934,13 +9005,13 @@ var LeaferUI = function(exports) {
8934
9005
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
8935
9006
  }
8936
9007
  __updateRenderSpread() {
8937
- let width = super.__updateRenderSpread();
8938
- if (!width) width = this.isOverflow ? 1 : 0;
8939
- return width;
9008
+ let spread = super.__updateRenderSpread();
9009
+ if (!spread) spread = this.isOverflow ? 1 : 0;
9010
+ return spread;
8940
9011
  }
8941
9012
  __updateRenderBounds() {
8942
9013
  const {renderBounds: renderBounds, renderSpread: renderSpread} = this.__layout;
8943
- copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
9014
+ copyAndSpread$1(renderBounds, this.__.__textBoxBounds, renderSpread);
8944
9015
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
8945
9016
  }
8946
9017
  __updateChange() {
@@ -9299,9 +9370,9 @@ var LeaferUI = function(exports) {
9299
9370
  static setData(data) {
9300
9371
  this.data = data;
9301
9372
  }
9302
- static getValidMove(leaf, start, total, checkLimit = true) {
9303
- const move = leaf.getLocalPoint(total, null, true);
9304
- PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9373
+ static getValidMove(leaf, localStart, worldTotal, checkLimit = true) {
9374
+ const move = leaf.getLocalPoint(worldTotal, null, true);
9375
+ PointHelper.move(move, localStart.x - leaf.x, localStart.y - leaf.y);
9305
9376
  if (checkLimit) this.limitMove(leaf, move);
9306
9377
  DragBoundsHelper.axisMove(leaf, move);
9307
9378
  return move;
@@ -10255,8 +10326,8 @@ var LeaferUI = function(exports) {
10255
10326
  if (isHitPixel) {
10256
10327
  const {renderBounds: renderBounds} = this.__layout;
10257
10328
  const size = Platform.image.hitCanvasSize;
10258
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10259
- const {x: x, y: y, width: width, height: height} = tempBounds$1.set(renderBounds).scale(scale);
10329
+ const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10330
+ const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
10260
10331
  h.resize({
10261
10332
  width: width,
10262
10333
  height: height,
@@ -10343,8 +10414,8 @@ var LeaferUI = function(exports) {
10343
10414
  canvas.hitPixel = function(radiusPoint, offset, scale = 1) {
10344
10415
  let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
10345
10416
  if (offset) x -= offset.x, y -= offset.y;
10346
- tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10347
- const {data: data} = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
10417
+ tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10418
+ const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
10348
10419
  for (let i = 0, len = data.length; i < len; i += 4) {
10349
10420
  if (data[i + 3] > 0) return true;
10350
10421
  }
@@ -10853,23 +10924,27 @@ var LeaferUI = function(exports) {
10853
10924
  out.recycle(ui.__nowWorld);
10854
10925
  }
10855
10926
  }
10856
- const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
10927
+ const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
10928
+ const tempBounds$1 = {};
10857
10929
  function shape(ui, current, options) {
10858
10930
  const canvas = current.getSameCanvas();
10859
- const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
10860
- let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
10931
+ const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
10932
+ const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
10933
+ toOuterOf(layout.strokeSpread ? (copyAndSpread(tempBounds$1, layout.boxBounds, layout.strokeSpread),
10934
+ tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
10935
+ let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
10861
10936
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
10862
- if (currentBounds.includes(nowWorld)) {
10937
+ if (currentBounds.includes(nowWorldShapeBounds)) {
10863
10938
  worldCanvas = canvas;
10864
- bounds = shapeBounds = nowWorld;
10939
+ bounds = shapeBounds = nowWorldShapeBounds;
10940
+ renderBounds = nowWorld;
10865
10941
  } else {
10866
- const {renderShapeSpread: spread} = ui.__layout;
10867
10942
  let worldClipBounds;
10868
10943
  if (Platform.fullImageShadow) {
10869
- worldClipBounds = nowWorld;
10944
+ worldClipBounds = nowWorldShapeBounds;
10870
10945
  } else {
10871
- const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
10872
- worldClipBounds = getIntersectData(spreadBounds, nowWorld);
10946
+ const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
10947
+ worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
10873
10948
  }
10874
10949
  fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
10875
10950
  let {a: fitScaleX, d: fitScaleY} = fitMatrix;
@@ -10879,8 +10954,10 @@ var LeaferUI = function(exports) {
10879
10954
  scaleX *= fitScaleX;
10880
10955
  scaleY *= fitScaleY;
10881
10956
  }
10882
- shapeBounds = getOuterOf(nowWorld, fitMatrix);
10957
+ shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
10883
10958
  bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
10959
+ renderBounds = getOuterOf(nowWorld, fitMatrix);
10960
+ move$1(renderBounds, -fitMatrix.e, -fitMatrix.f);
10884
10961
  const userMatrix = options.matrix;
10885
10962
  if (userMatrix) {
10886
10963
  matrix = new Matrix(fitMatrix);
@@ -10899,6 +10976,7 @@ var LeaferUI = function(exports) {
10899
10976
  matrix: matrix,
10900
10977
  fitMatrix: fitMatrix,
10901
10978
  bounds: bounds,
10979
+ renderBounds: renderBounds,
10902
10980
  worldCanvas: worldCanvas,
10903
10981
  shapeBounds: shapeBounds,
10904
10982
  scaleX: scaleX,
@@ -10996,7 +11074,7 @@ var LeaferUI = function(exports) {
10996
11074
  drawTextStroke: drawTextStroke,
10997
11075
  shape: shape
10998
11076
  };
10999
- let origin = {}, tempMatrix = getMatrixData();
11077
+ let origin = {}, tempMatrix$1 = getMatrixData();
11000
11078
  const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
11001
11079
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
11002
11080
  const transform = get$3();
@@ -11008,12 +11086,12 @@ var LeaferUI = function(exports) {
11008
11086
  }, rotation);
11009
11087
  data.transform = transform;
11010
11088
  }
11011
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
11089
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
11012
11090
  const transform = get$3();
11013
11091
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
11014
- if (clipSize) {
11015
- tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
11016
- multiplyParent(transform, tempMatrix);
11092
+ if (clipScaleX) {
11093
+ tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
11094
+ multiplyParent(transform, tempMatrix$1);
11017
11095
  }
11018
11096
  data.transform = transform;
11019
11097
  }
@@ -11106,7 +11184,12 @@ var LeaferUI = function(exports) {
11106
11184
 
11107
11185
  case "normal":
11108
11186
  case "clip":
11109
- if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
11187
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
11188
+ let clipScaleX, clipScaleY;
11189
+ if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
11190
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
11191
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
11192
+ }
11110
11193
  break;
11111
11194
 
11112
11195
  case "repeat":
@@ -11251,7 +11334,7 @@ var LeaferUI = function(exports) {
11251
11334
  if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
11252
11335
  }
11253
11336
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
11254
- const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
11337
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
11255
11338
  function createPattern(ui, paint, pixelRatio) {
11256
11339
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
11257
11340
  const id = scaleX + "-" + scaleY + "-" + pixelRatio;
@@ -11299,8 +11382,8 @@ var LeaferUI = function(exports) {
11299
11382
  if (transform || scaleX !== 1 || scaleY !== 1) {
11300
11383
  const canvasWidth = width + (xGap || 0);
11301
11384
  const canvasHeight = height + (yGap || 0);
11302
- scaleX /= canvasWidth / max(floor(canvasWidth), 1);
11303
- scaleY /= canvasHeight / max(floor(canvasHeight), 1);
11385
+ scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
11386
+ scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
11304
11387
  if (!imageMatrix) {
11305
11388
  imageMatrix = get$1();
11306
11389
  if (transform) copy$1(imageMatrix, transform);
@@ -11325,17 +11408,15 @@ var LeaferUI = function(exports) {
11325
11408
  if (allowDraw) {
11326
11409
  if (data.repeat) {
11327
11410
  allowDraw = false;
11328
- } else {
11329
- if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
11330
- let {width: width, height: height} = data;
11331
- width *= scaleX * pixelRatio;
11332
- height *= scaleY * pixelRatio;
11333
- if (data.scaleX) {
11334
- width *= data.scaleX;
11335
- height *= data.scaleY;
11336
- }
11337
- allowDraw = width * height > Platform.image.maxCacheSize;
11411
+ } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
11412
+ let {width: width, height: height} = data;
11413
+ width *= scaleX * pixelRatio;
11414
+ height *= scaleY * pixelRatio;
11415
+ if (data.scaleX) {
11416
+ width *= data.scaleX;
11417
+ height *= data.scaleY;
11338
11418
  }
11419
+ allowDraw = width * height > Platform.image.maxCacheSize;
11339
11420
  }
11340
11421
  }
11341
11422
  if (allowDraw) {
@@ -11493,17 +11574,17 @@ var LeaferUI = function(exports) {
11493
11574
  conicGradient: conicGradient,
11494
11575
  getTransform: getTransform
11495
11576
  };
11496
- const {copy: copy, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
11497
- const tempBounds = {};
11577
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
11578
+ const tempBounds = {}, tempMatrix = new Matrix;
11498
11579
  const offsetOutBounds$1 = {};
11499
11580
  function shadow(ui, current, shape) {
11500
- let copyBounds, spreadScale;
11501
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
11581
+ let copyBounds, transform;
11582
+ const {__nowWorld: nowWorld} = ui;
11502
11583
  const {shadow: shadow} = ui.__;
11503
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11584
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11504
11585
  const other = current.getSameCanvas();
11505
11586
  const end = shadow.length - 1;
11506
- toOffsetOutBounds$1(bounds, offsetOutBounds$1);
11587
+ toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
11507
11588
  shadow.forEach((item, index) => {
11508
11589
  let otherScale = 1;
11509
11590
  if (item.scaleFixed) {
@@ -11511,63 +11592,69 @@ var LeaferUI = function(exports) {
11511
11592
  if (sx > 1) otherScale = 1 / sx;
11512
11593
  }
11513
11594
  other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
11514
- spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
11515
- drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
11516
- copyBounds = bounds;
11595
+ transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
11596
+ if (transform) other.setTransform(transform);
11597
+ drawWorldShadow(other, offsetOutBounds$1, shape);
11598
+ if (transform) other.resetTransform();
11599
+ copyBounds = renderBounds;
11517
11600
  if (item.box) {
11518
11601
  other.restore();
11519
11602
  other.save();
11520
11603
  if (worldCanvas) {
11521
- other.copyWorld(other, bounds, nowWorld, "copy");
11604
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
11522
11605
  copyBounds = nowWorld;
11523
11606
  }
11524
11607
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
11525
11608
  }
11526
- if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11609
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11527
11610
  if (end && index < end) other.clearWorld(copyBounds);
11528
11611
  });
11529
11612
  other.recycle(copyBounds);
11530
11613
  }
11531
- function getShadowSpread(_ui, shadow) {
11532
- let width = 0;
11533
- 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));
11534
- return width;
11614
+ function getShadowRenderSpread(_ui, shadow) {
11615
+ let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
11616
+ shadow.forEach(item => {
11617
+ x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
11618
+ top = max(top, spread + blur - y);
11619
+ right = max(right, spread + blur + x);
11620
+ bottom = max(bottom, spread + blur + y);
11621
+ left = max(left, spread + blur - x);
11622
+ });
11623
+ return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
11624
+ }
11625
+ function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
11626
+ if (shadow.spread) {
11627
+ const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
11628
+ tempMatrix.set().scaleOfOuter({
11629
+ x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
11630
+ y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
11631
+ }, spreadScale);
11632
+ return tempMatrix;
11633
+ }
11634
+ return undefined;
11535
11635
  }
11536
- function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
11537
- const {bounds: bounds, shapeBounds: shapeBounds} = shape;
11636
+ function drawWorldShadow(canvas, outBounds, shape) {
11637
+ const {shapeBounds: shapeBounds} = shape;
11638
+ let from, to;
11538
11639
  if (Platform.fullImageShadow) {
11539
11640
  copy(tempBounds, canvas.bounds);
11540
- tempBounds.x += outBounds.x - shapeBounds.x;
11541
- tempBounds.y += outBounds.y - shapeBounds.y;
11542
- if (spreadScale) {
11543
- const {fitMatrix: fitMatrix} = shape;
11544
- tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
11545
- tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
11546
- tempBounds.width *= spreadScale;
11547
- tempBounds.height *= spreadScale;
11548
- }
11549
- canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
11641
+ move(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
11642
+ from = canvas.bounds, to = tempBounds;
11550
11643
  } else {
11551
- if (spreadScale) {
11552
- copy(tempBounds, outBounds);
11553
- tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
11554
- tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
11555
- tempBounds.width *= spreadScale;
11556
- tempBounds.height *= spreadScale;
11557
- }
11558
- canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
11644
+ from = shapeBounds, to = outBounds;
11559
11645
  }
11646
+ canvas.copyWorld(shape.canvas, from, to);
11560
11647
  }
11561
11648
  const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
11562
11649
  const offsetOutBounds = {};
11563
11650
  function innerShadow(ui, current, shape) {
11564
- let copyBounds, spreadScale;
11565
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
11651
+ let copyBounds, transform;
11652
+ const {__nowWorld: nowWorld} = ui;
11566
11653
  const {innerShadow: innerShadow} = ui.__;
11567
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11654
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11568
11655
  const other = current.getSameCanvas();
11569
11656
  const end = innerShadow.length - 1;
11570
- toOffsetOutBounds(bounds, offsetOutBounds);
11657
+ toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
11571
11658
  innerShadow.forEach((item, index) => {
11572
11659
  let otherScale = 1;
11573
11660
  if (item.scaleFixed) {
@@ -11576,16 +11663,17 @@ var LeaferUI = function(exports) {
11576
11663
  }
11577
11664
  other.save();
11578
11665
  other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
11579
- spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
11580
- drawWorldShadow(other, offsetOutBounds, spreadScale, shape);
11666
+ transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
11667
+ if (transform) other.setTransform(transform);
11668
+ drawWorldShadow(other, offsetOutBounds, shape);
11581
11669
  other.restore();
11582
11670
  if (worldCanvas) {
11583
- other.copyWorld(other, bounds, nowWorld, "copy");
11671
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
11584
11672
  other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
11585
11673
  copyBounds = nowWorld;
11586
11674
  } else {
11587
11675
  other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
11588
- copyBounds = bounds;
11676
+ copyBounds = renderBounds;
11589
11677
  }
11590
11678
  other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
11591
11679
  LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
@@ -11593,6 +11681,7 @@ var LeaferUI = function(exports) {
11593
11681
  });
11594
11682
  other.recycle(copyBounds);
11595
11683
  }
11684
+ const getInnerShadowSpread = getShadowRenderSpread;
11596
11685
  function blur(ui, current, origin) {
11597
11686
  const {blur: blur} = ui.__;
11598
11687
  origin.setWorldBlur(blur * ui.__nowWorld.a);
@@ -11605,10 +11694,12 @@ var LeaferUI = function(exports) {
11605
11694
  innerShadow: innerShadow,
11606
11695
  blur: blur,
11607
11696
  backgroundBlur: backgroundBlur,
11608
- getShadowSpread: getShadowSpread,
11697
+ getShadowRenderSpread: getShadowRenderSpread,
11698
+ getShadowTransform: getShadowTransform,
11609
11699
  isTransformShadow(_shadow) {
11610
11700
  return undefined;
11611
- }
11701
+ },
11702
+ getInnerShadowSpread: getInnerShadowSpread
11612
11703
  };
11613
11704
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
11614
11705
  let usedGrayscaleAlpha;
@@ -11622,6 +11713,7 @@ var LeaferUI = function(exports) {
11622
11713
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
11623
11714
  maskCanvas = contentCanvas = null;
11624
11715
  }
11716
+ if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
11625
11717
  maskOpacity = child.__.opacity;
11626
11718
  usedGrayscaleAlpha = false;
11627
11719
  if (mask === "path" || mask === "clipping-path") {
@@ -11639,7 +11731,6 @@ var LeaferUI = function(exports) {
11639
11731
  if (!contentCanvas) contentCanvas = getCanvas(canvas);
11640
11732
  child.__render(maskCanvas, options);
11641
11733
  }
11642
- if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
11643
11734
  continue;
11644
11735
  }
11645
11736
  const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
@@ -12199,6 +12290,7 @@ var LeaferUI = function(exports) {
12199
12290
  exports.Export = Export;
12200
12291
  exports.FileHelper = FileHelper;
12201
12292
  exports.Filter = Filter;
12293
+ exports.FourNumberHelper = FourNumberHelper;
12202
12294
  exports.FrameData = FrameData;
12203
12295
  exports.GroupData = GroupData;
12204
12296
  exports.HitCanvasManager = HitCanvasManager;
@@ -12306,6 +12398,7 @@ var LeaferUI = function(exports) {
12306
12398
  exports.defineDataProcessor = defineDataProcessor;
12307
12399
  exports.defineKey = defineKey;
12308
12400
  exports.defineLeafAttr = defineLeafAttr;
12401
+ exports.dimType = dimType;
12309
12402
  exports.doBoundsType = doBoundsType;
12310
12403
  exports.doStrokeType = doStrokeType;
12311
12404
  exports.effectType = effectType;
@@ -12347,8 +12440,8 @@ var LeaferUI = function(exports) {
12347
12440
  exports.sortType = sortType;
12348
12441
  exports.strokeType = strokeType;
12349
12442
  exports.surfaceType = surfaceType;
12350
- exports.tempBounds = tempBounds$1;
12351
- exports.tempMatrix = tempMatrix$1;
12443
+ exports.tempBounds = tempBounds$2;
12444
+ exports.tempMatrix = tempMatrix$2;
12352
12445
  exports.tempPoint = tempPoint$2;
12353
12446
  exports.tryToNumber = tryToNumber;
12354
12447
  exports.useCanvas = useCanvas;