Documentation ¶
Overview ¶
Package geom32 provides geometry primitives.
Index ¶
- func PointSegmentDistance(s1, s2, p Point) float32
- func PointSegmentDistanceSquared(s1, s2, p Point) float32
- type Insets
- type Matrix2D
- type Point
- type Rect
- func (r *Rect) AddPoint(pt Point) *Rect
- func (r *Rect) Align() *Rect
- func (r Rect) Bottom() float32
- func (r Rect) BottomLeft() Point
- func (r Rect) BottomRight() Point
- func (r Rect) Bounds() Rect
- func (r Rect) Center() Point
- func (r Rect) CenterX() float32
- func (r Rect) CenterY() float32
- 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 float32) *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() float32
- 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 ¶
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 ¶
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 Matrix2D ¶ added in v1.35.0
type Matrix2D struct { ScaleX float32 SkewX float32 TransX float32 SkewY float32 ScaleY float32 TransY float32 }
Matrix2D provides a 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) TransformPt ¶ added in v1.35.0
TransformPt returns the result of transforming the point by this matrix.
type Point ¶
type Point struct {
X, Y float32
}
Point defines a location.
func LineIntersection ¶
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 (*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.
type Rect ¶
Rect defines a rectangle.
func NewRectPtr ¶
NewRectPtr creates a new *Rect.
func (*Rect) AddPoint ¶
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 ¶
BottomLeft returns the bottom-left point of the rectangle.
func (Rect) BottomRight ¶
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 ¶
Intersects returns true if this rect and the other rect intersect.
func (Rect) IntersectsLine ¶
IntersectsLine returns true if this rect and the line described by start and end intersect.
type Size ¶
type Size struct {
Width, Height float32
}
Size defines a width and height.
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.