Exemple #1
0
        public static T GaussianEnum <T>(float pivot = -100f)
        {
            var v = System.Enum.GetValues(typeof(T));

            if (pivot == -100f)
            {
                return((T)(v.GetValue(MathSKP.Clamp(GI(0, v.Length, Rng.F(0f, 0.15f)), 0, v.Length - 1))));
            }
            pivot = MathSKP.Clamp(GF(pivot - 0.5f, pivot + 0.5f), 0f, 1f);
            var index = MathSKP.Clamp(GI(0, v.Length, pivot), 0, v.Length - 1);

            return((T)(v.GetValue(index)));
        }
Exemple #2
0
 public static int VaryWithin(this int value, int min, int max, int step) => value           = MathSKP.Clamp(value + IUncapped(-step, step), min, max);
Exemple #3
0
 public static float VaryWithin(this float value, float min, float max, float step) => value = MathSKP.Clamp(value + IUncapped(-step, step), min, max);
Exemple #4
0
 public static byte VaryWithin(this byte value, byte min, byte max, byte step) => value      = (byte)MathSKP.Clamp(value + IUncapped(-step, step), min, max);