Sets the color described by the ImagickPixel object using normalized values for hue, saturation and luminosity.
This example creates a red color, rotates the hue by 180 degrees and sets the new color.

Original color

r : 229
g : 26
b : 26
a : 1

Rotated color

r : 26
g : 229
b : 229
a : 1
Sets the color described by the ImagickPixel object using normalized values for hue, saturation and luminosity.
Parameters
huefloatThe normalized value for hue, described as a fractional arc (between 0 and 1) of the hue circle, where the zero value is red.
saturationfloatThe normalized value for saturation, with 1 as full saturation.
luminosityfloatThe normalized value for luminosity, on a scale from black at 0 to white at 1, with the full HS value at 0.5 luminosity.
        $output = "This example creates a red color, rotates the hue by 180 degrees and sets the new color.
"; //Create an almost pure red color $color = new \ImagickPixel('rgb(90%, 10%, 10%)'); $originalColor = clone $color; //Get it's HSL values $colorInfo = $color->getHSL(); //Rotate the hue by 180 degrees $newHue = $colorInfo['hue'] + 0.5; if ($newHue > 1) { $newHue = $newHue - 1; } //Set the ImagickPixel to the new color $color->setHSL($newHue, $colorInfo['saturation'], $colorInfo['luminosity']); $output .= "

Original color

"; $colorInfo = $originalColor->getcolor(); foreach ($colorInfo as $key => $value) { $output .= "$key : $value
"; } $output .= "

Rotated color

"; //Check that the new color is blue/green $colorInfo = $color->getcolor(); foreach ($colorInfo as $key => $value) { $output .= "$key : $value
"; } return $output;