2018-09-18 18:23:25 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.UI.Scrolling.Visualisers
|
|
|
|
|
{
|
2018-10-30 09:00:55 +00:00
|
|
|
|
public readonly struct ConstantSpeedChangeVisualiser : ISpeedChangeVisualiser
|
2018-09-18 18:23:25 +00:00
|
|
|
|
{
|
2018-10-30 09:00:55 +00:00
|
|
|
|
private readonly double timeRange;
|
|
|
|
|
private readonly float scrollLength;
|
2018-09-18 18:23:25 +00:00
|
|
|
|
|
2018-10-30 09:00:55 +00:00
|
|
|
|
public ConstantSpeedChangeVisualiser(double timeRange, float scrollLength)
|
2018-09-18 18:23:25 +00:00
|
|
|
|
{
|
2018-10-30 09:00:55 +00:00
|
|
|
|
this.timeRange = timeRange;
|
|
|
|
|
this.scrollLength = scrollLength;
|
2018-09-18 18:23:25 +00:00
|
|
|
|
}
|
2018-10-30 08:31:43 +00:00
|
|
|
|
|
2018-10-30 09:04:13 +00:00
|
|
|
|
public double GetDisplayStartTime(double time) => time - timeRange;
|
2018-10-30 08:31:43 +00:00
|
|
|
|
|
|
|
|
|
public float GetLength(double startTime, double endTime)
|
|
|
|
|
{
|
|
|
|
|
// At the hitobject's end time, the hitobject will be positioned such that its end rests at the origin.
|
|
|
|
|
// This results in a negative-position value, and the absolute of it indicates the length of the hitobject.
|
2018-10-30 09:04:13 +00:00
|
|
|
|
return -PositionAt(startTime, endTime);
|
2018-10-30 08:31:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-30 09:04:13 +00:00
|
|
|
|
public float PositionAt(double time, double currentTime) => (float)((time - currentTime) / timeRange * scrollLength);
|
2018-09-18 18:23:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|