Created
July 24, 2018 04:38
-
-
Save mojeld/c70e9eed025f6725230fad8cb66e5265 to your computer and use it in GitHub Desktop.
PowerShell Color文字列 #000000をRGB分割してint型に変換表示
This file contains 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
<# | |
2018.07.24 | |
PowerShell 色文字(#000000)からRGB分けてint変換 | |
セキュリティがかかっている場合はSet-ExecutionPolicy RemoteSigned https://go.microsoft.com/fwlink/?LinkID=135170 を管理者モードで試す | |
PowerShellで rgb.ps1を実行した後、 > str_to_rgb -color "#00ff00" | |
#> | |
function global:str_to_rgb() | |
{ | |
Param([string]$color) | |
$local:rgb = @("r","g","b"); | |
for ($local:i = 0; $local:i -lt 3; $local:i++){ | |
$local:l_ = $rgb[$local:i] + "=" + [Convert]::ToInt64($color.Substring($local:i*2+1, 2),16) + "; " | |
$local:o_ = $local:o_ + $local:l_ | |
} | |
return $local:o_ | |
} | |
<# | |
str_to_rgb -color "#00ff00" | |
#上記のように実行すると下記のように返す | |
#r=0; g=255; b=0; | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment