/// <summary> /// Returns the distance in pixels between this and another `Transformable2D`. /// </summary> public float DistanceTo(Transformable2D other) { if (other == null) { return float.NaN; } return (Position - other.Position).Length; }
void StartPulsating(Transformable2D transform, TimeSpan duration, float from, float to) { Vector2 original = new Vector2(from); Vector2 target = new Vector2(to); transform.Scale = original; TaskManager.Main .WaitUntil( elapsed => { var t = elapsed / duration.TotalSeconds; var step = Easing.EaseOut(t, EasingType.Cubic); transform.Scale = Vector2.Lerp(original, target, step); return t >= 1; }) .Then( () => { StartPulsating(transform, duration, from, to); }); }