mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-29 13:14:49 +02: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 $Size = (tree_height, trunk_width, trunk_height)
|
||||||
# Variable $XPos = The starting x position on the terminal line
|
# 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
|
# 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 (
|
param (
|
||||||
[array]$Size=@(10,2,2),
|
[array]$Size=@(20,8,4),
|
||||||
[int]$XPos=50,
|
[int]$XPos=50,
|
||||||
[array]$Colors = @("blue", "green", "cyan", "red", "yellow", "magenta"),
|
[array]$colors = @("blue", "green", "cyan", "red", "yellow", "magenta"),
|
||||||
[int]$Idx = (Get-Random -Min 0 -Max ($Colors.Length-1)),
|
[int]$Idx = (Get-Random -Min 0 -Max ($colors.Length-1)),
|
||||||
[int]$Count = 10,
|
[int]$count = 100,
|
||||||
[int]$Duration = 500
|
[int]$duration = 250 # ms
|
||||||
)
|
)
|
||||||
|
|
||||||
while ( $Count -gt 0 ) {
|
Clear-Host
|
||||||
|
do {
|
||||||
Clear-Host
|
[console]::SetCursorPosition(0,0)
|
||||||
|
Write-Host "`n`tMerry Christmas and a Happy New Year!`n`n" -foregroundColor Yellow
|
||||||
Write-Host "`n`n`n"
|
|
||||||
|
|
||||||
for ( $i=1; $i -le $Size[0]; $i++ ) {
|
for ( $i=1; $i -le $Size[0]; $i++ ) {
|
||||||
$Line = " " * ($XPos - $i) + "*" * ($i * 2)
|
$line = " " * ($XPos - $i) + "*" * ($i * 2)
|
||||||
$Idx = $Idx % $Colors.Length
|
$Idx = $Idx % $colors.Length
|
||||||
Write-Host $Line -ForegroundColor $Colors[$Idx]
|
Write-Host $line -foregroundColor $colors[$Idx]
|
||||||
$Idx++
|
$Idx++
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( $j=1; $j -le $Size[2]; $j++ ){
|
for ( $j=1; $j -le $Size[2]; $j++ ){
|
||||||
$Line = " " * ( $XPos - ( $Size[1] / 2 ) ) + "#" * $Size[1]
|
$line = " " * ( $XPos - ( $Size[1] / 2 ) ) + "#" * $Size[1]
|
||||||
Write-Host $Line -ForegroundColor White
|
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