Created
October 18, 2024 05:17
-
-
Save StartAutomating/abb3896a9d05661a400bb471eaf52168 to your computer and use it in GitHub Desktop.
Gist tell me how bright it is
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter GetLuma { | |
$colorString = $_ | |
# Convert the background color to a uint32 | |
$rgb = ($colorString -replace "#", "0x" -replace ';') -as [UInt32] | |
# then make it into a percentage red, green, and blue. | |
$r, $g, $b = ([float][byte](($rgb -band 0xff0000) -shr 16)/255), | |
([float][byte](($rgb -band 0x00ff00) -shr 8)/255), | |
([float][byte]($rgb -band 0x0000ff)/255) | |
# Calculate the luma of the background color | |
0.2126 * $R + 0.7152 * $G + 0.0722 * $B | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment