Documentation ¶
Index ¶
- Variables
- func CalcEllipseSegmentCount(r, e float64) int
- type Contour
- type Polygon
- func (p Polygon) Bounds() geom.Rect
- func (p Polygon) Clone() Polygon
- func (p Polygon) Contains(pt geom.Point) bool
- func (p Polygon) ContainsEvenOdd(pt geom.Point) bool
- func (p Polygon) Intersect(other Polygon) Polygon
- func (p Polygon) Subtract(other Polygon) Polygon
- func (p Polygon) Union(other Polygon) Polygon
- func (p Polygon) Xor(other Polygon) Polygon
Constants ¶
This section is empty.
Variables ¶
var Epsilon = float64Epsilon
Epsilon controls how close a point has to be to be considered the same as another. If performance becomes an issue, you can increase this value, which will cause more points to merge together, reducing the amount of work that must be done. Don't raise it too high, though, as it can distort the resulting polygon.
Functions ¶
func CalcEllipseSegmentCount ¶ added in v1.20.0
CalcEllipseSegmentCount 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 ¶
Contour is a sequence of vertices connected by line segments, forming a closed shape.
type Polygon ¶
type Polygon []Contour
Polygon holds one or more contour lines. The polygon may contain holes and may be self-intersecting.
func ApproximateEllipse ¶ added in v1.16.0
ApproximateEllipse creates a polygon that approximates an ellipse. 'sections' indicates how many segments to break the ellipse contour into.
func ApproximateEllipseAuto ¶ added in v1.20.0
ApproximateEllipseAuto creates a polygon that approximates an ellipse, automatically choose the number of segments to break the ellipse contour into. This uses CalcEllipseSegmentCount() with an 'e' of 0.2.
func (Polygon) 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) Subtract ¶
Subtract returns the result of removing the other polygon from this polygon.