[FR] Range::getProportionalValue(float proportion)

In analogy with what is found in other parts of JUCE (Line, Rectangle), it would be nice if Range had a method that, given a proportional position along the length of the range, returns the corresponding value:

  • 0 -> start value
  • 1 -> end value
  • 0.5 -> middle value
  • and so on…

But that is the job of NormalisableRange, isn’t it?
You can get a Range from a NormalisableRange using NormalisableRange< ValueType >::getRange () const, or did I miss something?

I don’t know exactly the difference, maybe they could be merged at some point?

Yes, I thought about that but switching to a NormalizableRange seemed overkill in my case…

Bump. It’s really just one member function being added:

template<typename FloatType>
ValueType getProportionalValue(FloatType proportion)
    proportion = jlimit(0.f, 1.f, proportion);
    return start + static_cast<ValueType>( ( FloatType(end) - FloatType(start) ) * proportion );