生成直线改为按照sortNum最大最小值
This commit is contained in:
parent
de933d7203
commit
9cb8b56e0b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user