If I set red to 255, instead of a gray box I get a white box.
I guess you should map the values to the 0-255 range
I found this example on the forum:
(x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
which would translate for blue and green to:
(loopindex - 0) * (255 - 0) / (1280 - 0) + 0
or int(loopindex*255/1280)
Ok, this gives some interesting colour transitions when changing the value of red, but nothing close to the red and black square you show..
Guess I'm making a mistake..