mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
go.mobile/geom: introduce Rectangle
LGTM=adg R=adg, nigeltao CC=golang-codereviews https://golang.org/cl/151820043
This commit is contained in:
+12
-1
@@ -17,6 +17,7 @@ type Pt float32
|
||||
// Px converts the length to current device pixels.
|
||||
func (p Pt) Px() float32 { return float32(p) * Scale }
|
||||
|
||||
// String returns a string representation of p like "3.2pt".
|
||||
func (p Pt) String() string { return fmt.Sprintf("%.2fpt", p) }
|
||||
|
||||
// Point is a point in a two-dimensional plane.
|
||||
@@ -24,7 +25,17 @@ type Point struct {
|
||||
X, Y Pt
|
||||
}
|
||||
|
||||
func (p Point) String() string { return fmt.Sprintf("Point(%.2f, %.2f)", p.X, p.Y) }
|
||||
// String returns a string representation of p like "(1.2,3.4)".
|
||||
func (p Point) String() string { return fmt.Sprintf("(%.2f,%.2f)", p.X, p.Y) }
|
||||
|
||||
// A Rectangle is region of points.
|
||||
// The top-left point is Min, and the bottom-right point is Max.
|
||||
type Rectangle struct {
|
||||
Min, Max Point
|
||||
}
|
||||
|
||||
// String returns a string representation of r like "(3,4)-(6,5)".
|
||||
func (r Rectangle) String() string { return r.Min.String() + "-" + r.Max.String() }
|
||||
|
||||
// Scale is the number of pixels in a single Pt on the current device.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user