生成直线改为按照sortNum最大最小值

This commit is contained in:
yyy 2025-03-14 10:18:46 +08:00
parent de933d7203
commit 9cb8b56e0b

View File

@ -2029,16 +2029,28 @@ const clickDrawSelectionArea = () => {
// 线
const mapPointsToLine = (points) => {
// locationX
// let minXPoint = points[0]
// let maxXPoint = points[0]
// points.forEach((point) => {
// if (point.locationX < minXPoint.locationX) {
// minXPoint = point
// }
// if (point.locationX > maxXPoint.locationX) {
// maxXPoint = point
// }
// })
// sortNum
let minXPoint = points[0]
let maxXPoint = points[0]
points.forEach((point) => {
if (point.locationX < minXPoint.locationX) {
minXPoint = point
for (let i = 1; i < points.length; i++) {
if (points[i].sortNum < minXPoint.sortNum) {
minXPoint = points[i]
}
if (point.locationX > maxXPoint.locationX) {
maxXPoint = point
if (points[i].sortNum > maxXPoint.sortNum) {
maxXPoint = points[i]
}
})
}
const dx = maxXPoint.locationX - minXPoint.locationX
const dy = maxXPoint.locationY - minXPoint.locationY