title: Need a little help on an equation for a GUI "Slider"
body: <p>This is a small equation that's giving me a headache, I'm close to solving but- Ugh.
  I'll try to be prompt.</p>
  <p>I have this:</p>
  <p><a href="https://i.stack.imgur.com/3BLOa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3BLOa.png" alt="Difficulty Settings Slider" /></a></p>
  <p>As you see it is a slider that goes from 0.1x to 3x Difficulty.</p>
  <p>I have other sliders like this, for audio for example that just go from 0% to 100%.</p>
  <p>That works fine.</p>
  <p>However, with a minimum value greater than 0 my math breaks a bit and I'm stuck not being able to
  perfectly slide the bar all the way to the bottom because it isn't 0 and it is 0.1 instead.</p>
  <p>I want to make it to where even if the minimum value isn't 0, the bar goes all the way to empty.</p>
  <p>Here is the relevant equations/calculations at play:</p>
  <pre><code>var percent = val/val_max
  var adjustment = ((x2-x1)*val_min)-((((x2-x1)*val_min)*percent)*val_min)
  var x2_final = (x1+((x2-x1)*percent))-adjustment
  </code></pre>
  <p><strong>percent</strong> is the percentage of the current value relative to the max value (0.0 to 1.0)</p>
  <p><strong>adjustment</strong> is trying to find how much to additionally add/remove from x2_final based on the current value to keep the slider properly scaled when the minimum value isn't 0. (This is where the problem is)</p>
  <p><strong>x2_final</strong> is the final (in pixels) coordinate where the slider should stop based on the previous calculations.</p>
  <p>Initially the slider would over fill when full (that was fixed by the current adjustments) but now the slider doesn't go all the way empty and leaves a &quot;0.1&quot; worth of slider.</p>
  <p>I don't usually use forums or stackoverflow as I try to figure out things on my own but so I apologize if my explanation needs work.</p>
  <p>Here is what the slider looks like when I set it as low as it will go:</p>
  <p><a href="https://i.stack.imgur.com/fXl3q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fXl3q.png" alt="Slider Minimum Position" /></a></p>
  <p>Also, if I have more math related problems, are there any good tools I can use to help simulate my calculations like this so people can run it for them selves or something?</p>
  <p>Thanks in advance!</p>