@leafer-ui/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() {
@@ -8696,6 +8722,7 @@ let UI = UI_1 = class UI extends Leaf {
8696
8722
  createProxyData() {
8697
8723
  return undefined;
8698
8724
  }
8725
+ clearProxyData() {}
8699
8726
  find(_condition, _options) {
8700
8727
  return Plugin.need("find");
8701
8728
  }
@@ -8736,7 +8763,7 @@ let UI = UI_1 = class UI extends Leaf {
8736
8763
  __updateRenderPath(updateCache) {
8737
8764
  const data = this.__;
8738
8765
  if (data.path) {
8739
- data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8766
+ data.__pathForRender = data.cornerRadius || data.path.radius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8740
8767
  if (data.__useArrow) PathArrow.addArrows(this, updateCache);
8741
8768
  } else data.__pathForRender && (data.__pathForRender = undefined);
8742
8769
  }
@@ -9569,7 +9596,7 @@ let Ellipse = class Ellipse extends UI {
9569
9596
  }
9570
9597
  }
9571
9598
  if (!open) closePath$2(path);
9572
- if (Platform.ellipseToCurve || data.__useArrow) data.path = this.getPath(true);
9599
+ if (Platform.ellipseToCurve || data.__useArrow || data.cornerRadius) data.path = this.getPath(true);
9573
9600
  }
9574
9601
  };
9575
9602
 
@@ -9595,7 +9622,7 @@ let Polygon = class Polygon extends UI {
9595
9622
  const data = this.__;
9596
9623
  const path = data.path = [];
9597
9624
  if (data.points) {
9598
- drawPoints$1(path, data.points, data.curve, true);
9625
+ drawPoints$1(path, data.points, data.curve, data.closed);
9599
9626
  } else {
9600
9627
  const {width: width, height: height, sides: sides} = data;
9601
9628
  const rx = width / 2, ry = height / 2;
@@ -12075,17 +12102,19 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
12075
12102
  }
12076
12103
 
12077
12104
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
12105
+ let needUpdate = true;
12078
12106
  const data = ui.__;
12079
12107
  if (attrName === "fill" && !data.__naturalWidth) {
12080
12108
  data.__naturalWidth = image.width / data.pixelRatio;
12081
12109
  data.__naturalHeight = image.height / data.pixelRatio;
12082
12110
  if (data.__autoSide) {
12083
12111
  ui.forceUpdate("width");
12112
+ LeafHelper.updateBounds(ui);
12084
12113
  if (ui.__proxyData) {
12085
12114
  ui.setProxyAttr("width", data.width);
12086
12115
  ui.setProxyAttr("height", data.height);
12087
12116
  }
12088
- return false;
12117
+ needUpdate = false;
12089
12118
  }
12090
12119
  }
12091
12120
  if (!leafPaint.data) {
@@ -12095,7 +12124,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
12095
12124
  if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
12096
12125
  }
12097
12126
  if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
12098
- return true;
12127
+ return needUpdate;
12099
12128
  }
12100
12129
 
12101
12130
  function onLoad(ui, event) {
@@ -12545,10 +12574,10 @@ const realFrom = {};
12545
12574
  const realTo = {};
12546
12575
 
12547
12576
  function conicGradient(paint, box) {
12548
- let {from: from, to: to, type: type, opacity: opacity, stretch: stretch} = paint;
12577
+ let {from: from, to: to, type: type, opacity: opacity, rotation: rotation, stretch: stretch} = paint;
12549
12578
  toPoint(from || "center", box, realFrom);
12550
12579
  toPoint(to || "bottom", box, realTo);
12551
- 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));
12580
+ 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));
12552
12581
  const data = {
12553
12582
  type: type,
12554
12583
  style: style