aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/utils
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-06 19:41:49 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-06 19:41:49 +0200
commitcacd8d59f14a342e64a011969c13a7f4b59b4c6d (patch)
treec711456c4ec9eabb46b59425a118319297b176a7 /src/main/java/cc/polyfrost/oneconfig/utils
parent3c7d6a1a4d49ef40969bef2cb67825862c41407c (diff)
downloadOneConfig-cacd8d59f14a342e64a011969c13a7f4b59b4c6d.tar.gz
OneConfig-cacd8d59f14a342e64a011969c13a7f4b59b4c6d.tar.bz2
OneConfig-cacd8d59f14a342e64a011969c13a7f4b59b4c6d.zip
merge
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/utils')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java
index 7eb4944..e30c227 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java
@@ -2,18 +2,21 @@ package cc.polyfrost.oneconfig.utils;
public class MathUtils {
public static float clamp(float number) {
- return number < (float) 0.0 ? (float) 0.0 : Math.min(number, (float) 1.0);
+ return number < 0f ? 0f : Math.min(number, 1f);
+ }
+
+ public static float clamp(float number, float min, float max) {
+ return number < min ? min : Math.min(number, max);
}
public static float easeOut(float current, float goal, float speed) {
- if (Math.floor(Math.abs(goal - current) * Math.abs(current - goal) * 3) > 0) {
+ if (Math.round(Math.abs(goal - current) * 25) > 0) {
return current + (goal - current) / speed;
} else {
return goal;
}
}
-
public static float easeInQuad(float current) {
return current * current;
}
@@ -26,5 +29,7 @@ public class MathUtils {
return c / 2 * ((float) Math.sqrt(1 - (t -= 2) * t) + 1) + b;
}
-
+ public static float map(float value, float start1, float stop1, float start2, float stop2) {
+ return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
+ }
}