| 1 | package net.minecraft.util;
|
| 2 |
|
| 3 | public class Ease {
|
| 4 | public static float inBack(final float x) {
|
| 5 | float c1 = 1.70158F;
|
| 6 | float c3 = 2.70158F;
|
| 7 | return Mth.square(x) * (2.70158F * x - 1.70158F);
|
| 8 | }
|
| 9 |
|
| 10 | public static float inBounce(final float x) {
|
| 11 | return 1.0F - outBounce(1.0F - x);
|
| 12 | }
|
| 13 |
|
| 14 | public static float inCubic(final float x) {
|
| 15 | return Mth.cube(x);
|
| 16 | }
|
| 17 |
|
| 18 | public static float inElastic(final float x) {
|
| 19 | if (x == 0.0F) {
|
| 20 | return 0.0F;
|
| 21 | }
|
| 22 |
|
| 23 | if (x == 1.0F) {
|
| 24 | return 1.0F;
|
| 25 | }
|
| 26 |
|
| 27 | float c4 = (float) (Math.PI * 2.0 / 3.0);
|
| 28 | return (float)(-Math.pow(2.0, 10.0 * x - 10.0) * Math.sin((x * 10.0 - 10.75) * (float) (Math.PI * 2.0 / 3.0)));
|
| 29 | }
|
| 30 |
|
| 31 | public static float inExpo(final float x) {
|
| 32 | return x == 0.0F ? 0.0F : (float)Math.pow(2.0, 10.0 * x - 10.0);
|
| 33 | }
|
| 34 |
|
| 35 | public static float inQuart(final float x) {
|
| 36 | return Mth.square(Mth.square(x));
|
| 37 | }
|
| 38 |
|
| 39 | public static float inQuint(final float x) {
|
| 40 | return Mth.square(Mth.square(x)) * x;
|
| 41 | }
|
| 42 |
|
| 43 | public static float inSine(final float x) {
|
| 44 | return 1.0F - Mth.cos(x * (float) (Math.PI / 2));
|
| 45 | }
|
| 46 |
|
| 47 | public static float inOutBounce(final float x) {
|
| 48 | return x < 0.5F ? (1.0F - outBounce(1.0F - 2.0F * x)) / 2.0F : (1.0F + outBounce(2.0F * x - 1.0F)) / 2.0F;
|
| 49 | }
|
| 50 |
|
| 51 | public static float inOutCirc(final float x) {
|
| 52 | return x < 0.5F ? (float)((1.0 - Math.sqrt(1.0 - Math.pow(2.0 * x, 2.0))) / 2.0) : (float)((Math.sqrt(1.0 - Math.pow(-2.0 * x + 2.0, 2.0)) + 1.0) / 2.0);
|
| 53 | }
|
| 54 |
|
| 55 | public static float inOutCubic(final float x) {
|
| 56 | return x < 0.5F ? 4.0F * Mth.cube(x) : (float)(1.0 - Math.pow(-2.0 * x + 2.0, 3.0) / 2.0);
|
| 57 | }
|
| 58 |
|
| 59 | public static float inOutQuad(final float x) {
|
| 60 | return x < 0.5F ? 2.0F * Mth.square(x) : (float)(1.0 - Math.pow(-2.0 * x + 2.0, 2.0) / 2.0);
|
| 61 | }
|
| 62 |
|
| 63 | public static float inOutQuart(final float x) {
|
| 64 | return x < 0.5F ? 8.0F * Mth.square(Mth.square(x)) : (float)(1.0 - Math.pow(-2.0 * x + 2.0, 4.0) / 2.0);
|
| 65 | }
|
| 66 |
|
| 67 | public static float inOutQuint(final float x) {
|
| 68 | return x < 0.5 ? 16.0F * x * x * x * x * x : (float)(1.0 - Math.pow(-2.0 * x + 2.0, 5.0) / 2.0);
|
| 69 | }
|
| 70 |
|
| 71 | public static float outBounce(final float x) {
|
| 72 | float n1 = 7.5625F;
|
| 73 | float d1 = 2.75F;
|
| 74 | if (x < 0.36363637F) {
|
| 75 | return 7.5625F * Mth.square(x);
|
| 76 | } else if (x < 0.72727275F) {
|
| 77 | return 7.5625F * Mth.square(x - 0.54545456F) + 0.75F;
|
| 78 | } else {
|
| 79 | return x < 0.9090909090909091 ? 7.5625F * Mth.square(x - 0.8181818F) + 0.9375F : 7.5625F * Mth.square(x - 0.95454544F) + 0.984375F;
|
| 80 | }
|
| 81 | }
|
| 82 |
|
| 83 | public static float outElastic(final float x) {
|
| 84 | float c4 = (float) (Math.PI * 2.0 / 3.0);
|
| 85 | if (x == 0.0F) {
|
| 86 | return 0.0F;
|
| 87 | } else {
|
| 88 | return x == 1.0F ? 1.0F : (float)(Math.pow(2.0, -10.0 * x) * Math.sin((x * 10.0 - 0.75) * (float) (Math.PI * 2.0 / 3.0)) + 1.0);
|
| 89 | }
|
| 90 | }
|
| 91 |
|
| 92 | public static float outExpo(final float x) {
|
| 93 | return x == 1.0F ? 1.0F : 1.0F - (float)Math.pow(2.0, -10.0 * x);
|
| 94 | }
|
| 95 |
|
| 96 | public static float outQuad(final float x) {
|
| 97 | return 1.0F - Mth.square(1.0F - x);
|
| 98 | }
|
| 99 |
|
| 100 | public static float outQuint(final float x) {
|
| 101 | return 1.0F - (float)Math.pow(1.0 - x, 5.0);
|
| 102 | }
|
| 103 |
|
| 104 | public static float outSine(final float x) {
|
| 105 | return Mth.sin(x * (float) (Math.PI / 2));
|
| 106 | }
|
| 107 |
|
| 108 | public static float inOutSine(final float x) {
|
| 109 | return -(Mth.cos((float) Math.PI * x) - 1.0F) / 2.0F;
|
| 110 | }
|
| 111 |
|
| 112 | public static float outBack(final float x) {
|
| 113 | float c1 = 1.70158F;
|
| 114 | float c3 = 2.70158F;
|
| 115 | return 1.0F + 2.70158F * Mth.cube(x - 1.0F) + 1.70158F * Mth.square(x - 1.0F);
|
| 116 | }
|
| 117 |
|
| 118 | public static float outQuart(final float x) {
|
| 119 | return 1.0F - Mth.square(Mth.square(1.0F - x));
|
| 120 | }
|
| 121 |
|
| 122 | public static float outCubic(final float x) {
|
| 123 | return 1.0F - Mth.cube(1.0F - x);
|
| 124 | }
|
| 125 |
|
| 126 | public static float inOutExpo(final float x) {
|
| 127 | if (x < 0.5F) {
|
| 128 | return x == 0.0F ? 0.0F : (float)(Math.pow(2.0, 20.0 * x - 10.0) / 2.0);
|
| 129 | } else {
|
| 130 | return x == 1.0F ? 1.0F : (float)((2.0 - Math.pow(2.0, -20.0 * x + 10.0)) / 2.0);
|
| 131 | }
|
| 132 | }
|
| 133 |
|
| 134 | public static float inQuad(final float x) {
|
| 135 | return x * x;
|
| 136 | }
|
| 137 |
|
| 138 | public static float outCirc(final float x) {
|
| 139 | return (float)Math.sqrt(1.0F - Mth.square(x - 1.0F));
|
| 140 | }
|
| 141 |
|
| 142 | public static float inOutElastic(final float x) {
|
| 143 | float c5 = (float) Math.PI * 4.0F / 9.0F;
|
| 144 | if (x == 0.0F) {
|
| 145 | return 0.0F;
|
| 146 | }
|
| 147 |
|
| 148 | if (x == 1.0F) {
|
| 149 | return 1.0F;
|
| 150 | }
|
| 151 |
|
| 152 | double sin = Math.sin((20.0 * x - 11.125) * (float) Math.PI * 4.0F / 9.0F);
|
| 153 | return x < 0.5F ? (float)(-(Math.pow(2.0, 20.0 * x - 10.0) * sin) / 2.0) : (float)(Math.pow(2.0, -20.0 * x + 10.0) * sin / 2.0 + 1.0);
|
| 154 | }
|
| 155 |
|
| 156 | public static float inCirc(final float x) {
|
| 157 | return (float)(-Math.sqrt(1.0F - x * x)) + 1.0F;
|
| 158 | }
|
| 159 |
|
| 160 | public static float inOutBack(final float x) {
|
| 161 | float c1 = 1.70158F;
|
| 162 | float c2 = 2.5949094F;
|
| 163 | if (x < 0.5F) {
|
| 164 | return 4.0F * x * x * (7.189819F * x - 2.5949094F) / 2.0F;
|
| 165 | }
|
| 166 |
|
| 167 | float dt = 2.0F * x - 2.0F;
|
| 168 | return (dt * dt * (3.5949094F * dt + 2.5949094F) + 2.0F) / 2.0F;
|
| 169 | }
|
| 170 | }
|
| 171 |
|