poly

package
v1.118.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2024 License: MPL-2.0 Imports: 5 Imported by: 2

README

Warning!

The polygon boolean operation code doesn't function as expected in all cases. It does work for most cases, but I recommend against using it in production code at the moment.

Documentation

Index

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.

func (Contour[T]) Bounds

func (c Contour[T]) Bounds() geom.Rect[T]

Bounds returns the bounding rectangle of the contour.

func (Contour[T]) Clone

func (c Contour[T]) Clone() Contour[T]

Clone returns a copy of this contour.

func (Contour[T]) Contains

func (c Contour[T]) Contains(pt geom.Point[T]) bool

Contains returns true if the point is contained by the contour.

func (Contour[T]) String added in v1.99.0

func (c Contour[T]) String() string

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

func FromEllipse[T constraints.Float](r geom.Rect[T], sections int) Polygon[T]

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]) Bounds

func (p Polygon[T]) Bounds() geom.Rect[T]

Bounds returns the bounding rectangle of this polygon.

func (Polygon[T]) Clone

func (p Polygon[T]) Clone() Polygon[T]

Clone returns a duplicate of this polygon.

func (Polygon[T]) Contains

func (p Polygon[T]) Contains(pt geom.Point[T]) bool

Contains returns true if the point is contained by this polygon.

func (Polygon[T]) ContainsEvenOdd

func (p Polygon[T]) ContainsEvenOdd(pt geom.Point[T]) bool

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

func (p Polygon[T]) Intersect(other Polygon[T]) Polygon[T]

Intersect returns a new Polygon holding the intersection of both Polygons.

func (Polygon[T]) String added in v1.99.0

func (p Polygon[T]) String() string

String implements fmt.Stringer.

func (Polygon[T]) Sub added in v1.100.0

func (p Polygon[T]) Sub(other Polygon[T]) Polygon[T]

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

func (p Polygon[T]) Transform(m geom.Matrix[T]) Polygon[T]

Transform returns the result of transforming this Polygon by the Matrix.

func (Polygon[T]) Union

func (p Polygon[T]) Union(other Polygon[T]) Polygon[T]

Union returns a new Polygon holding the union of both Polygons.

func (Polygon[T]) Xor

func (p Polygon[T]) Xor(other Polygon[T]) Polygon[T]

Xor returns a new Polygon holding the result of xor'ing this Polygon with the other Polygon.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL