2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-09-19 02:23:25 +08:00
|
|
|
|
|
2018-11-02 18:52:40 +08:00
|
|
|
|
namespace osu.Game.Rulesets.UI.Scrolling.Algorithms
|
2018-09-19 02:23:25 +08:00
|
|
|
|
{
|
2018-11-02 18:51:34 +08:00
|
|
|
|
public class ConstantScrollAlgorithm : IScrollAlgorithm
|
2018-09-19 02:23:25 +08:00
|
|
|
|
{
|
2018-10-30 17:33:24 +08:00
|
|
|
|
public double GetDisplayStartTime(double time, double timeRange) => time - timeRange;
|
2018-09-19 02:23:25 +08:00
|
|
|
|
|
2018-10-30 17:33:24 +08:00
|
|
|
|
public float GetLength(double startTime, double endTime, double timeRange, float scrollLength)
|
2018-09-19 02:23:25 +08:00
|
|
|
|
{
|
2018-10-30 17:33:24 +08:00
|
|
|
|
// 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.
|
|
|
|
|
return -PositionAt(startTime, endTime, timeRange, scrollLength);
|
2018-09-19 02:23:25 +08:00
|
|
|
|
}
|
2018-10-30 16:31:43 +08:00
|
|
|
|
|
2018-10-30 17:33:24 +08:00
|
|
|
|
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
|
|
|
|
|
=> (float)((time - currentTime) / timeRange * scrollLength);
|
2018-10-30 16:31:43 +08:00
|
|
|
|
|
2018-11-09 18:55:48 +08:00
|
|
|
|
public double TimeAt(float position, double currentTime, double timeRange, float scrollLength)
|
|
|
|
|
=> position * timeRange / scrollLength + currentTime;
|
|
|
|
|
|
2018-10-30 17:33:24 +08:00
|
|
|
|
public void Reset()
|
2018-10-30 16:31:43 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
2018-09-19 02:23:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|