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 Matrix2D
- type Point
- type Rect
- func (r *Rect) AddPoint(pt Point) *Rect
- func (r *Rect) Align() *Rect
- func (r Rect) Bottom() float64
- func (r Rect) BottomLeft() Point
- func (r Rect) BottomRight() Point
- func (r Rect) Bounds() Rect
- 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) MarshalText() (text []byte, err error)
- 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
- func (r *Rect) UnmarshalText(text []byte) error
- 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) MarshalText() (text []byte, err error)
- 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
- func (s *Size) UnmarshalText(text []byte) error
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.
func (Insets) MarshalText ¶ added in v1.52.0
MarshalText implements the encoding.TextMarshaler interface.
func (*Insets) Subtract ¶ added in v1.24.0
Subtract modifies this Insets by subtracting the supplied Insets. Returns itself for easy chaining.
func (*Insets) UnmarshalText ¶ added in v1.52.0
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Matrix2D ¶ added in v1.35.0
type Matrix2D struct { ScaleX float64 SkewX float64 TransX float64 SkewY float64 ScaleY float64 TransY float64 }
Matrix2D provides a 2D matrix.
func NewIdentityMatrix2D ¶ added in v1.35.0
func NewIdentityMatrix2D() *Matrix2D
NewIdentityMatrix2D creates a new identity transformation 2D matrix.
func NewRotationByDegreesMatrix2D ¶ added in v1.35.0
NewRotationByDegreesMatrix2D creates a new 2D matrix that rotates by 'degrees'. Positive values are clockwise.
func NewRotationMatrix2D ¶ added in v1.35.0
NewRotationMatrix2D creates a new 2D matrix that rotates by 'radians'. Positive values are clockwise.
func NewScaleMatrix2D ¶ added in v1.35.0
NewScaleMatrix2D creates a new 2D matrix that scales by 'sx' and 'sy'.
func NewTranslationMatrix2D ¶ added in v1.35.0
NewTranslationMatrix2D creates a new 2D matrix that translates by 'tx' and 'ty'.
func (*Matrix2D) Rotate ¶ added in v1.35.0
Rotate this matrix by 'radians'. Positive values are clockwise.
func (*Matrix2D) TransformDistance ¶ added in v1.35.0
TransformDistance returns the result of transforming the distance vector by this matrix. This is similar to TransformPoint(), except that the translation components of the transformation are ignored.
func (*Matrix2D) TransformPoint ¶ added in v1.35.0
TransformPoint returns the result of transforming the point by this matrix.
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.
func (*Point) Align ¶
Align modifies this Point to align with integer coordinates. Returns itself for easy chaining.
func (Point) MarshalText ¶ added in v1.52.0
MarshalText implements the encoding.TextMarshaler interface.
func (*Point) Negate ¶ added in v1.36.0
Negate modifies this Point by negating both the X and Y coordinates.
func (*Point) Subtract ¶
Subtract modifies this Point by subtracting the supplied coordinates. Returns itself for easy chaining.
func (*Point) UnmarshalText ¶ added in v1.52.0
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Rect ¶
Rect defines a rectangle.
func NewRectPtr ¶ added in v1.8.0
NewRectPtr creates a new *Rect.
func (*Rect) AddPoint ¶ added in v1.30.0
AddPoint adds a Point to this Rect. If the Rect has a negative width or height, then the Rect's upper-left corner will be set to the Point and its width and height will be set to 0. Returns itself for easy chaining.
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.
func (Rect) MarshalText ¶ added in v1.52.0
MarshalText implements the encoding.TextMarshaler interface.
func (*Rect) Union ¶
Union this Rect with another Rect, storing the result into this Rect. Returns itself for easy chaining.
func (*Rect) UnmarshalText ¶ added in v1.52.0
UnmarshalText implements the encoding.TextUnmarshaler interface.
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) MarshalText ¶ added in v1.52.0
MarshalText implements the encoding.TextMarshaler interface.
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.
func (*Size) UnmarshalText ¶ added in v1.52.0
UnmarshalText implements the encoding.TextUnmarshaler interface.