mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-23 05:01:37 +01:00
Updated write-xmas-tree.ps1
This commit is contained in:
parent
28ee2a5a44
commit
fd1cf4ea6c
@ -1,45 +1,37 @@
|
||||
# Prints a christmas tree to terminal
|
||||
# Writes a christmas tree to terminal
|
||||
# Variable $Size = (tree_height, trunk_width, trunk_height)
|
||||
# Variable $XPos = The starting x position on the terminal line
|
||||
# Variables $Colors = List of colors to use
|
||||
# Variables $colors = List of colors to use
|
||||
# Random color pattern each execution
|
||||
|
||||
# Examples:
|
||||
#PSXmasTree.ps1 #default
|
||||
#PSXmasTree.ps1 -Size 20,8,4 -Count 20 -Duration 800 #big tree
|
||||
#PSXmasTree.ps1 -Size 3,2,1 -XPos 20 #totes adorbs baby tree
|
||||
|
||||
param (
|
||||
[array]$Size=@(10,2,2),
|
||||
[array]$Size=@(20,8,4),
|
||||
[int]$XPos=50,
|
||||
[array]$Colors = @("blue", "green", "cyan", "red", "yellow", "magenta"),
|
||||
[int]$Idx = (Get-Random -Min 0 -Max ($Colors.Length-1)),
|
||||
[int]$Count = 10,
|
||||
[int]$Duration = 500
|
||||
[array]$colors = @("blue", "green", "cyan", "red", "yellow", "magenta"),
|
||||
[int]$Idx = (Get-Random -Min 0 -Max ($colors.Length-1)),
|
||||
[int]$count = 100,
|
||||
[int]$duration = 250 # ms
|
||||
)
|
||||
|
||||
while ( $Count -gt 0 ) {
|
||||
|
||||
Clear-Host
|
||||
|
||||
Write-Host "`n`n`n"
|
||||
Clear-Host
|
||||
do {
|
||||
[console]::SetCursorPosition(0,0)
|
||||
Write-Host "`n`tMerry Christmas and a Happy New Year!`n`n" -foregroundColor Yellow
|
||||
|
||||
for ( $i=1; $i -le $Size[0]; $i++ ) {
|
||||
$Line = " " * ($XPos - $i) + "*" * ($i * 2)
|
||||
$Idx = $Idx % $Colors.Length
|
||||
Write-Host $Line -ForegroundColor $Colors[$Idx]
|
||||
$line = " " * ($XPos - $i) + "*" * ($i * 2)
|
||||
$Idx = $Idx % $colors.Length
|
||||
Write-Host $line -foregroundColor $colors[$Idx]
|
||||
$Idx++
|
||||
}
|
||||
|
||||
for ( $j=1; $j -le $Size[2]; $j++ ){
|
||||
$Line = " " * ( $XPos - ( $Size[1] / 2 ) ) + "#" * $Size[1]
|
||||
Write-Host $Line -ForegroundColor White
|
||||
$line = " " * ( $XPos - ( $Size[1] / 2 ) ) + "#" * $Size[1]
|
||||
Write-Host $line -foregroundColor DarkGreen
|
||||
}
|
||||
|
||||
Start-Sleep -Milliseconds $Duration
|
||||
Start-Sleep -milliseconds $duration
|
||||
|
||||
$Count--
|
||||
$count--
|
||||
} while ($count -gt 0)
|
||||
|
||||
}
|
||||
|
||||
Write-Host "Merry Christmas!" -ForegroundColor Green
|
Loading…
Reference in New Issue
Block a user