github.com/xxf098/lite-proxy@v0.15.1-0.20230422081941-12c69f323218/web/render/point.go (about) 1 package render 2 3 import ( 4 "math" 5 6 "golang.org/x/image/math/fixed" 7 ) 8 9 type Point struct { 10 X, Y float64 11 } 12 13 func (a Point) Fixed() fixed.Point26_6 { 14 return fixp(a.X, a.Y) 15 } 16 17 func (a Point) Distance(b Point) float64 { 18 return math.Hypot(a.X-b.X, a.Y-b.Y) 19 } 20 21 func (a Point) Interpolate(b Point, t float64) Point { 22 x := a.X + (b.X-a.X)*t 23 y := a.Y + (b.Y-a.Y)*t 24 return Point{x, y} 25 }