diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util/render/LerpUtils.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/render/LerpUtils.kt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/render/LerpUtils.kt b/src/main/kotlin/moe/nea/firmament/util/render/LerpUtils.kt index a979f8d..66899ce 100644 --- a/src/main/kotlin/moe/nea/firmament/util/render/LerpUtils.kt +++ b/src/main/kotlin/moe/nea/firmament/util/render/LerpUtils.kt @@ -6,6 +6,8 @@ package moe.nea.firmament.util.render +import me.shedaniel.math.Color + val pi = Math.PI val tau = Math.PI * 2 fun lerpAngle(a: Float, b: Float, progress: Float): Float { @@ -17,7 +19,20 @@ fun lerpAngle(a: Float, b: Float, progress: Float): Float { fun lerp(a: Float, b: Float, progress: Float): Float { return a + (b - a) * progress } +fun lerp(a: Int, b: Int, progress: Float): Int { + return (a + (b - a) * progress).toInt() +} fun ilerp(a: Float, b: Float, value: Float): Float { return (value - a) / (b - a) } + +fun lerp(a: Color, b: Color, progress: Float): Color { + return Color.ofRGBA( + lerp(a.red, b.red, progress), + lerp(a.green, b.green, progress), + lerp(a.blue, b.blue, progress), + lerp(a.alpha, b.alpha, progress), + ) +} + |