@leafer/core 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.
package/lib/core.cjs CHANGED
@@ -425,6 +425,15 @@ const MatrixHelper = {
425
425
  t.c *= scaleY;
426
426
  t.d *= scaleY;
427
427
  },
428
+ pixelScale(t, pixelRatio, to) {
429
+ to || (to = t);
430
+ to.a = t.a * pixelRatio;
431
+ to.b = t.b * pixelRatio;
432
+ to.c = t.c * pixelRatio;
433
+ to.d = t.d * pixelRatio;
434
+ to.e = t.e * pixelRatio;
435
+ to.f = t.f * pixelRatio;
436
+ },
428
437
  scaleOfOuter(t, origin, scaleX, scaleY) {
429
438
  M$6.toInnerPoint(t, origin, tempPoint$3);
430
439
  M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
@@ -924,6 +933,10 @@ class Matrix {
924
933
  this.scaleY *= y || x;
925
934
  return this;
926
935
  }
936
+ pixelScale(pixelRatio) {
937
+ MatrixHelper.pixelScale(this, pixelRatio);
938
+ return this;
939
+ }
927
940
  scaleOfOuter(origin, x, y) {
928
941
  MatrixHelper.scaleOfOuter(this, origin, x, y);
929
942
  return this;
@@ -2148,7 +2161,7 @@ __decorate([ contextMethod() ], Canvas.prototype, "measureText", null);
2148
2161
 
2149
2162
  __decorate([ contextMethod() ], Canvas.prototype, "strokeText", null);
2150
2163
 
2151
- const {copy: copy$5, multiplyParent: multiplyParent$3} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2164
+ const {copy: copy$5, multiplyParent: multiplyParent$3, pixelScale: pixelScale} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2152
2165
 
2153
2166
  const minSize = {
2154
2167
  width: 1,
@@ -2249,12 +2262,7 @@ class LeaferCanvasBase extends Canvas {
2249
2262
  setWorld(matrix, parentMatrix) {
2250
2263
  const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
2251
2264
  if (parentMatrix) multiplyParent$3(matrix, parentMatrix, w);
2252
- w.a = matrix.a * pixelRatio;
2253
- w.b = matrix.b * pixelRatio;
2254
- w.c = matrix.c * pixelRatio;
2255
- w.d = matrix.d * pixelRatio;
2256
- w.e = matrix.e * pixelRatio;
2257
- w.f = matrix.f * pixelRatio;
2265
+ pixelScale(matrix, pixelRatio, w);
2258
2266
  if (pixelSnap) {
2259
2267
  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),
2260
2268
  w.f = round$1(w.f);
@@ -4267,6 +4275,18 @@ function surfaceType(defaultValue) {
4267
4275
  }));
4268
4276
  }
4269
4277
 
4278
+ function dimType(defaultValue) {
4279
+ return decorateLeafAttr(defaultValue, key => attr({
4280
+ set(value) {
4281
+ if (this.__setAttr(key, value)) {
4282
+ const data = this.__;
4283
+ DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
4284
+ this.__layout.surfaceChange();
4285
+ }
4286
+ }
4287
+ }));
4288
+ }
4289
+
4270
4290
  function opacityType(defaultValue) {
4271
4291
  return decorateLeafAttr(defaultValue, key => attr({
4272
4292
  set(value) {
@@ -4311,7 +4331,7 @@ function sortType(defaultValue) {
4311
4331
  return decorateLeafAttr(defaultValue, key => attr({
4312
4332
  set(value) {
4313
4333
  if (this.__setAttr(key, value)) {
4314
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
4334
+ this.__layout.surfaceChange();
4315
4335
  this.waitParent(() => {
4316
4336
  this.parent.__layout.childrenSortChange();
4317
4337
  });
@@ -4348,7 +4368,7 @@ function hitType(defaultValue) {
4348
4368
  set(value) {
4349
4369
  if (this.__setAttr(key, value)) {
4350
4370
  this.__layout.hitCanvasChanged = true;
4351
- if (Debug.showBounds === "hit") this.__layout.surfaceChanged || this.__layout.surfaceChange();
4371
+ if (Debug.showBounds === "hit") this.__layout.surfaceChange();
4352
4372
  if (this.leafer) this.leafer.updateCursor();
4353
4373
  }
4354
4374
  }
@@ -5863,6 +5883,7 @@ const LeafRender = {
5863
5883
  if (options.shape) return this.__renderShape(canvas, options);
5864
5884
  if (this.__worldOpacity) {
5865
5885
  const data = this.__;
5886
+ if (data.bright && !options.topRendering) return options.topList.add(this);
5866
5887
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5867
5888
  canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5868
5889
  if (this.__.__single) {
@@ -5911,7 +5932,9 @@ const BranchRender = {
5911
5932
  this.__nowWorld = this.__getNowWorld(options);
5912
5933
  if (this.__worldOpacity) {
5913
5934
  const data = this.__;
5914
- if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5935
+ if (data.__useDim) {
5936
+ 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);
5937
+ }
5915
5938
  if (data.__single && !this.isBranchLeaf) {
5916
5939
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5917
5940
  const tempCanvas = canvas.getSameCanvas(false, true);
@@ -6753,7 +6776,7 @@ class LeafLevelList {
6753
6776
  }
6754
6777
  }
6755
6778
 
6756
- const version = "1.9.6";
6779
+ const version = "1.9.7";
6757
6780
 
6758
6781
  exports.AlignHelper = AlignHelper;
6759
6782
 
@@ -6927,6 +6950,8 @@ exports.defineKey = defineKey;
6927
6950
 
6928
6951
  exports.defineLeafAttr = defineLeafAttr;
6929
6952
 
6953
+ exports.dimType = dimType;
6954
+
6930
6955
  exports.doBoundsType = doBoundsType;
6931
6956
 
6932
6957
  exports.doStrokeType = doStrokeType;
package/lib/core.esm.js CHANGED
@@ -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.prototype, "measureText", null);
2146
2159
 
2147
2160
  __decorate([ contextMethod() ], Canvas.prototype, "strokeText", null);
2148
2161
 
2149
- const {copy: copy$5, multiplyParent: multiplyParent$3} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2162
+ const {copy: copy$5, multiplyParent: multiplyParent$3, 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 {
2247
2260
  setWorld(matrix, parentMatrix) {
2248
2261
  const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
2249
2262
  if (parentMatrix) multiplyParent$3(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,6 +6774,6 @@ class LeafLevelList {
6751
6774
  }
6752
6775
  }
6753
6776
 
6754
- const version = "1.9.6";
6777
+ const version = "1.9.7";
6755
6778
 
6756
- export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, 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, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useModule, version, visibleType };
6779
+ export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, 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, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useModule, version, visibleType };