title: Converting temperature to RGB value
body: <p>I am calculating the current temperature to RGB related to a maximum temperature:</p>
  
  <pre><code>val = round(temp / tempMax * 255, 0);
  if (val &gt; 255) val = 255;
  </code></pre>
  
  <p>In maths the function is <code>v=temp/tempMax*255</code>. 
  This works for a temperature between 0 and tempMax. </p>
  
  <p>I want to do the same but in an area between <code>minTemp</code> and <code>maxTemp-5</code>. 
  That means if the temp is exactly minTemp, val should be 0 and if it is maxTemp-5 it should be 255. all temperature that are lower than minTemp set val to zero and there will be special if statement for the area between maxTemp-5 and maxTemp. All the ifs are no problem but how do I need to modify my function that it calculating proportionally to the given borders?</p>