public static void Interpolate <T>(IInterpolatable <Vector2> from, IInterpolatable <Vector2> to, T *results, int count) where T : unmanaged, IInterpolatable <Vector2> { if (from.Length != to.Length) { throw new Exception("Length of two inputs is different"); } float *steps = stackalloc float[from.Length * 2]; float *fromPtr = (float *)from.ValuesPtr; float *toPtr = (float *)to.ValuesPtr; for (int i = 0; i < from.Length; i++) { steps[i++] = (toPtr[i] - fromPtr[i]) / count; steps[i] = (toPtr[i] - fromPtr[i]) / count; } while (count-- > 0) { for (int i = 0; i < from.Length; i++) { results[count].ValuesPtr[i] = new Vector2(steps[i * 2] * i, steps[i * 2 + 1] * i); } } }
public static bool IsActive(this IInterpolatable ii) { if (ii.Enabled) { return(true); } if (!ii.Enabled && ii.FunctionWhenDisabled) { return(true); } return(false); }
public static CommandDelegate ChangeTo <T>(IInterpolatable <T> interpolatable, T endValue, double duration, CommandEase ease = null) { CheckArgumentNonNull(interpolatable, "interpolatable"); T startValue = interpolatable.GetValue(); return(Cmd.Sequence( Cmd.Do(delegate() { startValue = interpolatable.GetValue(); }), Cmd.Duration(delegate(double t) { interpolatable.Interpolate(startValue, endValue, t); }, duration, ease) )); }
public static void Interpolate <T>(IInterpolatable <float> from, IInterpolatable <float> to, T *results, int count) where T : unmanaged, IInterpolatable <float> { if (from.Length != to.Length) { throw new Exception("Length of two inputs is different"); } float *steps = stackalloc float[from.Length]; for (int i = 0; i < from.Length; i++) { steps[i] = (to.ValuesPtr[i] - from.ValuesPtr[i]) / count; } while (count-- > 0) { for (int i = 0; i < from.Length; i++) { results[count].ValuesPtr[i] = steps[i] * i; } } }