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()
- func (r Rect) Bottom() float64
- 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)
- func (r *Rect) InsetUniform(amount float64)
- func (r *Rect) Intersect(other Rect)
- func (r Rect) Intersects(other Rect) bool
- func (r Rect) IsEmpty() bool
- func (r Rect) Max() Point
- func (r Rect) Right() float64
- func (r Rect) String() string
- func (r *Rect) Union(other Rect)
- type Size
- func (s *Size) Add(size Size)
- func (s *Size) AddInsets(insets Insets)
- func (s *Size) ConstrainForHint(hint Size)
- func (s *Size) GrowToInteger()
- func (s *Size) Max(other Size)
- func (s *Size) Min(other Size)
- func (s Size) String() string
- func (s *Size) Subtract(size Size)
- func (s *Size) SubtractInsets(insets Insets)
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.
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.
type Rect ¶
Rect defines a rectangle.
func NewRectPtr ¶ added in v1.8.0
NewRectPtr creates a new *Rect.
func (*Rect) Align ¶
func (r *Rect) Align()
Align modifies this rectangle to align with integer coordinates that would encompass the original 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.
func (Rect) Intersects ¶ added in v1.6.0
Intersects returns true if this rect and the other rect 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) AddInsets ¶
AddInsets modifies this Size by expanding it to accommodate the specified insets.
func (*Size) ConstrainForHint ¶
ConstrainForHint ensures this size is no larger than the hint. Hint values less than one are ignored.
func (*Size) GrowToInteger ¶
func (s *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.
func (*Size) Min ¶
Min modifies this Size to contain the smallest values between itself and 'other'.
func (*Size) SubtractInsets ¶
SubtractInsets modifies this Size by reducing it to accommodate the specified insets.