Can someone explain how JavaScript color pickers work? (The ones that don’t use HTML5 canvas.)
My first idea was to generate (thousands of) 1px divs programmatic ally and give them a slightly different background color. But I think there has to be a better solution than this!
For a standard picker, you need a static image with an alpha gradient from left (opaque) to right (transparent), and a color gradient from top (white) to bottom (black). Create a DIV, and the image in it.
The Hue picker is a static image. When a hue is selected, the background color of the DIV changes to this hue. The transparent image on top of the DIV will alter this underlying color, and simulate a proper color picker. Magic isn’t it ?
Edit: This is an HSV picker, the hue picker selects, well, the Hue. The X coordinate on the big picker is the Saturation, and the Y is the Brightness (or value). You will then probably need an HSV to RGB algorithm.