@leafer-draw/miniapp 2.0.5 → 2.0.7

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.
@@ -2896,6 +2896,32 @@ const BezierHelper = {
2896
2896
  getDerivative(t, fromV, v1, v2, toV) {
2897
2897
  const o = 1 - t;
2898
2898
  return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
2899
+ },
2900
+ cut(t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
2901
+ if (t <= 0) return {
2902
+ left: null,
2903
+ right: [ x1, y1, x2, y2, toX, toY ]
2904
+ }; else if (t >= 1) return {
2905
+ left: [ x1, y1, x2, y2, toX, toY ],
2906
+ right: null
2907
+ };
2908
+ const u = 1 - t;
2909
+ const leftX1 = fromX * u + x1 * t;
2910
+ const leftY1 = fromY * u + y1 * t;
2911
+ const P12x = x1 * u + x2 * t;
2912
+ const P12y = y1 * u + y2 * t;
2913
+ const rightX2 = x2 * u + toX * t;
2914
+ const rightY2 = y2 * u + toY * t;
2915
+ const leftX2 = leftX1 * u + P12x * t;
2916
+ const leftY2 = leftY1 * u + P12y * t;
2917
+ const rightX1 = P12x * u + rightX2 * t;
2918
+ const rightY1 = P12y * u + rightY2 * t;
2919
+ const leftX = leftX2 * u + rightX1 * t;
2920
+ const leftY = leftY2 * u + rightY1 * t;
2921
+ return {
2922
+ left: [ leftX1, leftY1, leftX2, leftY2, leftX, leftY ],
2923
+ right: [ rightX1, rightY1, rightX2, rightY2, toX, toY ]
2924
+ };
2899
2925
  }
2900
2926
  };
2901
2927
 
@@ -7053,7 +7079,7 @@ class LeafLevelList {
7053
7079
  }
7054
7080
  }
7055
7081
 
7056
- const version = "2.0.5";
7082
+ const version = "2.0.7";
7057
7083
 
7058
7084
  class LeaferCanvas extends LeaferCanvasBase {
7059
7085
  get allowBackgroundColor() {
@@ -8496,6 +8522,7 @@ let UI = UI_1 = class UI extends Leaf {
8496
8522
  createProxyData() {
8497
8523
  return undefined;
8498
8524
  }
8525
+ clearProxyData() {}
8499
8526
  find(_condition, _options) {
8500
8527
  return Plugin.need("find");
8501
8528
  }
@@ -8536,7 +8563,7 @@ let UI = UI_1 = class UI extends Leaf {
8536
8563
  __updateRenderPath(updateCache) {
8537
8564
  const data = this.__;
8538
8565
  if (data.path) {
8539
- data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8566
+ data.__pathForRender = data.cornerRadius || data.path.radius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8540
8567
  if (data.__useArrow) PathArrow.addArrows(this, updateCache);
8541
8568
  } else data.__pathForRender && (data.__pathForRender = undefined);
8542
8569
  }
@@ -9369,7 +9396,7 @@ let Ellipse = class Ellipse extends UI {
9369
9396
  }
9370
9397
  }
9371
9398
  if (!open) closePath$2(path);
9372
- if (Platform.ellipseToCurve || data.__useArrow) data.path = this.getPath(true);
9399
+ if (Platform.ellipseToCurve || data.__useArrow || data.cornerRadius) data.path = this.getPath(true);
9373
9400
  }
9374
9401
  };
9375
9402
 
@@ -9395,7 +9422,7 @@ let Polygon = class Polygon extends UI {
9395
9422
  const data = this.__;
9396
9423
  const path = data.path = [];
9397
9424
  if (data.points) {
9398
- drawPoints$1(path, data.points, data.curve, true);
9425
+ drawPoints$1(path, data.points, data.curve, data.closed);
9399
9426
  } else {
9400
9427
  const {width: width, height: height, sides: sides} = data;
9401
9428
  const rx = width / 2, ry = height / 2;
@@ -10247,17 +10274,19 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10247
10274
  }
10248
10275
 
10249
10276
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
10277
+ let needUpdate = true;
10250
10278
  const data = ui.__;
10251
10279
  if (attrName === "fill" && !data.__naturalWidth) {
10252
10280
  data.__naturalWidth = image.width / data.pixelRatio;
10253
10281
  data.__naturalHeight = image.height / data.pixelRatio;
10254
10282
  if (data.__autoSide) {
10255
10283
  ui.forceUpdate("width");
10284
+ LeafHelper.updateBounds(ui);
10256
10285
  if (ui.__proxyData) {
10257
10286
  ui.setProxyAttr("width", data.width);
10258
10287
  ui.setProxyAttr("height", data.height);
10259
10288
  }
10260
- return false;
10289
+ needUpdate = false;
10261
10290
  }
10262
10291
  }
10263
10292
  if (!leafPaint.data) {
@@ -10267,7 +10296,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
10267
10296
  if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
10268
10297
  }
10269
10298
  if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
10270
- return true;
10299
+ return needUpdate;
10271
10300
  }
10272
10301
 
10273
10302
  function onLoad(ui, event) {
@@ -10717,10 +10746,10 @@ const realFrom = {};
10717
10746
  const realTo = {};
10718
10747
 
10719
10748
  function conicGradient(paint, box) {
10720
- let {from: from, to: to, type: type, opacity: opacity, stretch: stretch} = paint;
10749
+ let {from: from, to: to, type: type, opacity: opacity, rotation: rotation, stretch: stretch} = paint;
10721
10750
  toPoint(from || "center", box, realFrom);
10722
10751
  toPoint(to || "bottom", box, realTo);
10723
- const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
10752
+ const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(rotation ? rotation * OneRadian : 0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
10724
10753
  const data = {
10725
10754
  type: type,
10726
10755
  style: style