Return hue from max rgb

@param dec $red
@param dec $green
@param dec $blue
@return hue
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;
	}
359874
public function setBackgroundColor($red, $green, $blue)
    {
        $this->red = $red;
        $this->green = $green;
        $this->blue = $blue;

        return $this;
    }
898048
public static function rgbToHsl($red, $green, $blue)
    {
        if (\min($red, $green, $blue) < 0) {
            throw new InvalidArgumentException('The parameters for rgbToHsl should be no less than 0');
        }

        if (\max($red, $green, $blue) > 0xFF) {
            throw new InvalidArgumentException('The parameters for rgbToHsl should be no more than 255');
        }

        $clrMin = \min($red, $green, $blue);
        $clrMax = \max($red, $green, $blue);
        $deltaMax = $clrMax - $clrMin;

        $L = ($clrMax + $clrMin) / 510;

        if (0 == $deltaMax) {
            $H = 0;
            $S = 0;
        } else {
            if (0.5 > $L) {
                $S = $deltaMax / ($clrMax + $clrMin);
            } else {
                $S = $deltaMax / (510 - $clrMax - $clrMin);
            }

            if ($clrMax === $red) {
                $H = ($green - $blue) / (6.0 * $deltaMax);

                if (0 > $H) {
                    $H += 1.0;
                }
            } elseif ($clrMax === $green) {
                $H = 1 / 3 + ($blue - $red) / (6.0 * $deltaMax);
            } else {
                $H = 2 / 3 + ($red - $green) / (6.0 * $deltaMax);
            }
        }

        return array(
            (float) ($H * 360 % 360),
            (float) ($S * 100),
            (float) ($L * 100),
        );
    }
5794
function _hexToDecColor($hex)
    {
        $length = strlen($hex);
        $color['red'] = hexdec(substr($hex, $length - 6, 2));
        $color['green'] = hexdec(substr($hex, $length - 4, 2));
        $color['blue'] = hexdec(substr($hex, $length - 2, 2));
        return $color;
    }
364133
private function restrictCmykColorSpace($c, $color, &$PDFAXwarnings = [])
	{
		if ($this->mpdf->PDFA && $this->mode != 3) {
			if ($this->mpdf->PDFA && !$this->mpdf->PDFAauto) {
				$PDFAXwarnings[] = "CMYK color specified '" . $color . "' (converted to RGB)";
			}
			$c = $this->colorModeConverter->cmyk2rgb($c);
		} elseif ($this->mode == 1) {
			$c = $this->colorModeConverter->cmyk2gray($c);
		} elseif ($this->mode == 2) {
			$c = $this->colorModeConverter->cmyk2rgb($c);
		}

		return $c;
	}
20133
private static int toAnsi(int red, int green, int blue)
    {
        // rescale to 0-5 range
        red = red * 6 / 256;
        green = green * 6 / 256;
        blue = blue * 6 / 256;

        return 16 + red * 36 + green * 6 + blue;
    }
1279081
public static function fromRgba(int $red, int $green, int $blue, float $alpha) : TransparentColour
    {
        return new self(new Colour($red, $green, $blue), $alpha);
    }
392046
def set_color(self, red, green, blue):
        
        if self._pwm_enabled:
            # Set duty cycle of PWM pins.
            rdc, gdc, bdc = self._rgb_to_duty_cycle((red, green, blue))
            self._pwm.set_duty_cycle(self._red, rdc)
            self._pwm.set_duty_cycle(self._green, gdc)
            self._pwm.set_duty_cycle(self._blue, bdc)
        else:
            # Set appropriate backlight pins based on polarity and enabled colors.
            self._gpio.output_pins({self._red:   self._blpol if red else not self._blpol,
                                    self._green: self._blpol if green else not self._blpol,
                                    self._blue:  self._blpol if blue else not self._blpol })
262443
public function rgb2cmyk($c)
	{
		$cyan = 1 - ($c[1] / 255);
		$magenta = 1 - ($c[2] / 255);
		$yellow = 1 - ($c[3] / 255);
		$min = min($cyan, $magenta, $yellow);

		if ($min == 1) {
			if ($c[0] == 5) {
				return [6, 100, 100, 100, 100, $c[4]];
			}

			return [4, 100, 100, 100, 100];
			// For K-Black
			//if ($c[0]==5) { return array (6,0,0,0,100, $c[4]); }
			//else { return array (4,0,0,0,100); }
		}
		$K = $min;
		$black = 1 - $K;
		if ($c[0] == 5) {
			return [6, ($cyan - $K) * 100 / $black, ($magenta - $K) * 100 / $black, ($yellow - $K) * 100 / $black, $K * 100, $c[4]];
		}

		return [4, ($cyan - $K) * 100 / $black, ($magenta - $K) * 100 / $black, ($yellow - $K) * 100 / $black, $K * 100];
	}
940688
public Color getFromRGB(final int red, final int green, final int blue) {
        return this.getFromString("#" + this.toHexString(red) + this.toHexString(green) + this
                        .toHexString(blue));
    }
1299822
public function setLightAmbientColor($red, $green, $blue)
    {
        $this->lightAmbientColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
        return $this;
    }
703736
function allocateColor( $name, $red, $green, $blue )
    {
        if ( isset( $this->Palette[$name] ) )
        {
            eZDebug::writeError( 'Color already defined: ' . $name, __METHOD__ );
            return null;
        }
        $red = max( 0, min( 255, $red ) );
        $green = max( 0, min( 255, $green ) );
        $blue = max( 0, min( 255, $blue ) );
        $color = ImageColorAllocate( $this->ImageObject, $red, $green, $blue );
        $this->Palette[$name] = $color;
        $this->PaletteIndex[] = $color;
        return $color;
    }
106203
public function rgb($red, $green, $blue)
    {
        $this->setValues($red, $green, $blue);

        return $this;
    }
90104
public static function getColorCode($color, $options = array())
    {
        $code = (int) $color;
        if (is_string($color)) {
            $options = array_merge(explode('+', strtolower($color)), $options);
            $color = array_shift($options);
            if (!isset(self::$colors[$color])) {
                throw new ConsoleException("Unknown color '$color'");
            }
            $code = self::$colors[$color];
        }
        foreach ($options as $opt) {
            $opt = strtolower($opt);
            if (!isset(self::$options[$opt])) {
                throw new ConsoleException("Unknown option '$color'");
            }
            $code = $code | self::$options[$opt];
        }
        return $code;
    }
573998
public function getRgbByColor($color) {
		$result = imagecolorsforindex($this->image, $color);
		return array(
			$result['red'],
			$result['green'],
			$result['blue']
		);
	}
1033731
def set_rgb(self, red, green, blue):
        
        x, y = rgb_to_xy(red, green, blue)
        self.xy = [x, y]
1211437
public function setLightBallColor($red, $green, $blue)
    {
        $this->lightBallColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
        return $this;
    }