mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
24 lines
641 B
Kotlin
24 lines
641 B
Kotlin
package net.torvald.terrarum.ui
|
|
|
|
import net.torvald.terrarum.sqr
|
|
|
|
/**
|
|
* Created by minjaesong on 2017-03-14.
|
|
*/
|
|
object UIUtils {
|
|
fun moveQuick(start: Float, end: Float, timer: Float, duration: Float) =
|
|
(start - end) * ((timer / duration) - 1).sqr() + end
|
|
fun moveLinear(start: Float, end: Float, timer: Float, duration: Float): Float {
|
|
val scale = timer / duration
|
|
if (start == end) {
|
|
return start
|
|
}
|
|
if (scale <= 0f) {
|
|
return start
|
|
}
|
|
if (scale >= 1f) {
|
|
return end
|
|
}
|
|
return ((1f - scale) * start) + (scale * end)
|
|
}
|
|
} |