I need an equation to calculate the percentage of $\color{red}{\text{hot}}$ water it would need to raise $\color{blue}{\text{cold}}$ water to $x$ degrees using a mixing valve. The mixing valve decreases the amount of $\color{blue}{\text{cold}}$ water as it increases the amount of $\color{red}{\text{hot}}$ water.
- $75\% \color{red}{\text{ hot }} 25\% \color{blue}{\text{ cold}}$
- $80\% \color{red}{\text{ hot }} 20\% \color{blue}{\text{ cold}}$
- etc.
Attached is a drawing for reference. I was able to calculate the mixing valve percent manually. I want a formula that can do it automatically.

Let $T_h$ be the temperature of the hot water, $T_c$ be the temperature of the cold water, $T_m$ the temperature of the mixture, and $r$ the mixing ratio.
Then, we have $$T_m=rT_h+(1-r)T_c.$$
This yields
$$r=\dfrac{T_m-T_c}{T_h-T_c}.$$