Documentation ¶
Overview ¶
Package coords keeps coordinates-related structs and their utilities for the UI system.
Index ¶
- func CompareBoundsWithMargin(a, b Rect, margin int) bool
- func CompareBoundsWithMargins(a, b Rect, ml, mt, mr, mb int) bool
- type Point
- type Rect
- func (r Rect) Bottom() int
- func (r Rect) BottomCenter() Point
- func (r Rect) BottomLeft() Point
- func (r Rect) BottomRight() Point
- func (r Rect) CenterPoint() Point
- func (r Rect) CenterX() int
- func (r Rect) CenterY() int
- func (r Rect) Contains(other Rect) bool
- func (r Rect) Empty() bool
- func (r Rect) Equals(r2 Rect) bool
- func (r Rect) Intersection(other Rect) Rect
- func (r Rect) LeftCenter() Point
- func (r Rect) Right() int
- func (r Rect) RightCenter() Point
- func (r Rect) Size() Size
- func (r Rect) String() string
- func (r Rect) TopLeft() Point
- func (r Rect) TopRight() Point
- func (r Rect) WithInset(dw, dh int) Rect
- func (r Rect) WithOffset(dl, dt int) Rect
- type Size
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareBoundsWithMargin ¶
CompareBoundsWithMargin returns true if the given two bounds have the same value allowing the same margin in all directions.
func CompareBoundsWithMargins ¶
CompareBoundsWithMargins returns true if the given two bounds have the same value allowing the provided margins.
Types ¶
type Point ¶
Point represents a location.
type Rect ¶
type Rect struct { Left int `json:"left"` Top int `json:"top"` Width int `json:"width"` Height int `json:"height"` }
Rect represents a rectangular region.
func ConvertBoundsFromDPToPX ¶
ConvertBoundsFromDPToPX converts the given bounds in dips to pixels based on the given device scale factor. The converted values of Left, Top, Width, and Height are rounded.
func ConvertBoundsFromPXToDP ¶
ConvertBoundsFromPXToDP converts the given bounds in pixels to dips based on the given device scale factor. The converted values of Left, Top, Width, and Height are rounded.
func NewRectLTRB ¶
NewRectLTRB creates a new rect instance for left, top, right, and bottom coordinates.
func (Rect) BottomCenter ¶
BottomCenter returns the center location of the bottom edge of the rectangle.
func (Rect) BottomLeft ¶
BottomLeft returns the location of the bottom left of the rectangle.
func (Rect) BottomRight ¶
BottomRight returns the location of the bottom right of the rectangle.
func (Rect) CenterPoint ¶
CenterPoint returns the location of the center of the rectangle.
func (Rect) Contains ¶
Contains returns whether `other` is a rectangle contained within r. A rectangle is considered to contain itself.
func (Rect) Intersection ¶
Intersection returns the intersection of two rectangles, or an empty rectangle if they don't intersect.
func (Rect) LeftCenter ¶
LeftCenter returns the center location of the left edge of the rectangle.
func (Rect) RightCenter ¶
RightCenter returns the center location of the right edge of the rectangle.
func (Rect) WithInset ¶
WithInset returns a new Rect inset by the given amounts. If insetting would cause the rectangle to have negative area, instead an empty rectangle with the same CenterPoint is returned. Note that dw and dh may be negative to outset a rectangle.
func (Rect) WithOffset ¶
WithOffset returns a new Rect offset by the given amounts.