summaryrefslogtreecommitdiff
path: root/Impostor-dev/src/Impostor.Api/Innersloth/FloatRange.cs
blob: c8a0824df26dc34bec7dfb3c5cdc9350caf3a960 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using Impostor.Api.Unity;

namespace Impostor.Api.Innersloth
{
    public class FloatRange
    {
        private readonly float _min;
        private readonly float _max;

        public FloatRange(float min, float max)
        {
            _min = min;
            _max = max;
        }

        public float Width => _max - _min;

        public float Lerp(float v) => Mathf.Lerp(_min, _max, v);

        public float ReverseLerp(float t) => Mathf.Clamp((t - _min) / Width, 0.0f, 1f);
    }
}