
This script uses the DHTML ability of Internet Explorer v4+ to continuously capture the X/Y positions of the cursor within an element such as a DIV. The DIV containing the image has a onMouseMove event handler which captures the mouse position. It also has an onMouseDown event handler which uses the X/Y positions when the mouse is clicked to calculate the color values for that color.
The color wheel is for a brightness of 100%, and was obtained from a screen capture of the color picker on a Macintosh computer. By changing the brightness value (and then pressing the 'Tab' key), the entire range of colors may be displayed.
The code is extensively documented. Help yourself, but if you use the code on your own site, please give WebSorcerer credit somehow.
To calculate the green and blue values, the co-ordinates were rotated 120 or 240 degrees, respectively, and new x and y values for the chosen point calculated from the formula shown. JavaScript uses angles in radians for its calculations. Fortunately the value of pi is a built-in Math function.
