Documentation ¶
Overview ¶
Package geom provides geometry primitives.
Index ¶
- func PointSegmentDistance(s1, s2, p Point) float64
- func PointSegmentDistanceSquared(s1, s2, p Point) float64
- type Insets
- type Point
- type Rect
- func (r *Rect) Align() *Rect
- func (r Rect) Bottom() float64
- func (r Rect) BottomLeft() Point
- func (r Rect) BottomRight() Point
- func (r Rect) Center() Point
- func (r Rect) CenterX() float64
- func (r Rect) CenterY() float64
- func (r Rect) ContainsPoint(pt Point) bool
- func (r Rect) ContainsRect(in Rect) bool
- func (r *Rect) CopyAndZeroLocation() Rect
- func (r *Rect) Inset(insets Insets) *Rect
- func (r *Rect) InsetUniform(amount float64) *Rect
- func (r *Rect) Intersect(other Rect) *Rect
- func (r Rect) Intersects(other Rect) bool
- func (r Rect) IntersectsLine(start, end Point) bool
- func (r Rect) IsEmpty() bool
- func (r Rect) Max() Point
- func (r Rect) Right() float64
- func (r Rect) String() string
- func (r Rect) TopLeft() Point
- func (r Rect) TopRight() Point
- func (r *Rect) Union(other Rect) *Rect
- type Size
- func (s *Size) Add(size Size) *Size
- func (s *Size) AddInsets(insets Insets) *Size
- func (s *Size) ConstrainForHint(hint Size) *Size
- func (s *Size) GrowToInteger() *Size
- func (s *Size) Max(other Size) *Size
- func (s *Size) Min(other Size) *Size
- func (s Size) String() string
- func (s *Size) Subtract(size Size) *Size
- func (s *Size) SubtractInsets(insets Insets) *Size
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PointSegmentDistance ¶ added in v1.13.0
PointSegmentDistance returns the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this function returns 0.
func PointSegmentDistanceSquared ¶ added in v1.13.0
PointSegmentDistanceSquared returns the square of the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this function returns 0.
Types ¶
type Insets ¶
Insets defines margins on each side of a rectangle.
func NewHorizontalInsets ¶
NewHorizontalInsets creates a new Insets whose left and right edges have the specified value.
func NewUniformInsets ¶
NewUniformInsets creates a new Insets whose edges all have the same value.
func NewVerticalInsets ¶
NewVerticalInsets creates a new Insets whose top and bottom edges have the specified value.
func (*Insets) Add ¶
Add modifies this Insets by adding the supplied Insets. Returns itself for easy chaining.
type Point ¶
type Point struct {
X, Y float64
}
Point defines a location.
func LineIntersection ¶ added in v1.13.0
LineIntersection determines the intersection of two lines, if any. A return of no points indicates no intersection. One point indicates intersection at a single point. Two points indicates an overlapping line segment.
func NewPointPtr ¶ added in v1.8.0
NewPointPtr creates a new *Point.
func (*Point) Add ¶
Add modifies this Point by adding the supplied coordinates. Returns itself for easy chaining.
type Rect ¶
Rect defines a rectangle.
func NewRectPtr ¶ added in v1.8.0
NewRectPtr creates a new *Rect.
func (*Rect) Align ¶
Align modifies this rectangle to align with integer coordinates that would encompass the original rectangle. Returns itself for easy chaining.
func (Rect) BottomLeft ¶ added in v1.28.0
BottomLeft returns the bottom-left point of the rectangle.
func (Rect) BottomRight ¶ added in v1.28.0
BottomRight returns the bottom-right point of the rectangle.
func (Rect) ContainsPoint ¶
ContainsPoint returns true if the coordinates are within the Rect.
func (Rect) ContainsRect ¶
ContainsRect returns true if this Rect fully contains the passed in Rect.
func (*Rect) CopyAndZeroLocation ¶
CopyAndZeroLocation creates a new copy of the Rect and sets the location of the copy to 0,0.
func (*Rect) InsetUniform ¶
InsetUniform insets this Rect by the specified amount on all sides. Positive values make the Rect smaller, while negative values make it larger. Returns itself for easy chaining.
func (*Rect) Intersect ¶
Intersect this Rect with another Rect, storing the result into this Rect. Returns itself for easy chaining.
func (Rect) Intersects ¶ added in v1.6.0
Intersects returns true if this rect and the other rect intersect.
func (Rect) IntersectsLine ¶ added in v1.28.0
IntersectsLine returns true if this rect and the line described by start and end intersect.
type Size ¶
type Size struct {
Width, Height float64
}
Size defines a width and height.
func NewSizePtr ¶ added in v1.8.0
NewSizePtr creates a new *Size.
func (*Size) Add ¶
Add modifies this Size by adding the supplied Size. Returns itself for easy chaining.
func (*Size) AddInsets ¶
AddInsets modifies this Size by expanding it to accommodate the specified insets. Returns itself for easy chaining.
func (*Size) ConstrainForHint ¶
ConstrainForHint ensures this size is no larger than the hint. Hint values less than one are ignored. Returns itself for easy chaining.
func (*Size) GrowToInteger ¶
GrowToInteger modifies this Size such that its width and height are both the smallest integers greater than or equal to their original values. Returns itself for easy chaining.
func (*Size) Max ¶
Max modifies this Size to contain the largest values between itself and 'other'. Returns itself for easy chaining.
func (*Size) Min ¶
Min modifies this Size to contain the smallest values between itself and 'other'. Returns itself for easy chaining.
func (*Size) Subtract ¶
Subtract modifies this Size by subtracting the supplied Size. Returns itself for easy chaining.
func (*Size) SubtractInsets ¶
SubtractInsets modifies this Size by reducing it to accommodate the specified insets. Returns itself for easy chaining.