change: set the coordinate precision to 1 pixel

This commit is contained in:
lilong.129
2023-09-21 21:44:36 +08:00
parent b5612dbb2a
commit d1c30000a7
2 changed files with 5 additions and 6 deletions

View File

@@ -7,8 +7,6 @@ import (
"time"
"github.com/httprunner/funplugin"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
)
var (
@@ -438,8 +436,8 @@ type PointF struct {
}
func (p PointF) IsIdentical(p2 PointF) bool {
return builtin.IsZeroFloat64(math.Abs(p.X-p2.X)) &&
builtin.IsZeroFloat64(math.Abs(p.Y-p2.Y))
// set the coordinate precision to 1 pixel
return math.Abs(p.X-p2.X) < 1 && math.Abs(p.Y-p2.Y) < 1
}
type Rect struct {

View File

@@ -483,9 +483,10 @@ func (box Box) IsEmpty() bool {
}
func (box Box) IsIdentical(box2 Box) bool {
// set the coordinate precision to 1 pixel
return box.Point.IsIdentical(box2.Point) &&
builtin.IsZeroFloat64(math.Abs(box.Width-box2.Width)) &&
builtin.IsZeroFloat64(math.Abs(box.Height-box2.Height))
math.Abs(box.Width-box2.Width) < 1 &&
math.Abs(box.Height-box2.Height) < 1
}
func (box Box) Center() PointF {