Last active
August 27, 2020 17:40
-
-
Save dpo007/816f7b809e3f4dbc76df84f89f7a699c to your computer and use it in GitHub Desktop.
PowerShell function :: A simple console Write-Host animation
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
function DiscoWrite { | |
param ( | |
[string]$str, | |
[int]$speed = 25, | |
[switch]$NoNewline | |
) | |
$anim = @('.', '-', '+', '*', '#') | |
[int]$CursorTop = [Console]::CursorTop | |
foreach ($letter in $str.ToCharArray()) { | |
[int]$CursorLeft = [Console]::CursorLeft | |
foreach ($frame in $anim) { | |
Write-Host $frame -NoNewline | |
[Console]::SetCursorPosition($CursorLeft, $CursorTop) | |
Start-Sleep -m $speed | |
} | |
Write-Host $letter -NoNewline | |
} | |
if (!$NoNewLine) { | |
Write-Host | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment