@leafer/core 1.9.4 → 1.9.5
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 +33 -24
- package/lib/core.esm.js +32 -25
- package/lib/core.esm.min.js +1 -1
- package/lib/core.esm.min.js.map +1 -1
- package/lib/core.min.cjs +1 -1
- package/lib/core.min.cjs.map +1 -1
- package/package.json +17 -17
- package/src/index.ts +1 -1
- package/types/index.d.ts +1 -1
package/lib/core.cjs
CHANGED
|
@@ -138,6 +138,9 @@ class LeafData {
|
|
|
138
138
|
const {path: path} = this;
|
|
139
139
|
return path && path.length === 6 && path[0] === 1;
|
|
140
140
|
}
|
|
141
|
+
get __usePathBox() {
|
|
142
|
+
return this.__pathInputed;
|
|
143
|
+
}
|
|
141
144
|
get __blendMode() {
|
|
142
145
|
if (this.eraser && this.eraser !== "path") return "destination-out";
|
|
143
146
|
const {blendMode: blendMode} = this;
|
|
@@ -2223,15 +2226,15 @@ class LeaferCanvasBase extends Canvas {
|
|
|
2223
2226
|
DataHelper.copyAttrs(s, size, canvasSizeAttrs);
|
|
2224
2227
|
canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
|
|
2225
2228
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2226
|
-
|
|
2227
|
-
this.updateViewSize();
|
|
2228
|
-
this.smooth = this.config.smooth;
|
|
2229
|
-
}
|
|
2229
|
+
this.updateViewSize();
|
|
2230
2230
|
this.updateClientBounds();
|
|
2231
|
-
if (this.context
|
|
2232
|
-
this.
|
|
2233
|
-
this.
|
|
2234
|
-
|
|
2231
|
+
if (this.context) {
|
|
2232
|
+
this.smooth = this.config.smooth;
|
|
2233
|
+
if (!this.unreal && takeCanvas) {
|
|
2234
|
+
this.clearWorld(takeCanvas.bounds);
|
|
2235
|
+
this.copyWorld(takeCanvas);
|
|
2236
|
+
takeCanvas.recycle();
|
|
2237
|
+
}
|
|
2235
2238
|
}
|
|
2236
2239
|
}
|
|
2237
2240
|
updateViewSize() {}
|
|
@@ -2545,7 +2548,7 @@ const RectHelper = {
|
|
|
2545
2548
|
}
|
|
2546
2549
|
};
|
|
2547
2550
|
|
|
2548
|
-
const {sin: sin$1, cos: cos$1, atan2: atan2$1, ceil: ceil, abs: abs$1, PI: PI, sqrt: sqrt$1, pow: pow} = Math;
|
|
2551
|
+
const {sin: sin$1, cos: cos$1, hypot: hypot, atan2: atan2$1, ceil: ceil, abs: abs$1, PI: PI, sqrt: sqrt$1, pow: pow} = Math;
|
|
2549
2552
|
|
|
2550
2553
|
const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
|
|
2551
2554
|
|
|
@@ -2616,9 +2619,11 @@ const BezierHelper = {
|
|
|
2616
2619
|
const CBy = toY - y1;
|
|
2617
2620
|
let startRadian = atan2$1(BAy, BAx);
|
|
2618
2621
|
let endRadian = atan2$1(CBy, CBx);
|
|
2622
|
+
const lenBA = hypot(BAx, BAy);
|
|
2623
|
+
const lenCB = hypot(CBx, CBy);
|
|
2619
2624
|
let totalRadian = endRadian - startRadian;
|
|
2620
2625
|
if (totalRadian < 0) totalRadian += PI2;
|
|
2621
|
-
if (
|
|
2626
|
+
if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$1(totalRadian - PI) < 1e-12) {
|
|
2622
2627
|
if (data) data.push(L$6, x1, y1);
|
|
2623
2628
|
if (setPointBounds) {
|
|
2624
2629
|
setPoint$1(setPointBounds, fromX, fromY);
|
|
@@ -3210,11 +3215,7 @@ class PathCreator {
|
|
|
3210
3215
|
this.set(path);
|
|
3211
3216
|
}
|
|
3212
3217
|
set(path) {
|
|
3213
|
-
|
|
3214
|
-
this.__path = isString(path) ? PathHelper.parse(path) : path;
|
|
3215
|
-
} else {
|
|
3216
|
-
this.__path = [];
|
|
3217
|
-
}
|
|
3218
|
+
this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
|
|
3218
3219
|
return this;
|
|
3219
3220
|
}
|
|
3220
3221
|
beginPath() {
|
|
@@ -3584,14 +3585,18 @@ const PathCorner = {
|
|
|
3584
3585
|
}
|
|
3585
3586
|
};
|
|
3586
3587
|
|
|
3587
|
-
|
|
3588
|
+
function path(path) {
|
|
3589
|
+
return new PathCreator(path);
|
|
3590
|
+
}
|
|
3591
|
+
|
|
3592
|
+
const pen = path();
|
|
3593
|
+
|
|
3594
|
+
PathHelper.creator = path();
|
|
3588
3595
|
|
|
3589
3596
|
PathHelper.parse = PathConvert.parse;
|
|
3590
3597
|
|
|
3591
3598
|
PathHelper.convertToCanvasData = PathConvert.toCanvasData;
|
|
3592
3599
|
|
|
3593
|
-
const pen = new PathCreator;
|
|
3594
|
-
|
|
3595
3600
|
const {drawRoundRect: drawRoundRect} = RectHelper;
|
|
3596
3601
|
|
|
3597
3602
|
function roundRect(drawer) {
|
|
@@ -3956,7 +3961,7 @@ const ImageManager = {
|
|
|
3956
3961
|
return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
|
|
3957
3962
|
},
|
|
3958
3963
|
isFormat(format, config) {
|
|
3959
|
-
if (config.format
|
|
3964
|
+
if (config.format) return config.format === format;
|
|
3960
3965
|
const {url: url} = config;
|
|
3961
3966
|
if (url.startsWith("data:")) {
|
|
3962
3967
|
if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
|
|
@@ -4050,7 +4055,7 @@ class LeaferImage {
|
|
|
4050
4055
|
getFull(_filters) {
|
|
4051
4056
|
return this.view;
|
|
4052
4057
|
}
|
|
4053
|
-
getCanvas(width, height, opacity, _filters, xGap, yGap) {
|
|
4058
|
+
getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
|
|
4054
4059
|
width || (width = this.width);
|
|
4055
4060
|
height || (height = this.height);
|
|
4056
4061
|
if (this.cache) {
|
|
@@ -4066,6 +4071,7 @@ class LeaferImage {
|
|
|
4066
4071
|
const canvas = Platform.origin.createCanvas(max(floor(width + (xGap || 0)), 1), max(floor(height + (yGap || 0)), 1));
|
|
4067
4072
|
const ctx = canvas.getContext("2d");
|
|
4068
4073
|
if (opacity) ctx.globalAlpha = opacity;
|
|
4074
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
4069
4075
|
ctx.drawImage(this.view, 0, 0, width, height);
|
|
4070
4076
|
this.cache = this.use > 1 ? {
|
|
4071
4077
|
data: canvas,
|
|
@@ -4717,8 +4723,9 @@ const L = LeafHelper;
|
|
|
4717
4723
|
|
|
4718
4724
|
const {updateAllMatrix: updateAllMatrix$1, updateMatrix: updateMatrix$1, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange, updateChange: updateChange} = L;
|
|
4719
4725
|
|
|
4720
|
-
function getTempLocal(t,
|
|
4721
|
-
|
|
4726
|
+
function getTempLocal(t, worldPoint) {
|
|
4727
|
+
t.updateLayout();
|
|
4728
|
+
return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
|
|
4722
4729
|
}
|
|
4723
4730
|
|
|
4724
4731
|
const LeafBoundsHelper = {
|
|
@@ -5808,7 +5815,7 @@ const LeafBounds = {
|
|
|
5808
5815
|
__updateBoxBounds(_secondLayout, _bounds) {
|
|
5809
5816
|
const b = this.__layout.boxBounds;
|
|
5810
5817
|
const data = this.__;
|
|
5811
|
-
if (data.
|
|
5818
|
+
if (data.__usePathBox) {
|
|
5812
5819
|
toBounds(data.path, b);
|
|
5813
5820
|
} else {
|
|
5814
5821
|
b.x = 0;
|
|
@@ -6744,7 +6751,7 @@ class LeafLevelList {
|
|
|
6744
6751
|
}
|
|
6745
6752
|
}
|
|
6746
6753
|
|
|
6747
|
-
const version = "1.9.
|
|
6754
|
+
const version = "1.9.5";
|
|
6748
6755
|
|
|
6749
6756
|
exports.AlignHelper = AlignHelper;
|
|
6750
6757
|
|
|
@@ -6966,6 +6973,8 @@ exports.naturalBoundsType = naturalBoundsType;
|
|
|
6966
6973
|
|
|
6967
6974
|
exports.opacityType = opacityType;
|
|
6968
6975
|
|
|
6976
|
+
exports.path = path;
|
|
6977
|
+
|
|
6969
6978
|
exports.pathInputType = pathInputType;
|
|
6970
6979
|
|
|
6971
6980
|
exports.pathType = pathType;
|
package/lib/core.esm.js
CHANGED
|
@@ -136,6 +136,9 @@ class LeafData {
|
|
|
136
136
|
const {path: path} = this;
|
|
137
137
|
return path && path.length === 6 && path[0] === 1;
|
|
138
138
|
}
|
|
139
|
+
get __usePathBox() {
|
|
140
|
+
return this.__pathInputed;
|
|
141
|
+
}
|
|
139
142
|
get __blendMode() {
|
|
140
143
|
if (this.eraser && this.eraser !== "path") return "destination-out";
|
|
141
144
|
const {blendMode: blendMode} = this;
|
|
@@ -2221,15 +2224,15 @@ class LeaferCanvasBase extends Canvas {
|
|
|
2221
2224
|
DataHelper.copyAttrs(s, size, canvasSizeAttrs);
|
|
2222
2225
|
canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
|
|
2223
2226
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2224
|
-
|
|
2225
|
-
this.updateViewSize();
|
|
2226
|
-
this.smooth = this.config.smooth;
|
|
2227
|
-
}
|
|
2227
|
+
this.updateViewSize();
|
|
2228
2228
|
this.updateClientBounds();
|
|
2229
|
-
if (this.context
|
|
2230
|
-
this.
|
|
2231
|
-
this.
|
|
2232
|
-
|
|
2229
|
+
if (this.context) {
|
|
2230
|
+
this.smooth = this.config.smooth;
|
|
2231
|
+
if (!this.unreal && takeCanvas) {
|
|
2232
|
+
this.clearWorld(takeCanvas.bounds);
|
|
2233
|
+
this.copyWorld(takeCanvas);
|
|
2234
|
+
takeCanvas.recycle();
|
|
2235
|
+
}
|
|
2233
2236
|
}
|
|
2234
2237
|
}
|
|
2235
2238
|
updateViewSize() {}
|
|
@@ -2543,7 +2546,7 @@ const RectHelper = {
|
|
|
2543
2546
|
}
|
|
2544
2547
|
};
|
|
2545
2548
|
|
|
2546
|
-
const {sin: sin$1, cos: cos$1, atan2: atan2$1, ceil: ceil, abs: abs$1, PI: PI, sqrt: sqrt$1, pow: pow} = Math;
|
|
2549
|
+
const {sin: sin$1, cos: cos$1, hypot: hypot, atan2: atan2$1, ceil: ceil, abs: abs$1, PI: PI, sqrt: sqrt$1, pow: pow} = Math;
|
|
2547
2550
|
|
|
2548
2551
|
const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
|
|
2549
2552
|
|
|
@@ -2614,9 +2617,11 @@ const BezierHelper = {
|
|
|
2614
2617
|
const CBy = toY - y1;
|
|
2615
2618
|
let startRadian = atan2$1(BAy, BAx);
|
|
2616
2619
|
let endRadian = atan2$1(CBy, CBx);
|
|
2620
|
+
const lenBA = hypot(BAx, BAy);
|
|
2621
|
+
const lenCB = hypot(CBx, CBy);
|
|
2617
2622
|
let totalRadian = endRadian - startRadian;
|
|
2618
2623
|
if (totalRadian < 0) totalRadian += PI2;
|
|
2619
|
-
if (
|
|
2624
|
+
if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$1(totalRadian - PI) < 1e-12) {
|
|
2620
2625
|
if (data) data.push(L$6, x1, y1);
|
|
2621
2626
|
if (setPointBounds) {
|
|
2622
2627
|
setPoint$1(setPointBounds, fromX, fromY);
|
|
@@ -3208,11 +3213,7 @@ class PathCreator {
|
|
|
3208
3213
|
this.set(path);
|
|
3209
3214
|
}
|
|
3210
3215
|
set(path) {
|
|
3211
|
-
|
|
3212
|
-
this.__path = isString(path) ? PathHelper.parse(path) : path;
|
|
3213
|
-
} else {
|
|
3214
|
-
this.__path = [];
|
|
3215
|
-
}
|
|
3216
|
+
this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
|
|
3216
3217
|
return this;
|
|
3217
3218
|
}
|
|
3218
3219
|
beginPath() {
|
|
@@ -3582,14 +3583,18 @@ const PathCorner = {
|
|
|
3582
3583
|
}
|
|
3583
3584
|
};
|
|
3584
3585
|
|
|
3585
|
-
|
|
3586
|
+
function path(path) {
|
|
3587
|
+
return new PathCreator(path);
|
|
3588
|
+
}
|
|
3589
|
+
|
|
3590
|
+
const pen = path();
|
|
3591
|
+
|
|
3592
|
+
PathHelper.creator = path();
|
|
3586
3593
|
|
|
3587
3594
|
PathHelper.parse = PathConvert.parse;
|
|
3588
3595
|
|
|
3589
3596
|
PathHelper.convertToCanvasData = PathConvert.toCanvasData;
|
|
3590
3597
|
|
|
3591
|
-
const pen = new PathCreator;
|
|
3592
|
-
|
|
3593
3598
|
const {drawRoundRect: drawRoundRect} = RectHelper;
|
|
3594
3599
|
|
|
3595
3600
|
function roundRect(drawer) {
|
|
@@ -3954,7 +3959,7 @@ const ImageManager = {
|
|
|
3954
3959
|
return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
|
|
3955
3960
|
},
|
|
3956
3961
|
isFormat(format, config) {
|
|
3957
|
-
if (config.format
|
|
3962
|
+
if (config.format) return config.format === format;
|
|
3958
3963
|
const {url: url} = config;
|
|
3959
3964
|
if (url.startsWith("data:")) {
|
|
3960
3965
|
if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
|
|
@@ -4048,7 +4053,7 @@ class LeaferImage {
|
|
|
4048
4053
|
getFull(_filters) {
|
|
4049
4054
|
return this.view;
|
|
4050
4055
|
}
|
|
4051
|
-
getCanvas(width, height, opacity, _filters, xGap, yGap) {
|
|
4056
|
+
getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
|
|
4052
4057
|
width || (width = this.width);
|
|
4053
4058
|
height || (height = this.height);
|
|
4054
4059
|
if (this.cache) {
|
|
@@ -4064,6 +4069,7 @@ class LeaferImage {
|
|
|
4064
4069
|
const canvas = Platform.origin.createCanvas(max(floor(width + (xGap || 0)), 1), max(floor(height + (yGap || 0)), 1));
|
|
4065
4070
|
const ctx = canvas.getContext("2d");
|
|
4066
4071
|
if (opacity) ctx.globalAlpha = opacity;
|
|
4072
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
4067
4073
|
ctx.drawImage(this.view, 0, 0, width, height);
|
|
4068
4074
|
this.cache = this.use > 1 ? {
|
|
4069
4075
|
data: canvas,
|
|
@@ -4715,8 +4721,9 @@ const L = LeafHelper;
|
|
|
4715
4721
|
|
|
4716
4722
|
const {updateAllMatrix: updateAllMatrix$1, updateMatrix: updateMatrix$1, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange, updateChange: updateChange} = L;
|
|
4717
4723
|
|
|
4718
|
-
function getTempLocal(t,
|
|
4719
|
-
|
|
4724
|
+
function getTempLocal(t, worldPoint) {
|
|
4725
|
+
t.updateLayout();
|
|
4726
|
+
return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
|
|
4720
4727
|
}
|
|
4721
4728
|
|
|
4722
4729
|
const LeafBoundsHelper = {
|
|
@@ -5806,7 +5813,7 @@ const LeafBounds = {
|
|
|
5806
5813
|
__updateBoxBounds(_secondLayout, _bounds) {
|
|
5807
5814
|
const b = this.__layout.boxBounds;
|
|
5808
5815
|
const data = this.__;
|
|
5809
|
-
if (data.
|
|
5816
|
+
if (data.__usePathBox) {
|
|
5810
5817
|
toBounds(data.path, b);
|
|
5811
5818
|
} else {
|
|
5812
5819
|
b.x = 0;
|
|
@@ -6742,6 +6749,6 @@ class LeafLevelList {
|
|
|
6742
6749
|
}
|
|
6743
6750
|
}
|
|
6744
6751
|
|
|
6745
|
-
const version = "1.9.
|
|
6752
|
+
const version = "1.9.5";
|
|
6746
6753
|
|
|
6747
|
-
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, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useModule, version, visibleType };
|
|
6754
|
+
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 };
|