@leafer-draw/miniapp 2.0.8 → 2.1.0

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.
@@ -7079,7 +7079,7 @@ class LeafLevelList {
7079
7079
  }
7080
7080
  }
7081
7081
 
7082
- const version = "2.0.8";
7082
+ const version = "2.1.0";
7083
7083
 
7084
7084
  class LeaferCanvas extends LeaferCanvasBase {
7085
7085
  get allowBackgroundColor() {
@@ -7141,6 +7141,7 @@ class LeaferCanvas extends LeaferCanvasBase {
7141
7141
  updateClientBounds(callback) {
7142
7142
  if (this.viewSelect) Platform.miniapp.getBounds(this.viewSelect).then(bounds => {
7143
7143
  this.clientBounds = bounds;
7144
+ this.updateViewSize();
7144
7145
  if (callback) callback();
7145
7146
  });
7146
7147
  }
@@ -7240,7 +7241,7 @@ function useCanvas(_canvasType, app) {
7240
7241
  },
7241
7242
  loadImage(src, _crossOrigin, _leaferImage) {
7242
7243
  return new Promise((resolve, reject) => {
7243
- const img = Platform.canvas.view.createImage();
7244
+ const img = Platform.getCanvas().view.createImage();
7244
7245
  img.onload = () => {
7245
7246
  resolve(img);
7246
7247
  };
@@ -7335,21 +7336,25 @@ function useCanvas(_canvasType, app) {
7335
7336
  };
7336
7337
  Platform.canvas = Creator.canvas();
7337
7338
  Platform.conicGradientSupport = !!Platform.canvas.context.createConicGradient;
7339
+ defineKey(Platform, "devicePixelRatio", {
7340
+ get() {
7341
+ return Math.max(1, app.getWindowInfo ? app.getWindowInfo().pixelRatio : app.getSystemInfoSync().pixelRatio);
7342
+ }
7343
+ });
7338
7344
  }
7339
7345
 
7340
7346
  Platform.name = "miniapp";
7341
7347
 
7348
+ Platform.getCanvas = function() {
7349
+ const {renderCanvas: renderCanvas} = Platform;
7350
+ return renderCanvas && renderCanvas.view ? renderCanvas : Platform.canvas;
7351
+ };
7352
+
7342
7353
  Platform.requestRender = function(render) {
7343
- const {view: view} = Platform.renderCanvas || Platform.canvas;
7354
+ const {view: view} = Platform.getCanvas();
7344
7355
  view.requestAnimationFrame ? view.requestAnimationFrame(render) : setTimeout(render, 16);
7345
7356
  };
7346
7357
 
7347
- defineKey(Platform, "devicePixelRatio", {
7348
- get() {
7349
- return Math.max(1, wx.getWindowInfo ? wx.getWindowInfo().pixelRatio : wx.getSystemInfoSync().pixelRatio);
7350
- }
7351
- });
7352
-
7353
7358
  class Watcher {
7354
7359
  get childrenChanged() {
7355
7360
  return this.hasAdd || this.hasRemove || this.hasVisible;
@@ -8039,8 +8044,8 @@ class UIData extends LeafData {
8039
8044
  return this.__getRealStrokeWidth();
8040
8045
  }
8041
8046
  get __maxStrokeWidth() {
8042
- const t = this;
8043
- return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth;
8047
+ const t = this, strokeWidth = t.__hasStrokeSides || t.strokeWidth;
8048
+ return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, strokeWidth) : strokeWidth;
8044
8049
  }
8045
8050
  get __hasMultiPaint() {
8046
8051
  const t = this;
@@ -8141,6 +8146,10 @@ class UIData extends LeafData {
8141
8146
  }
8142
8147
  return strokeWidth;
8143
8148
  }
8149
+ __checkComplex() {
8150
+ const t = this;
8151
+ stintSet$3(t, "__complex", t.__isFills || t.__isStrokes || t.cornerRadius || t.__useEffect);
8152
+ }
8144
8153
  __setPaint(attrName, value) {
8145
8154
  this.__setInput(attrName, value);
8146
8155
  const layout = this.__leaf.__layout;
@@ -8375,7 +8384,7 @@ const UIRender = {
8375
8384
  data.__useEffect = !!(shadow || otherEffect);
8376
8385
  }
8377
8386
  data.__checkSingle();
8378
- stintSet$2(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
8387
+ data.__checkComplex();
8379
8388
  },
8380
8389
  __drawFast(canvas, options) {
8381
8390
  drawFast(this, canvas, options);
@@ -9424,11 +9433,16 @@ let Polygon = class Polygon extends UI {
9424
9433
  if (data.points) {
9425
9434
  drawPoints$1(path, data.points, data.curve, data.closed);
9426
9435
  } else {
9427
- const {width: width, height: height, sides: sides} = data;
9436
+ const {width: width, height: height, sides: sides, startAngle: startAngle} = data;
9428
9437
  const rx = width / 2, ry = height / 2;
9429
- moveTo$2(path, rx, 0);
9438
+ let startRadian = 0, radian;
9439
+ if (startAngle) {
9440
+ startRadian = startAngle * OneRadian;
9441
+ moveTo$2(path, rx + rx * sin$1(startRadian), ry - ry * cos$1(startRadian));
9442
+ } else moveTo$2(path, rx, 0);
9430
9443
  for (let i = 1; i < sides; i++) {
9431
- lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
9444
+ radian = i * 2 * PI$1 / sides + startRadian;
9445
+ lineTo$2(path, rx + rx * sin$1(radian), ry - ry * cos$1(radian));
9432
9446
  }
9433
9447
  closePath$1(path);
9434
9448
  }
@@ -9439,6 +9453,8 @@ __decorate([ dataProcessor(PolygonData) ], Polygon.prototype, "__", void 0);
9439
9453
 
9440
9454
  __decorate([ pathType(3) ], Polygon.prototype, "sides", void 0);
9441
9455
 
9456
+ __decorate([ pathType(0) ], Polygon.prototype, "startAngle", void 0);
9457
+
9442
9458
  __decorate([ pathType() ], Polygon.prototype, "points", void 0);
9443
9459
 
9444
9460
  __decorate([ pathType(0) ], Polygon.prototype, "curve", void 0);
@@ -9454,12 +9470,17 @@ let Star = class Star extends UI {
9454
9470
  return "Star";
9455
9471
  }
9456
9472
  __updatePath() {
9457
- const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9473
+ const {width: width, height: height, corners: corners, innerRadius: innerRadius, startAngle: startAngle} = this.__;
9458
9474
  const rx = width / 2, ry = height / 2;
9459
9475
  const path = this.__.path = [];
9460
- moveTo$1(path, rx, 0);
9476
+ let startRadian = 0, radian;
9477
+ if (startAngle) {
9478
+ startRadian = startAngle * OneRadian;
9479
+ moveTo$1(path, rx + rx * sin(startRadian), ry - ry * cos(startRadian));
9480
+ } else moveTo$1(path, rx, 0);
9461
9481
  for (let i = 1; i < corners * 2; i++) {
9462
- lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
9482
+ radian = i * PI / corners + startRadian;
9483
+ lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(radian), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(radian));
9463
9484
  }
9464
9485
  closePath(path);
9465
9486
  }
@@ -9471,6 +9492,8 @@ __decorate([ pathType(5) ], Star.prototype, "corners", void 0);
9471
9492
 
9472
9493
  __decorate([ pathType(.382) ], Star.prototype, "innerRadius", void 0);
9473
9494
 
9495
+ __decorate([ pathType(0) ], Star.prototype, "startAngle", void 0);
9496
+
9474
9497
  Star = __decorate([ registerUI() ], Star);
9475
9498
 
9476
9499
  const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
@@ -9829,7 +9852,8 @@ let Pen = class Pen extends Group {
9829
9852
  return this;
9830
9853
  }
9831
9854
  paint() {
9832
- if (!this.pathElement.__layout.boxChanged) this.pathElement.forceUpdate("path");
9855
+ const {pathElement: pathElement} = this;
9856
+ if (!pathElement.__layout.boxChanged) pathElement.forceUpdate("path");
9833
9857
  }
9834
9858
  };
9835
9859
 
@@ -9913,6 +9937,8 @@ function stroke(stroke, ui, canvas, renderOptions) {
9913
9937
  if (!data.__strokeWidth) return;
9914
9938
  if (data.__font) {
9915
9939
  Paint.strokeText(stroke, ui, canvas, renderOptions);
9940
+ } else if (data.__pathForStroke) {
9941
+ Paint.fillStroke(stroke, ui, canvas, renderOptions);
9916
9942
  } else {
9917
9943
  switch (data.strokeAlign) {
9918
9944
  case "center":