function Invoke-HueRotate
{
param( [uint] $Color, [decimal] $Degrees )
# split color into r, g and b channels
$r = ($Color -shr 16) -band 0xFF;
$g = ($Color -shr 8) -band 0xFF;
$b = ($Color -shr 0) -band 0xFF;
# convert degrees to radians and evaluate cos / sin
$cos$rad = [Math]::Cos($Degrees * [Math]::PI / 180);180;
$sin$cos = [Math]::SinCos($Degrees$rad);
* $sin = [Math]::PI / 180Sin($rad);
# long-hand matrix definition
# see https://drafts.fxtf.org/filter-effects/#feColorMatrixElement
# where it says 'For type="hueRotate"'
$a00 = 0.213 + ( 0.787 * $cos) + (-0.213 * $sin);
$a01 = 0.715 + (-0.715 * $cos) + (-0.715 * $sin);
$a02 = 0.072 + (-0.072 * $cos) + ( 0.928 * $sin);
$a10 = 0.213 + (-0.213 * $cos) + ( 0.143 * $sin);
$a11 = 0.715 + ( 0.285 * $cos) + ( 0.140 * $sin);
$a12 = 0.072 + (-0.072 * $cos) + (-0.283 * $sin);
$a20 = 0.213 + (-0.213 * $cos) + (-0.787 * $sin);
$a21 = 0.715 + (-0.715 * $cos) + ( 0.715 * $sin);
$a22 = 0.072 + ( 0.928 * $cos) + ( 0.072 * $sin);
# long-hand matrix multiplication
$r2 = ($a00 * $r) + ($a01 * $g) + ($a02 * $b);
$g2 = ($a10 * $r) + ($a11 * $g) + ($a12 * $b);
$b2 = ($a20 * $r) + ($a21 * $g) + ($a22 * $b);
# re-combine r, g and b channels
$result = [uint](
([Math]::Clamp([int]$r2, 0, 255) -shl 16) `
-bor
([Math]::Clamp([int]$g2, 0, 255) -shl 8) `
-bor
([Math]::Clamp([int]$b2, 0, 255) -shl 0) `
);
return $result;
}
$color = "#CC1100""#CC1100";
$original = ConvertFrom-HtmlColor -Value $color;
ConvertTo-HtmlColor $original;
#CC1100
$inverted = Invoke-InvertColor -Color $original;
ConvertTo-HtmlColor $inverted;
#33EEFF
$rotated = Invoke-HueRotate -Color $inverted -Degrees 180;
ConvertTo-HtmlColor $rotated;
#FFA190