I am trying to generate a unique RGB value for each x,y coordinate on a screen (I am doing this in JS).
It is not important that each RGB value shows up at least once, but it is important that each RGB value that does show up is unique (not all colors need to show up, but there can be no duplicate colors).
I have seen many people recommend using HSL/HSV to ensure all colors are used, however since this is not necessary in my case I am wondering if there is a simpler way.
The method I have come up with is the following:
var x = event.pageX/window.screen.width;
var y = event.pageY/window.screen.height;
var z = 1-x-y;
var r = parseInt(x*255);
var g = parseInt(y*255);
var b = parseInt(z*255);
I convert the x and y coordinates to values between 0 and 1, get z from those two, and then multiply by 255 to go from values between 0-1 to 1-255.
Although this is functional, there are duplicate colors around x~0.5 and y~0.5 and it misses a sizable portion of the RGB color spectrum.
Does anyone know of a better way of doing this while still staying relatively simplistic?