A PoSHy X-mas part two
And in this second part, let there be balls ..
# Merry X-mas from PoSH part 2
# http://thePowerShellGuy.com
Function Merry-Xmas {
1..2 |% {
$Peek = " ^ "
$tree = "/|\"
$i = 20
$pos = $host.ui.rawui.CursorPosition
write-host -fore 'Red' ($peek.PadLeft($i -1).PadRight(36) * 2)
write-host -fore 'green' ($tree.PadLeft($i -1).PadRight(36) * 2)
1..16 |% {
$tree = $tree -replace "/(.*)\\",'//$1\\'
write-host -fore 'green' ($tree.PadLeft($i).PadRight(36) * 2)
$i++
}
write-host -fore 'green' ("|||".PadLeft(19).PadRight(36) *2 )
write-host -fore 'green' ("|||".PadLeft(19).PadRight(36) *2)
$rect = New-Object System.Management.Automation.Host.Rectangle
$rect.top = $pos.y
$rect.Right = 70
$rect.Bottom = $pos.y + 19
$buffer = $host.ui.rawui.getbuffercontents($rect)
$R = new-object system.random
$ball = new-object System.Management.Automation.Host.BufferCell
$ball.Character = '@'
$ball.backgroundColor = $host.ui.rawui.BackgroundColor
1..120 |% {
sleep -m 120
$rx = $r.Next(19)
$ry = $r.Next(70)
$ball.ForegroundColor = $r.next(16)
if ($buffer[$rx,$ry].Character -eq '/') {$buffer[$rx,$ry] = $ball}
if ($buffer[$rx,$ry].Character -eq '\') {$buffer[$rx,$ry] = $ball}
$host.ui.rawui.SetBufferContents($pos,$buffer)
}
Write-Host -Fore 'red' "Merry X-mas From PoSH !"
}
}
Enjoy,
Greetings /\/\o\/\/