diff --git a/polygon.go b/polygon.go index 2ddcf19..56e901c 100644 --- a/polygon.go +++ b/polygon.go @@ -5,7 +5,7 @@ import "image" func (this Image[T]) FillPolygon (fill []T, points ...image.Point) { this.assertWidth(fill) - if len(points) < 2 { return } + if len(points) < 3 { return } // figure out the bounds of the polygon so we don't test empty space var area image.Rectangle @@ -88,3 +88,12 @@ func (this Image[T]) StrokePolygon (stroke []T, weight int, points ...image.Poin prevPoint = point } } + +func (this Image[T]) PolyLine (stroke []T, weight int, points ...image.Point) { + if len(points) < 2 { return } + prevPoint := points[0] + for _, point := range points[1:] { + this.Line(stroke, weight, prevPoint, point) + prevPoint = point + } +}