From c883ec06db1e42ffd9c8c709225f07c5278c2c58 Mon Sep 17 00:00:00 2001 From: "sashakoshka@tebibyte.media" Date: Wed, 26 Jun 2024 10:41:03 -0400 Subject: [PATCH] Fix lerp functions --- image/path/path.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/image/path/path.go b/image/path/path.go index f70c0e2..cd62536 100644 --- a/image/path/path.go +++ b/image/path/path.go @@ -39,7 +39,7 @@ func MultiLerp (fac float64, stages ...[]image.Point) []image.Point { return result } - expandedFac := fac * float64(len(stages)) + expandedFac := fac * float64(len(stages) - 1) startIndex := int(expandedFac) if startIndex >= len(stages) { startIndex = len(stages) - 1 } @@ -49,7 +49,6 @@ func MultiLerp (fac float64, stages ...[]image.Point) []image.Point { start := stages[startIndex] end := stages[endIndex] partialFac := expandedFac - float64(startIndex) - println(startIndex, endIndex, int(partialFac * 100)) return Lerp(partialFac, start, end) } @@ -82,5 +81,5 @@ func Translate (delta image.Point, path []image.Point) { } func lerp (fac float64, x, y int) int { - return int(float64(x) * fac + float64(y) * (1.0 - fac)) + return int(float64(x) * (1.0 - fac) + float64(y) * fac) }