joyful/internal/mappingrules/math.go

15 lines
347 B
Go

package mappingrules
import (
"golang.org/x/exp/constraints"
)
func AbsInt[T constraints.Integer](value T) T {
return max(value, -value)
}
// LerpInt linearly interpolates between two integer values using
// a float64 index value
func LerpInt[T constraints.Integer](min, max T, t float64) T {
return T((1-t)*float64(min) + t*float64(max))
}