title: Using D3 Scales to convert colour to number
body: <p>I would like to have this colour scheme as my input domain: 
  <a href="https://i.stack.imgur.com/lqurC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lqurC.png" alt="enter image description here"></a></p>
  
  <p>And a value between <code>0 and 1</code> as my output range.
  However, I am not sure which type of scale to use or how to add the scheme as an input domain.</p>
  
  <p>The code below is the opposite of what I am trying to do.</p>
  
  <pre><code>let scaleSequential1 = d3.scaleSequential()
    .domain([0, 1])
    .interpolator(d3.interpolateViridis);
  
  console.log( scaleSequential1(0) ); //#440154
  console.log( scaleSequential1(0.5) ); //#21918c
  console.log( scaleSequential1(1) ); //#fde725
  </code></pre>