@leafer/core 2.1.5 → 2.1.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 +20 -13
- package/lib/core.esm.js +20 -13
- 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
|
@@ -765,15 +765,15 @@ const PointHelper = {
|
|
|
765
765
|
t.x += (t.x - origin.x) * (scaleX - 1);
|
|
766
766
|
t.y += (t.y - origin.y) * (scaleY - 1);
|
|
767
767
|
},
|
|
768
|
-
rotate(t, rotation, origin) {
|
|
768
|
+
rotate(t, rotation, origin, radiusX = 1, radiusY = 1) {
|
|
769
769
|
if (!origin) origin = P$5.defaultPoint;
|
|
770
770
|
rotation *= OneRadian;
|
|
771
771
|
const cosR = cos$2(rotation);
|
|
772
772
|
const sinR = sin$2(rotation);
|
|
773
|
-
const rx = t.x - origin.x;
|
|
774
|
-
const ry = t.y - origin.y;
|
|
775
|
-
t.x = origin.x + rx * cosR - ry * sinR;
|
|
776
|
-
t.y = origin.y + rx * sinR + ry * cosR;
|
|
773
|
+
const rx = (t.x - origin.x) / radiusX;
|
|
774
|
+
const ry = (t.y - origin.y) / radiusY;
|
|
775
|
+
t.x = origin.x + (rx * cosR - ry * sinR) * radiusX;
|
|
776
|
+
t.y = origin.y + (rx * sinR + ry * cosR) * radiusY;
|
|
777
777
|
},
|
|
778
778
|
tempToInnerOf(t, matrix) {
|
|
779
779
|
const {tempPoint: temp} = P$5;
|
|
@@ -833,8 +833,8 @@ const PointHelper = {
|
|
|
833
833
|
getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
|
|
834
834
|
return min$1(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3));
|
|
835
835
|
},
|
|
836
|
-
getAngle(t, to) {
|
|
837
|
-
return getAtan2(t, to) / OneRadian;
|
|
836
|
+
getAngle(t, to, radiusX, radiusY) {
|
|
837
|
+
return getAtan2(t, to, radiusX, radiusY) / OneRadian;
|
|
838
838
|
},
|
|
839
839
|
getRotation(t, origin, to, toOrigin) {
|
|
840
840
|
if (!toOrigin) toOrigin = origin;
|
|
@@ -848,8 +848,8 @@ const PointHelper = {
|
|
|
848
848
|
const d = toY - toOriginY;
|
|
849
849
|
return Math.atan2(a * d - b * c, a * c + b * d);
|
|
850
850
|
},
|
|
851
|
-
getAtan2(t, to) {
|
|
852
|
-
return atan2$2(to.y - t.y, to.x - t.x);
|
|
851
|
+
getAtan2(t, to, radiusX = 1, radiusY = 1) {
|
|
852
|
+
return atan2$2((to.y - t.y) / radiusY, (to.x - t.x) / radiusX);
|
|
853
853
|
},
|
|
854
854
|
getDistancePoint(t, to, distance, changeTo, fromTo) {
|
|
855
855
|
const r = getAtan2(t, to);
|
|
@@ -3715,7 +3715,7 @@ const {arcTo: arcTo} = PathCommandDataHelper;
|
|
|
3715
3715
|
|
|
3716
3716
|
const PathCorner = {
|
|
3717
3717
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3718
|
-
let command, lastCommand, commandLen;
|
|
3718
|
+
let command, lastCommand, commandLen, startXIndex, startYIndex, smoothLen;
|
|
3719
3719
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3720
3720
|
if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
|
|
3721
3721
|
const len = data.length, three = len === 9;
|
|
@@ -3724,6 +3724,11 @@ const PathCorner = {
|
|
|
3724
3724
|
command = data[i];
|
|
3725
3725
|
switch (command) {
|
|
3726
3726
|
case M:
|
|
3727
|
+
smoothLen = smooth.length;
|
|
3728
|
+
if (smoothLen && lastCommand !== Z) {
|
|
3729
|
+
smooth[startXIndex] = startX;
|
|
3730
|
+
smooth[startYIndex] = startY;
|
|
3731
|
+
}
|
|
3727
3732
|
startX = lastX = data[i + 1];
|
|
3728
3733
|
startY = lastY = data[i + 2];
|
|
3729
3734
|
i += 3;
|
|
@@ -3734,6 +3739,8 @@ const PathCorner = {
|
|
|
3734
3739
|
} else {
|
|
3735
3740
|
smooth.push(M, startX, startY);
|
|
3736
3741
|
}
|
|
3742
|
+
startXIndex = smoothLen + 1;
|
|
3743
|
+
startYIndex = smoothLen + 2;
|
|
3737
3744
|
break;
|
|
3738
3745
|
|
|
3739
3746
|
case L$1:
|
|
@@ -3772,8 +3779,8 @@ const PathCorner = {
|
|
|
3772
3779
|
lastCommand = command;
|
|
3773
3780
|
}
|
|
3774
3781
|
if (command !== Z) {
|
|
3775
|
-
smooth[
|
|
3776
|
-
smooth[
|
|
3782
|
+
smooth[startXIndex] = startX;
|
|
3783
|
+
smooth[startYIndex] = startY;
|
|
3777
3784
|
}
|
|
3778
3785
|
return smooth;
|
|
3779
3786
|
}
|
|
@@ -6969,7 +6976,7 @@ class LeafLevelList {
|
|
|
6969
6976
|
}
|
|
6970
6977
|
}
|
|
6971
6978
|
|
|
6972
|
-
const version = "2.1.
|
|
6979
|
+
const version = "2.1.7";
|
|
6973
6980
|
|
|
6974
6981
|
exports.AlignHelper = AlignHelper;
|
|
6975
6982
|
|
package/lib/core.esm.js
CHANGED
|
@@ -763,15 +763,15 @@ const PointHelper = {
|
|
|
763
763
|
t.x += (t.x - origin.x) * (scaleX - 1);
|
|
764
764
|
t.y += (t.y - origin.y) * (scaleY - 1);
|
|
765
765
|
},
|
|
766
|
-
rotate(t, rotation, origin) {
|
|
766
|
+
rotate(t, rotation, origin, radiusX = 1, radiusY = 1) {
|
|
767
767
|
if (!origin) origin = P$5.defaultPoint;
|
|
768
768
|
rotation *= OneRadian;
|
|
769
769
|
const cosR = cos$2(rotation);
|
|
770
770
|
const sinR = sin$2(rotation);
|
|
771
|
-
const rx = t.x - origin.x;
|
|
772
|
-
const ry = t.y - origin.y;
|
|
773
|
-
t.x = origin.x + rx * cosR - ry * sinR;
|
|
774
|
-
t.y = origin.y + rx * sinR + ry * cosR;
|
|
771
|
+
const rx = (t.x - origin.x) / radiusX;
|
|
772
|
+
const ry = (t.y - origin.y) / radiusY;
|
|
773
|
+
t.x = origin.x + (rx * cosR - ry * sinR) * radiusX;
|
|
774
|
+
t.y = origin.y + (rx * sinR + ry * cosR) * radiusY;
|
|
775
775
|
},
|
|
776
776
|
tempToInnerOf(t, matrix) {
|
|
777
777
|
const {tempPoint: temp} = P$5;
|
|
@@ -831,8 +831,8 @@ const PointHelper = {
|
|
|
831
831
|
getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
|
|
832
832
|
return min$1(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3));
|
|
833
833
|
},
|
|
834
|
-
getAngle(t, to) {
|
|
835
|
-
return getAtan2(t, to) / OneRadian;
|
|
834
|
+
getAngle(t, to, radiusX, radiusY) {
|
|
835
|
+
return getAtan2(t, to, radiusX, radiusY) / OneRadian;
|
|
836
836
|
},
|
|
837
837
|
getRotation(t, origin, to, toOrigin) {
|
|
838
838
|
if (!toOrigin) toOrigin = origin;
|
|
@@ -846,8 +846,8 @@ const PointHelper = {
|
|
|
846
846
|
const d = toY - toOriginY;
|
|
847
847
|
return Math.atan2(a * d - b * c, a * c + b * d);
|
|
848
848
|
},
|
|
849
|
-
getAtan2(t, to) {
|
|
850
|
-
return atan2$2(to.y - t.y, to.x - t.x);
|
|
849
|
+
getAtan2(t, to, radiusX = 1, radiusY = 1) {
|
|
850
|
+
return atan2$2((to.y - t.y) / radiusY, (to.x - t.x) / radiusX);
|
|
851
851
|
},
|
|
852
852
|
getDistancePoint(t, to, distance, changeTo, fromTo) {
|
|
853
853
|
const r = getAtan2(t, to);
|
|
@@ -3713,7 +3713,7 @@ const {arcTo: arcTo} = PathCommandDataHelper;
|
|
|
3713
3713
|
|
|
3714
3714
|
const PathCorner = {
|
|
3715
3715
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3716
|
-
let command, lastCommand, commandLen;
|
|
3716
|
+
let command, lastCommand, commandLen, startXIndex, startYIndex, smoothLen;
|
|
3717
3717
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3718
3718
|
if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
|
|
3719
3719
|
const len = data.length, three = len === 9;
|
|
@@ -3722,6 +3722,11 @@ const PathCorner = {
|
|
|
3722
3722
|
command = data[i];
|
|
3723
3723
|
switch (command) {
|
|
3724
3724
|
case M:
|
|
3725
|
+
smoothLen = smooth.length;
|
|
3726
|
+
if (smoothLen && lastCommand !== Z) {
|
|
3727
|
+
smooth[startXIndex] = startX;
|
|
3728
|
+
smooth[startYIndex] = startY;
|
|
3729
|
+
}
|
|
3725
3730
|
startX = lastX = data[i + 1];
|
|
3726
3731
|
startY = lastY = data[i + 2];
|
|
3727
3732
|
i += 3;
|
|
@@ -3732,6 +3737,8 @@ const PathCorner = {
|
|
|
3732
3737
|
} else {
|
|
3733
3738
|
smooth.push(M, startX, startY);
|
|
3734
3739
|
}
|
|
3740
|
+
startXIndex = smoothLen + 1;
|
|
3741
|
+
startYIndex = smoothLen + 2;
|
|
3735
3742
|
break;
|
|
3736
3743
|
|
|
3737
3744
|
case L$1:
|
|
@@ -3770,8 +3777,8 @@ const PathCorner = {
|
|
|
3770
3777
|
lastCommand = command;
|
|
3771
3778
|
}
|
|
3772
3779
|
if (command !== Z) {
|
|
3773
|
-
smooth[
|
|
3774
|
-
smooth[
|
|
3780
|
+
smooth[startXIndex] = startX;
|
|
3781
|
+
smooth[startYIndex] = startY;
|
|
3775
3782
|
}
|
|
3776
3783
|
return smooth;
|
|
3777
3784
|
}
|
|
@@ -6967,6 +6974,6 @@ class LeafLevelList {
|
|
|
6967
6974
|
}
|
|
6968
6975
|
}
|
|
6969
6976
|
|
|
6970
|
-
const version = "2.1.
|
|
6977
|
+
const version = "2.1.7";
|
|
6971
6978
|
|
|
6972
6979
|
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, FourNumberHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferFilm, LeaferImage, LeaferVideo, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, UnitConvertHelper, 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 };
|