examples/rainbow-static.js
function colorWheel( WheelPos ){
        var r,g,b;
        WheelPos = 255 - WheelPos;

        if ( WheelPos < 85 ) {
            r = 255 - WheelPos * 3;
            g = 0;
            b = WheelPos * 3;
        } else if (WheelPos < 170) {
            WheelPos -= 85;
            r = 0;
            g = WheelPos * 3;
            b = 255 - WheelPos * 3;
        } else {
            WheelPos -= 170;
            r = WheelPos * 3;
            g = 255 - WheelPos * 3;
            b = 0;
        }
        // returns a string with the rgb value to be used as the parameter
        return "rgb(" + r +"," + g + "," + b + ")";
    }
function colorWheel( WheelPos ){
        var r,g,b;
        WheelPos = 255 - WheelPos;

        if ( WheelPos < 85 ) {
            r = 255 - WheelPos * 3;
            g = 0;
            b = WheelPos * 3;
        } else if (WheelPos < 170) {
            WheelPos -= 85;
            r = 0;
            g = WheelPos * 3;
            b = 255 - WheelPos * 3;
        } else {
            WheelPos -= 170;
            r = WheelPos * 3;
            g = 255 - WheelPos * 3;
            b = 0;
        }
        // returns a string with the rgb value to be used as the parameter
        return "rgb(" + r +"," + g + "," + b + ")";
    }
function colorWheel ( WheelPos ) { var r , g , b ; WheelPos = 255 - WheelPos ; if ( WheelPos < 85 ) { r = 255 - WheelPos * 3 ; g = 0 ; b = WheelPos * 3 ; } else if ( WheelPos < 170 ) { WheelPos -= 85 ; r = 0 ; g = WheelPos * 3 ; b = 255 - WheelPos * 3 ; } else { WheelPos -= 170 ; r = WheelPos * 3 ; g = 255 - WheelPos * 3 ; b = 0 ; } // returns a string with the rgb value to be used as the parameter return "rgb(" + r + "," + g + "," + b + ")" ; }
Input a value 0 to 255 to get a color value. The colours are a transition r - g - b - back to r.
Input a value 0 to 255 to get a color value . The colours are a transition r - g - b - back to r .