leafer-draw 1.9.6 → 1.9.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.
@@ -423,6 +423,15 @@ const MatrixHelper = {
423
423
  t.c *= scaleY;
424
424
  t.d *= scaleY;
425
425
  },
426
+ pixelScale(t, pixelRatio, to) {
427
+ to || (to = t);
428
+ to.a = t.a * pixelRatio;
429
+ to.b = t.b * pixelRatio;
430
+ to.c = t.c * pixelRatio;
431
+ to.d = t.d * pixelRatio;
432
+ to.e = t.e * pixelRatio;
433
+ to.f = t.f * pixelRatio;
434
+ },
426
435
  scaleOfOuter(t, origin, scaleX, scaleY) {
427
436
  M$6.toInnerPoint(t, origin, tempPoint$3);
428
437
  M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
@@ -922,6 +931,10 @@ class Matrix {
922
931
  this.scaleY *= y || x;
923
932
  return this;
924
933
  }
934
+ pixelScale(pixelRatio) {
935
+ MatrixHelper.pixelScale(this, pixelRatio);
936
+ return this;
937
+ }
925
938
  scaleOfOuter(origin, x, y) {
926
939
  MatrixHelper.scaleOfOuter(this, origin, x, y);
927
940
  return this;
@@ -2146,7 +2159,7 @@ __decorate([ contextMethod() ], Canvas$1.prototype, "measureText", null);
2146
2159
 
2147
2160
  __decorate([ contextMethod() ], Canvas$1.prototype, "strokeText", null);
2148
2161
 
2149
- const {copy: copy$7, multiplyParent: multiplyParent$4} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2162
+ const {copy: copy$7, multiplyParent: multiplyParent$4, pixelScale: pixelScale} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2150
2163
 
2151
2164
  const minSize = {
2152
2165
  width: 1,
@@ -2247,12 +2260,7 @@ class LeaferCanvasBase extends Canvas$1 {
2247
2260
  setWorld(matrix, parentMatrix) {
2248
2261
  const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
2249
2262
  if (parentMatrix) multiplyParent$4(matrix, parentMatrix, w);
2250
- w.a = matrix.a * pixelRatio;
2251
- w.b = matrix.b * pixelRatio;
2252
- w.c = matrix.c * pixelRatio;
2253
- w.d = matrix.d * pixelRatio;
2254
- w.e = matrix.e * pixelRatio;
2255
- w.f = matrix.f * pixelRatio;
2263
+ pixelScale(matrix, pixelRatio, w);
2256
2264
  if (pixelSnap) {
2257
2265
  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),
2258
2266
  w.f = round$1(w.f);
@@ -4265,6 +4273,18 @@ function surfaceType(defaultValue) {
4265
4273
  }));
4266
4274
  }
4267
4275
 
4276
+ function dimType(defaultValue) {
4277
+ return decorateLeafAttr(defaultValue, key => attr({
4278
+ set(value) {
4279
+ if (this.__setAttr(key, value)) {
4280
+ const data = this.__;
4281
+ DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
4282
+ this.__layout.surfaceChange();
4283
+ }
4284
+ }
4285
+ }));
4286
+ }
4287
+
4268
4288
  function opacityType(defaultValue) {
4269
4289
  return decorateLeafAttr(defaultValue, key => attr({
4270
4290
  set(value) {
@@ -4309,7 +4329,7 @@ function sortType(defaultValue) {
4309
4329
  return decorateLeafAttr(defaultValue, key => attr({
4310
4330
  set(value) {
4311
4331
  if (this.__setAttr(key, value)) {
4312
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
4332
+ this.__layout.surfaceChange();
4313
4333
  this.waitParent(() => {
4314
4334
  this.parent.__layout.childrenSortChange();
4315
4335
  });
@@ -4346,7 +4366,7 @@ function hitType(defaultValue) {
4346
4366
  set(value) {
4347
4367
  if (this.__setAttr(key, value)) {
4348
4368
  this.__layout.hitCanvasChanged = true;
4349
- if (Debug.showBounds === "hit") this.__layout.surfaceChanged || this.__layout.surfaceChange();
4369
+ if (Debug.showBounds === "hit") this.__layout.surfaceChange();
4350
4370
  if (this.leafer) this.leafer.updateCursor();
4351
4371
  }
4352
4372
  }
@@ -5861,6 +5881,7 @@ const LeafRender = {
5861
5881
  if (options.shape) return this.__renderShape(canvas, options);
5862
5882
  if (this.__worldOpacity) {
5863
5883
  const data = this.__;
5884
+ if (data.bright && !options.topRendering) return options.topList.add(this);
5864
5885
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5865
5886
  canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5866
5887
  if (this.__.__single) {
@@ -5909,7 +5930,9 @@ const BranchRender = {
5909
5930
  this.__nowWorld = this.__getNowWorld(options);
5910
5931
  if (this.__worldOpacity) {
5911
5932
  const data = this.__;
5912
- if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5933
+ if (data.__useDim) {
5934
+ 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);
5935
+ }
5913
5936
  if (data.__single && !this.isBranchLeaf) {
5914
5937
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5915
5938
  const tempCanvas = canvas.getSameCanvas(false, true);
@@ -6751,7 +6774,7 @@ class LeafLevelList {
6751
6774
  }
6752
6775
  }
6753
6776
 
6754
- const version = "1.9.6";
6777
+ const version = "1.9.7";
6755
6778
 
6756
6779
  const debug$4 = Debug.get("LeaferCanvas");
6757
6780
 
@@ -7511,7 +7534,7 @@ class Renderer {
7511
7534
  };
7512
7535
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
7513
7536
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
7514
- this.target.__render(canvas, options);
7537
+ Platform.render(this.target, canvas, options);
7515
7538
  this.renderBounds = realBounds = realBounds || bounds;
7516
7539
  this.renderOptions = options;
7517
7540
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
@@ -7604,6 +7627,15 @@ Object.assign(Creator, {
7604
7627
 
7605
7628
  Platform.layout = Layouter.fullLayout;
7606
7629
 
7630
+ Platform.render = function(target, canvas, options) {
7631
+ const topOptions = Object.assign(Object.assign({}, options), {
7632
+ topRendering: true
7633
+ });
7634
+ options.topList = new LeafList;
7635
+ target.__render(canvas, options);
7636
+ if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
7637
+ };
7638
+
7607
7639
  function effectType(defaultValue) {
7608
7640
  return decorateLeafAttr(defaultValue, key => attr({
7609
7641
  set(value) {
@@ -8379,9 +8411,9 @@ __decorate([ visibleType(true) ], UI.prototype, "visible", void 0);
8379
8411
 
8380
8412
  __decorate([ surfaceType(false) ], UI.prototype, "locked", void 0);
8381
8413
 
8382
- __decorate([ surfaceType(false) ], UI.prototype, "dim", void 0);
8414
+ __decorate([ dimType(false) ], UI.prototype, "dim", void 0);
8383
8415
 
8384
- __decorate([ surfaceType(false) ], UI.prototype, "dimskip", void 0);
8416
+ __decorate([ dimType(false) ], UI.prototype, "dimskip", void 0);
8385
8417
 
8386
8418
  __decorate([ sortType(0) ], UI.prototype, "zIndex", void 0);
8387
8419
 
@@ -11212,4 +11244,4 @@ Object.assign(Effect, EffectModule);
11212
11244
 
11213
11245
  useCanvas();
11214
11246
 
11215
- export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
11247
+ export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };