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)) } func ClampInt[T constraints.Integer](value, min, max T) T { if value < min { value = min } if value > max { value = max } return value }