There is a way to do it that won't take "days" but it is math heavy.
Essentially you'd have two loops (nested) that run from (0,0,0) to (hue1, hue2, hue3), depending on what the hue is (for red, it would be (255,0,0)). The other loop would run from those values over to (y,y,y) for the black-to-white gradient. Then you'd need a slider bar to change the hue value.
(You'd want to look up HVS to RGB conversion algorithms).