Get Random RGB Values on a specific range
@param  integer $r     Red
@param  integer $g     Green
@param  integer $b     Blue
@param  integer $range Range to randomize given values
@return array        array of randomized rgb
357066
protected function getRGBFromRange($r, $g, $b, $range) {
		#	get randomized rgb values on a specific range from a agiven value

		if (!$range) {
			return array($r, $g, $b);
		}

		$range = round($range / 2);
		$color = array();

		# red
		$min = $r - $range;
		$max = $r + $range;

		if ($min < 0) {
			$min = 0;
		}

		if ($max > 255) {
			$max = 255;
		}

		$color['r'] = $color[0] = rand($min, $max);

		# Green
		$min = $g - $range;
		$max = $g + $range;

		if ($min < 0) {
			$min = 0;
		}

		if ($max > 255) {
			$max = 255;
		}

		$color['g'] = $color[1] = rand($min, $max);

		# blue
		$min = $b - $range;
		$max = $b + $range;

		if ($min < 0) {
			$min = 0;
		}

		if ($max > 255) {
			$max = 255;
		}

		$color['b'] = $color[2] = rand($min, $max);

		return $color;
	}
608020
public function initFromRgb($r, $g, $b)
    {
        $this->r = (int) $r;
        $this->g = (int) $g;
        $this->b = (int) $b;
        $this->a = 0;

        return $this;
    }
869549
def _get_color(self, r, g, b):
        
        clr = (r, g, b)
        return clr
1361717
function setColorRGB( $r, $g, $b, $force = 0 )
    {
        $this->setColor( eZMath::rgbToCMYK2( $r, $g, $b ), $force );
    }
1257285
public static function rgb2cmy( $rgb )
	{
		list( $r, $g, $b ) = $rgb;
		$c	= 1 - ( $r / 255 );
		$m	= 1 - ( $g / 255 );
		$y	= 1 - ( $b / 255 );
		return array( $c, $m, $y );
	}
923202
function getRGB(color) {
		var result;

		// Check if we're already dealing with an array of colors
		if ( color && color.constructor == Array && color.length == 3 )
			return color;

		// Look for rgb(num,num,num)
		if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
			return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];

		// Look for rgb(num%,num%,num%)
		if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
			return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];

		// Look for #a0b1c2
		if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
			return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];

		// Look for #fff
		if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
			return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];

		// Otherwise, we're most likely dealing with a named color
		return colors[jQuery.trim(color).toLowerCase()];
	}
743701
public function cmyk2rgb($c)
	{
		$rgb = [];
		$colors = 255 - ($c[4] * 2.55);
		$rgb[0] = (int) ($colors * (255 - ($c[1] * 2.55)) / 255);
		$rgb[1] = (int) ($colors * (255 - ($c[2] * 2.55)) / 255);
		$rgb[2] = (int) ($colors * (255 - ($c[3] * 2.55)) / 255);
		if ($c[0] == 6) {
			return [5, $rgb[0], $rgb[1], $rgb[2], $c[5]];
		}

		return [3, $rgb[0], $rgb[1], $rgb[2]];
	}
830947
public function backColor($r, $g, $b) {
        $this->renderer->setBackgroundColor(new Rgb($r, $g, $b));

        return $this;
    }
364615
public static float[] getHSVArray(int r, int g, int b) {
        float[] hsv = new float[3];

        float rf = r / MAX;
        float gf = g / MAX;
        float bf = b / MAX;

        float minRGB = Math.min(rf, Math.min(gf, bf));
        float maxRGB = Math.max(rf, Math.max(gf, bf));

        float computedH = 0;
        float computedS = 0;
        float computedV = minRGB;

        // Black-gray-white
        if (minRGB != maxRGB) {
            // Colors other than black-gray-white:
            float d = (rf == minRGB) ? gf - bf : ((bf == minRGB) ? rf - gf : bf - rf);
            float h = (rf == minRGB) ? 3 : ((bf == minRGB) ? 1 : 5);
            computedH = 60 * (h - d / (maxRGB - minRGB));
            computedS = (maxRGB - minRGB) / maxRGB;
            computedV = maxRGB;
        }

        hsv[0] = computedH;
        hsv[1] = computedS;
        hsv[2] = computedV;
        return hsv;
    }
331583
private static function _get_hue_based_max_rgb( $red, $green, $blue ) {
		$max_rgb = max( $red, $green, $blue );
		$min_rgb = min( $red, $green, $blue );

		$diff_max_min_rgb = $max_rgb - $min_rgb;

		if ( $red === $max_rgb ) {
			$hue = 60 * ( $diff_max_min_rgb ? ( $green - $blue ) / $diff_max_min_rgb : 0 );
		} elseif ( $green === $max_rgb ) {
			$hue = 60 * ( $diff_max_min_rgb ? ( $blue - $red ) / $diff_max_min_rgb : 0 ) + 120;
		} elseif ( $blue === $max_rgb ) {
			$hue = 60 * ( $diff_max_min_rgb ? ( $red - $green ) / $diff_max_min_rgb : 0 ) + 240;
		}

		return $hue;
	}
184515
private static function rgb($color) {

		return (object) [

			'r' => intval(hexdec(substr($color, 0, 2))),
			'g' => intval(hexdec(substr($color, 2, 2))),
			'b' => intval(hexdec(substr($color, 4, 2)))
		];
	}
316935
private static int[] getRGBs(IndexColorModel pColorModel) {
        int[] rgb = new int[pColorModel.getMapSize()];
        pColorModel.getRGBs(rgb);

        return rgb;
    }
849067
public void setColor(float r, float g, float b, float a) {
		if (color == Color.white) {
			color = new Color(r,g,b,a);
		} else {
			color.r = r;
			color.g = g;
			color.b = b;
			color.a = a;
		}
	}
584830
public function initFromRgb($r, $g, $b)
    {
        $this->r = intval($r);
        $this->g = intval($g);
        $this->b = intval($b);
        $this->a = 0;
    }
820400
function rgbToRgb(r, g, b){
    return {
        r: bound01(r, 255) * 255,
        g: bound01(g, 255) * 255,
        b: bound01(b, 255) * 255
    };
}
453204
public static void rgbToYuv( double r , double g , double b , double yuv[] ) {
		double y = yuv[0] = 0.299*r + 0.587*g + 0.114*b;
		yuv[1] = 0.492*(b-y);
		yuv[2] = 0.877*(r-y);
	}
517352
public function getLuminance($red, $green, $blue)
    {
        switch ($this->luminanceStrategy) {
            case 1:
                $luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;
                break;
            case 2:
                $luminance = ($red * 0.299 + $green * 0.587 + $blue * 0.114) / 255;
                break;
            case 3:
                $luminance = sqrt(0.299 * pow($red, 2) + 0.587 * pow($green, 2) + 0.114 * pow($blue, 2)) / 255;
                break;
            case 0:
            default:
                $luminance = ($red + $green + $blue) / (255 * 3);
        }

        return $luminance;
    }