Documentation ¶
Index ¶
- func EllipseSegmentCount[T constraints.Float](r, e T) int
- type Contour
- type Polygon
- func (p Polygon[T]) Bounds() geom.Rect[T]
- func (p Polygon[T]) Clone() Polygon[T]
- func (p Polygon[T]) Contains(pt geom.Point[T]) bool
- func (p Polygon[T]) ContainsEvenOdd(pt geom.Point[T]) bool
- func (p Polygon[T]) Intersect(other Polygon[T]) Polygon[T]
- func (p Polygon[T]) String() string
- func (p Polygon[T]) Sub(other Polygon[T]) Polygon[T]
- func (p Polygon[T]) Transform(m geom.Matrix[T]) Polygon[T]
- func (p Polygon[T]) Union(other Polygon[T]) Polygon[T]
- func (p Polygon[T]) Xor(other Polygon[T]) Polygon[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EllipseSegmentCount ¶ added in v1.100.0
func EllipseSegmentCount[T constraints.Float](r, e T) int
EllipseSegmentCount returns a suggested number of segments to use when generating an ellipse. 'r' is the largest radius of the ellipse. 'e' is the acceptable error, typically 1 or less.
Types ¶
type Contour ¶
type Contour[T constraints.Float] []geom.Point[T]
Contour is a sequence of vertices connected by line segments, forming a closed shape.
type Polygon ¶
type Polygon[T constraints.Float] []Contour[T]
Polygon holds one or more contour lines. The polygon may contain holes and may be self-intersecting.
func FromEllipse ¶ added in v1.100.0
FromEllipse returns a Polygon that approximates an ellipse filling the given Rect. 'sections' indicates how many segments to break the ellipse contour into. Passing a value less than 4 for 'sections' will result in an automatic choice based on a call to EllipseSegmentCount, using half of the longest dimension for the 'r' parameter and 0.2 for the 'e' parameter.
func FromRect ¶ added in v1.100.0
func FromRect[T constraints.Float](r geom.Rect[T]) Polygon[T]
FromRect returns a Polygon in the shape of the specified rectangle.
func (Polygon[T]) ContainsEvenOdd ¶
ContainsEvenOdd returns true if the point is contained by the polygon using the even-odd rule. https://en.wikipedia.org/wiki/Even-odd_rule
func (Polygon[T]) Intersect ¶
Intersect returns a new Polygon holding the intersection of both Polygons.
func (Polygon[T]) Sub ¶ added in v1.100.0
Sub returns a new Polygon holding the result of removing the other Polygon from this Polygon.
func (Polygon[T]) Transform ¶ added in v1.100.0
Transform returns the result of transforming this Polygon by the Matrix.