public/javascripts/yui/colorpicker/colorpicker.js
function(r, g, b) {

            if (isArray(r)) {
                return this.websafe.apply(this, r);
            }

            // returns the closest match [0, 51, 102, 153, 204, 255]
            var f = function(v) {
                if (isNumber(v)) {
                    v = Math.min(Math.max(0, v), 255);
                    var i, next;
                    for (i=0; i<256; i=i+51) {
                        next = i+51;
                        if (v >= i && v <= next) {
                            return (v-i > 25) ? next : i;
                        }
                    }
                }

                return v;
            };

            return [f(r), f(g), f(b)];
        }
function(r, g, b) {

            if (isArray(r)) {
                return this.websafe.apply(this, r);
            }

            // returns the closest match [0, 51, 102, 153, 204, 255]
            var f = function(v) {
                if (isNumber(v)) {
                    v = Math.min(Math.max(0, v), 255);
                    var i, next;
                    for (i=0; i<256; i=i+51) {
                        next = i+51;
                        if (v >= i && v <= next) {
                            return (v-i > 25) ? next : i;
                        }
                    }
                }

                return v;
            };

            return [f(r), f(g), f(b)];
        }
function ( r , g , b ) { if ( isArray ( r ) ) { return this . websafe . apply ( this , r ) ; } // returns the closest match [0, 51, 102, 153, 204, 255] var f = function ( v ) { if ( isNumber ( v ) ) { v = Math . min ( Math . max ( 0 , v ) , 255 ) ; var i , next ; for ( i = 0 ; i < 256 ; i = i + 51 ) { next = i + 51 ; if ( v >= i && v <= next ) { return ( v - i > 25 ) ? next : i ; } } } return v ; } ; return [ f ( r ) , f ( g ) , f ( b ) ] ; }
Returns the closest websafe color to the supplied rgb value.
@method websafe
@param r {int|[int, int, int]} the red value, or an
array containing all three parameters
@param g {int} the green value
@param b {int} the blue value
@return {[int, int, int]} an array containing the closes
websafe rgb colors.
Returns the closest websafe color to the supplied rgb value .