From 14c4db9d165ccf9c68fb653746e7f6277e7e81d5 Mon Sep 17 00:00:00 2001 From: "sashakoshka@tebibyte.media" Date: Tue, 25 Jun 2024 01:56:15 -0400 Subject: [PATCH] Add Translate function --- image/path/path.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/image/path/path.go b/image/path/path.go index 92c0438..f70c0e2 100644 --- a/image/path/path.go +++ b/image/path/path.go @@ -74,6 +74,13 @@ func DistanceToLine (point, line1, line2 image.Point) float64 { return triangle / Distance(line1, line2) } +// Translate adds delta to all points in path. This modifies the slice contents. +func Translate (delta image.Point, path []image.Point) { + for index, point := range path { + path[index] = point.Add(delta) + } +} + func lerp (fac float64, x, y int) int { return int(float64(x) * fac + float64(y) * (1.0 - fac)) }