Add Translate function

This commit is contained in:
Sasha Koshka 2024-06-25 01:56:15 -04:00
parent 1f04d688cf
commit 14c4db9d16

View File

@ -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))
}