Added all missing conversion functions from the different point & rectangle formats.
Renamed To{32,64} to To{F32,F} for consistency.
This commit is contained in:
parent
18bac571b8
commit
c81df8279f
@ -142,8 +142,8 @@ func (p PointF) Sub(q PointF) PointF {
|
||||
return PointF{p.X - q.X, p.Y - q.Y}
|
||||
}
|
||||
|
||||
// To32 transforms the point p into a PointF32.
|
||||
func (p PointF) To32() PointF32 {
|
||||
// ToF32 transforms the point p into a PointF32.
|
||||
func (p PointF) ToF32() PointF32 {
|
||||
return PointF32{float32(p.X), float32(p.Y)}
|
||||
}
|
||||
|
||||
|
@ -142,8 +142,8 @@ func (p PointF32) Sub(q PointF32) PointF32 {
|
||||
return PointF32{p.X - q.X, p.Y - q.Y}
|
||||
}
|
||||
|
||||
// To64 transforms the point p into a PointF.
|
||||
func (p PointF32) To64() PointF {
|
||||
// ToF transforms the point p into a PointF.
|
||||
func (p PointF32) ToF() PointF {
|
||||
return PointF{float64(p.X), float64(p.Y)}
|
||||
}
|
||||
|
||||
|
@ -51,3 +51,9 @@ func (r Rectangle) Sub(p Point) Rectangle {
|
||||
Point{r.Max.X - p.X, r.Max.Y - p.Y},
|
||||
}
|
||||
}
|
||||
|
||||
// ToF returns the floating point representation of r.
|
||||
func (r Rectangle) ToF() RectangleF { return RectangleF{Min: r.Min.ToF(), Max: r.Max.ToF()} }
|
||||
|
||||
// ToF32 returns the floating point representation of r.
|
||||
func (r Rectangle) ToF32() RectangleF32 { return RectangleF32{Min: r.Min.ToF32(), Max: r.Max.ToF32()} }
|
||||
|
@ -77,3 +77,9 @@ func (r RectangleF) Sub(p PointF) RectangleF {
|
||||
PointF{r.Max.X - p.X, r.Max.Y - p.Y},
|
||||
}
|
||||
}
|
||||
|
||||
// ToF32 returns the floating point representation of r.
|
||||
func (r RectangleF) ToF32() RectangleF32 { return RectangleF32{Min: r.Min.ToF32(), Max: r.Max.ToF32()} }
|
||||
|
||||
// ToInt returns the integer point representation of r.
|
||||
func (r RectangleF) ToInt() Rectangle { return Rectangle{Min: r.Min.ToInt(), Max: r.Max.ToInt()} }
|
||||
|
@ -77,3 +77,9 @@ func (r RectangleF32) Sub(p PointF32) RectangleF32 {
|
||||
PointF32{r.Max.X - p.X, r.Max.Y - p.Y},
|
||||
}
|
||||
}
|
||||
|
||||
// ToInt returns the integer point representation of r.
|
||||
func (r RectangleF32) ToInt() Rectangle { return Rectangle{Min: r.Min.ToInt(), Max: r.Max.ToInt()} }
|
||||
|
||||
// ToF returns the floating point representation of r.
|
||||
func (r RectangleF32) ToF() RectangleF { return RectangleF{Min: r.Min.ToF(), Max: r.Max.ToF()} }
|
||||
|
Loading…
Reference in New Issue
Block a user