|
@@ -1252,7 +1252,7 @@ export default class MathUtil {
|
|
}
|
|
}
|
|
|
|
|
|
getHitInfoForThreeBezier(position, curve, rang = 3) {
|
|
getHitInfoForThreeBezier(position, curve, rang = 3) {
|
|
- const { x: offsetX, y: offsetY } = position
|
|
|
|
|
|
+ const { x: offsetX, y: offsetY } = position;
|
|
// 用 x 求出对应的 t,用 t 求相应位置的 y,再比较得出的 y 与 offsetY 之间的差值
|
|
// 用 x 求出对应的 t,用 t 求相应位置的 y,再比较得出的 y 与 offsetY 之间的差值
|
|
const tsx = mathUtil.getThreeBezierT(
|
|
const tsx = mathUtil.getThreeBezierT(
|
|
curve.start.x,
|
|
curve.start.x,
|
|
@@ -1273,8 +1273,8 @@ export default class MathUtil {
|
|
if (Math.abs(point.y - offsetY) < rang) {
|
|
if (Math.abs(point.y - offsetY) < rang) {
|
|
return {
|
|
return {
|
|
position: point,
|
|
position: point,
|
|
- distance: mathUtil.getDistance(point, position)
|
|
|
|
- }
|
|
|
|
|
|
+ distance: mathUtil.getDistance(point, position),
|
|
|
|
+ };
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1298,8 +1298,8 @@ export default class MathUtil {
|
|
if (Math.abs(point.x - offsetX) < rang) {
|
|
if (Math.abs(point.x - offsetX) < rang) {
|
|
return {
|
|
return {
|
|
position: point,
|
|
position: point,
|
|
- distance: mathUtil.getDistance(point, position)
|
|
|
|
- }
|
|
|
|
|
|
+ distance: mathUtil.getDistance(point, position),
|
|
|
|
+ };
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1310,8 +1310,8 @@ export default class MathUtil {
|
|
let bezierData = [];
|
|
let bezierData = [];
|
|
bezierData.push(curve.start.x);
|
|
bezierData.push(curve.start.x);
|
|
bezierData.push(curve.start.y);
|
|
bezierData.push(curve.start.y);
|
|
- bezierData.push(curve.control.x);
|
|
|
|
- bezierData.push(curve.control.y);
|
|
|
|
|
|
+ bezierData.push(curve.controls[0].x);
|
|
|
|
+ bezierData.push(curve.controls[0].y);
|
|
bezierData.push(curve.end.x);
|
|
bezierData.push(curve.end.x);
|
|
bezierData.push(curve.end.y);
|
|
bezierData.push(curve.end.y);
|
|
const { isHit, getInfo } = bezierUtil.measureBezier(...bezierData);
|
|
const { isHit, getInfo } = bezierUtil.measureBezier(...bezierData);
|
|
@@ -1321,18 +1321,22 @@ export default class MathUtil {
|
|
distance: mathUtil.getDistance(position, {
|
|
distance: mathUtil.getDistance(position, {
|
|
x: point[0],
|
|
x: point[0],
|
|
y: point[1],
|
|
y: point[1],
|
|
- })
|
|
|
|
|
|
+ }),
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
getHitInfoForCurves(pos, curves) {
|
|
getHitInfoForCurves(pos, curves) {
|
|
let joinInfo;
|
|
let joinInfo;
|
|
for (const curve of curves) {
|
|
for (const curve of curves) {
|
|
- const tempJoinInfo = curve.controls.length === 2
|
|
|
|
- ? mathUtil.getHitInfoForThreeBezier(pos, curve, 8)
|
|
|
|
- : mathUtil.getHitInfoForTwoBezier(pos.x, curve)
|
|
|
|
|
|
+ const tempJoinInfo =
|
|
|
|
+ curve.controls.length === 2
|
|
|
|
+ ? mathUtil.getHitInfoForThreeBezier(pos, curve, 8)
|
|
|
|
+ : mathUtil.getHitInfoForTwoBezier(pos.x, curve);
|
|
|
|
|
|
- if (!joinInfo || (tempJoinInfo && tempJoinInfo.distance < joinInfo.distance)) {
|
|
|
|
|
|
+ if (
|
|
|
|
+ !joinInfo ||
|
|
|
|
+ (tempJoinInfo && tempJoinInfo.distance < joinInfo.distance)
|
|
|
|
+ ) {
|
|
joinInfo = tempJoinInfo;
|
|
joinInfo = tempJoinInfo;
|
|
}
|
|
}
|
|
}
|
|
}
|