I'm doing a simple game, and I intend for a color to change pitch proportionally to a value , that is, for example if I have a light blue color in the background ( this would correspond to the value 0) and as this value increases that blue color is darker (to the maximum value of that value), or a simple rule of three, but of course I do not know how to provide this with the colors. I would appreciate any help, what I have so far is this (which is almost nothing), but I do not know if I'm on track.
//Las variables speed y time están en otra función pero es simplemente que se vea que no es una constante.
var value = time + speed; //Este valor es el que varía, y como máximo puede llegar a 100, pues a media que este valor aumenta hacer el color "azul claro" más oscuro.
var initialColor = {r: 0, g: 146, b: 237}; //Este sería el color que me gustaría que fuese cada vez más oscuro a medida que aumente el valor
/* Y aquí se supone que debería de calcularse el color más oscuro jugando con los valores r, g y b
*
*
*
*
*
*/
$("#background").css("background","rgba(" + r + ", " + g + ", " + b + ", 1)");