poly

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Polygon

type Polygon []image.Point

Polygon defines a list of closed points that define a polygon.

func New

func New(coordinates string) (Polygon, error)

New creates a new polygon from a whitespace separated list of comma separated coordinates e.g. `1,2 3,4 5,6`. A polygon contains at least 3 points. If 2 points are given it is assumed, that the region is a rectangle with an upper and lower point. In this case a polygon with all the 4 points is returned.

func (Polygon) BoundingRectangle

func (p Polygon) BoundingRectangle() image.Rectangle

BoundingRectangle returns the minimal rectangle containing all of the polygon's points.

func (Polygon) Inside

func (p Polygon) Inside(point image.Point) bool

Inside returns true if the given point lies within the polygon. Implementation: https://stackoverflow.com/questions/217578/how-can-i-determine-whether-a-2d-point-is-within-a-polygon

func (Polygon) String

func (p Polygon) String() string

Jump to

Keyboard shortcuts

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