How to make a fade in range selector


I want to make the “background selector” change color according to the slider value, I want to make a gradient going from red to blue for each value changed or at least every 10, but I don’t know how to put this in the switch , it would look something like (if value >= 0 and value < 10, color red; if value >= 10 and value < 20, color -red)

ezgif.com-video-to-gif-converter


I did it this way, it worked but it doesn’t seem like the best option