public void MoveMouseToWidget(GuiWidget widget, SystemWindow containingWindow, Point2D offset, Point2D offsetHint, ClickOrigin origin, out Point2D screenPosition) { RectangleDouble childBounds = widget.TransformToParentSpace(containingWindow, widget.LocalBounds); screenPosition = SystemWindowToScreen(new Point2D(childBounds.Left + offset.x, childBounds.Bottom + offset.y), containingWindow); int steps = (int)((TimeToMoveMouse * 1000) / 20); Vector2 start = new Vector2(CurrentMousePosition().x, CurrentMousePosition().y); if (origin == ClickOrigin.Center) { offset += offsetHint; } for (int i = 0; i < steps; i++) { childBounds = widget.TransformToParentSpace(containingWindow, widget.LocalBounds); screenPosition = SystemWindowToScreen(new Point2D(childBounds.Left + offset.x, childBounds.Bottom + offset.y), containingWindow); Vector2 end = new Vector2(screenPosition.x, screenPosition.y); Vector2 delta = end - start; double ratio = i / (double)steps; ratio = Cubic.Out(ratio); Vector2 current = start + delta * ratio; inputSystem.SetCursorPosition((int)current.X, (int)current.Y); Thread.Sleep(20); } inputSystem.SetCursorPosition(screenPosition.x, screenPosition.y); }
public void Out_InputAboveRange_ReturnsDestination() { Ease ease = new Cubic(); float x = 1.5f; float expected = ease.Scale.Y; float actual = ease.Out(x); Assert.AreEqual(expected, actual, 0.001f); }
public void Out_InputBelowRange_ReturnsOrigin() { Ease ease = new Cubic(); float x = -0.5f; float expected = 0; float actual = ease.Out(x); Assert.AreEqual(expected, actual, 0.001f); }
public void Out_InputInRange_ReturnsExpectedValue() { Ease ease = new Cubic(); float x = 0.6f; float expected = 0.936f; float actual = ease.Out(x); Assert.AreEqual(expected, actual, 0.001f); }
public void Out_ChangedScaleInputAboveRange_ReturnsDestination() { Vector scale = new Vector(4, 6); Ease ease = new Cubic(scale); float x = 11.1f; float expected = ease.Scale.Y; float actual = ease.Out(x); Assert.AreEqual(expected, actual, 0.001f); }
public void Out_ChangedScaleInputBelowRange_ReturnsOrigin() { Vector scale = new Vector(4, 6); Ease ease = new Cubic(scale); float x = -1.1f; float expected = 0; float actual = ease.Out(x); Assert.AreEqual(expected, actual, 0.001f); }
public void Out_ChangedScaleInputInRange_ReturnsExpectedValue() { Vector scale = new Vector(4, 6); Ease ease = new Cubic(scale); float x = 2.5f; float expected = 5.684f; float actual = ease.Out(x); Assert.AreEqual(expected, actual, 0.001f); }
public void SetMouseCursorPosition(int x, int y) { Vector2 start = new Vector2(CurrentMousePosition().x, CurrentMousePosition().y); Vector2 end = new Vector2(x, y); Vector2 delta = end - start; int steps = (int)((TimeToMoveMouse * 1000) / 20); for (int i = 0; i < steps; i++) { double ratio = i / (double)steps; ratio = Cubic.Out(ratio); Vector2 current = start + delta * ratio; inputSystem.SetCursorPosition((int)current.X, (int)current.Y); Thread.Sleep(20); } inputSystem.SetCursorPosition((int)end.X, (int)end.Y); }
//------------------------------------------------------------------------------------------------------------ public static float GetEasingFunction(Type easingFunction, float t) { // Quad if (easingFunction == Type.EaseInQuad) { return(Quadratic.In(t)); } if (easingFunction == Type.EaseOutQuad) { return(Quadratic.Out(t)); } if (easingFunction == Type.EaseInOutQuad) { return(Quadratic.InOut(t)); } // Cubic if (easingFunction == Type.EaseInCubic) { return(Cubic.In(t)); } if (easingFunction == Type.EaseOutCubic) { return(Cubic.Out(t)); } if (easingFunction == Type.EaseInOutCubic) { return(Cubic.InOut(t)); } // Quart if (easingFunction == Type.EaseInQuart) { return(Quartic.In(t)); } if (easingFunction == Type.EaseOutQuart) { return(Quartic.Out(t));; } if (easingFunction == Type.EaseInOutQuart) { return(Quartic.InOut(t));; } // Quint if (easingFunction == Type.EaseInQuint) { return(Quintic.In(t)); } if (easingFunction == Type.EaseOutQuint) { return(Quintic.Out(t)); } if (easingFunction == Type.EaseInOutQuint) { return(Quintic.InOut(t)); } // Sine if (easingFunction == Type.EaseInSine) { return(Sinusoidal.In(t)); } if (easingFunction == Type.EaseOutSine) { return(Sinusoidal.Out(t)); } if (easingFunction == Type.EaseInOutSine) { return(Sinusoidal.InOut(t)); } // Expo if (easingFunction == Type.EaseInExpo) { return(Exponential.In(t)); } if (easingFunction == Type.EaseOutExpo) { return(Exponential.Out(t)); } if (easingFunction == Type.EaseInOutExpo) { return(Exponential.InOut(t)); } // CirC if (easingFunction == Type.EaseInCirc) { return(Circular.In(t)); } if (easingFunction == Type.EaseOutCirc) { return(Circular.Out(t)); } if (easingFunction == Type.EaseInOutCirc) { return(Circular.InOut(t)); } // Linear if (easingFunction == Type.Linear) { return(Linear(t)); } // Bounce if (easingFunction == Type.EaseInBounce) { return(Bounce.In(t)); } if (easingFunction == Type.EaseOutBounce) { return(Bounce.Out(t)); } if (easingFunction == Type.EaseInOutBounce) { return(Bounce.InOut(t)); } // Back if (easingFunction == Type.EaseInBack) { return(Back.In(t)); } if (easingFunction == Type.EaseOutBack) { return(Back.Out(t)); } if (easingFunction == Type.EaseInOutBack) { return(Back.InOut(t)); } // Elastic if (easingFunction == Type.EaseInElastic) { return(Elastic.In(t)); } if (easingFunction == Type.EaseOutElastic) { return(Elastic.Out(t)); } if (easingFunction == Type.EaseInOutElastic) { return(Elastic.InOut(t)); } return(0); }
public static float GetTerpedPosition(float time, float totalTime, Function function, Direction direction) { switch (function) { case Function.Quadratic: switch (direction) { case Direction.In: return(Quadratic.In(time / totalTime)); case Direction.Out: return(Quadratic.Out(time / totalTime)); default: return(Quadratic.InOut(time / totalTime)); } case Function.Cubic: switch (direction) { case Direction.In: return(Cubic.In(time / totalTime)); case Direction.Out: return(Cubic.Out(time / totalTime)); default: return(Cubic.InOut(time / totalTime)); } case Function.Quartic: switch (direction) { case Direction.In: return(Quartic.In(time / totalTime)); case Direction.Out: return(Quartic.Out(time / totalTime)); default: return(Quartic.InOut(time / totalTime)); } case Function.Quintic: switch (direction) { case Direction.In: return(Quintic.In(time / totalTime)); case Direction.Out: return(Quintic.Out(time / totalTime)); default: return(Quintic.InOut(time / totalTime)); } case Function.Sinusoidal: switch (direction) { case Direction.In: return(Sinusoidal.In(time / totalTime)); case Direction.Out: return(Sinusoidal.Out(time / totalTime)); default: return(Sinusoidal.InOut(time / totalTime)); } case Function.Exponential: switch (direction) { case Direction.In: return(Exponential.In(time / totalTime)); case Direction.Out: return(Exponential.Out(time / totalTime)); default: return(Exponential.InOut(time / totalTime)); } case Function.Circular: switch (direction) { case Direction.In: return(Circular.In(time / totalTime)); case Direction.Out: return(Circular.Out(time / totalTime)); default: return(Circular.InOut(time / totalTime)); } case Function.Elastic: switch (direction) { case Direction.In: return(Elastic.In(time / totalTime)); case Direction.Out: return(Elastic.Out(time / totalTime)); default: return(Elastic.InOut(time / totalTime)); } case Function.Back: switch (direction) { case Direction.In: return(Back.In(time / totalTime)); case Direction.Out: return(Back.Out(time / totalTime)); default: return(Back.InOut(time / totalTime)); } default: //Function.Bounce: switch (direction) { case Direction.In: return(Bounce.In(time / totalTime)); case Direction.Out: return(Bounce.Out(time / totalTime)); default: return(Bounce.InOut(time / totalTime)); } } }
public static float Ease(EasingType easingFunction, float k) { switch (easingFunction) { case EasingType.Linear: return(Linear(k)); case EasingType.QuadraticIn: return(Quadratic.In(k)); case EasingType.QuadraticOut: return(Quadratic.Out(k)); case EasingType.QuadraticInOut: return(Quadratic.InOut(k)); case EasingType.CubicIn: return(Cubic.In(k)); case EasingType.CubicOut: return(Cubic.Out(k)); case EasingType.CubicInOut: return(Cubic.InOut(k)); case EasingType.QuarticIn: return(Quartic.In(k)); case EasingType.QuarticOut: return(Quartic.Out(k)); case EasingType.QuarticInOut: return(Quartic.InOut(k)); case EasingType.QuinticIn: return(Quintic.In(k)); case EasingType.QuinticOut: return(Quintic.Out(k)); case EasingType.QuinticInOut: return(Quintic.InOut(k)); case EasingType.SinusoidalIn: return(Sinusoidal.In(k)); case EasingType.SinusoidalOut: return(Sinusoidal.Out(k)); case EasingType.SinusoidalInOut: return(Sinusoidal.InOut(k)); case EasingType.ExponentialIn: return(Exponential.In(k)); case EasingType.ExponentialOut: return(Exponential.Out(k)); case EasingType.ExponentialInOut: return(Exponential.InOut(k)); case EasingType.CircularIn: return(Circular.In(k)); case EasingType.CircularOut: return(Circular.Out(k)); case EasingType.CircularInOut: return(Circular.InOut(k)); case EasingType.ElasticIn: return(Elastic.In(k)); case EasingType.ElasticOut: return(Elastic.Out(k)); case EasingType.ElasticInOut: return(Elastic.InOut(k)); case EasingType.BackIn: return(Back.In(k)); case EasingType.BackOut: return(Back.Out(k)); case EasingType.BackInOut: return(Back.InOut(k)); case EasingType.BounceIn: return(Bounce.In(k)); case EasingType.BounceOut: return(Bounce.Out(k)); case EasingType.BounceInOut: return(Bounce.InOut(k)); default: return(Linear(k)); } }
public static double Specify(EaseType easeType, EaseOption easeOption, double k) { switch (easeType) { case EaseType.Quadratic: switch (easeOption) { case EaseOption.In: return(Quadratic.In(k)); case EaseOption.Out: return(Quadratic.Out(k)); case EaseOption.InOut: return(Quadratic.InOut(k)); } break; case EaseType.Cubic: switch (easeOption) { case EaseOption.In: return(Cubic.In(k)); case EaseOption.Out: return(Cubic.Out(k)); case EaseOption.InOut: return(Cubic.InOut(k)); } break; case EaseType.Quartic: switch (easeOption) { case EaseOption.In: return(Quartic.In(k)); case EaseOption.Out: return(Quartic.Out(k)); case EaseOption.InOut: return(Quartic.InOut(k)); } break; case EaseType.Quintic: switch (easeOption) { case EaseOption.In: return(Quintic.In(k)); case EaseOption.Out: return(Quintic.Out(k)); case EaseOption.InOut: return(Quintic.InOut(k)); } break; case EaseType.Sinusoidal: switch (easeOption) { case EaseOption.In: return(Sinusoidal.In(k)); case EaseOption.Out: return(Sinusoidal.Out(k)); case EaseOption.InOut: return(Sinusoidal.InOut(k)); } break; } return(Linear(k)); }