mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 07:53:21 +01:00
Updated write-xmas-tree.ps1
This commit is contained in:
parent
7c5a3c7353
commit
62eef6a209
@ -1,23 +1,29 @@
|
|||||||
# Writes a christmas tree to terminal
|
<#
|
||||||
# Variable $Size = (tree_height, trunk_width, trunk_height)
|
.SYNOPSIS
|
||||||
# Variable $XPos = The starting x position on the terminal line
|
Writes a Xmas tree
|
||||||
# Variables $colors = List of colors to use
|
.DESCRIPTION
|
||||||
# Random color pattern each execution
|
This PowerShell script writes a christmas tree to the terminal.
|
||||||
|
.EXAMPLE
|
||||||
|
PS> ./write-xmas-tree.ps1
|
||||||
|
.LINK
|
||||||
|
https://github.com/fleschutz/PowerShell
|
||||||
|
.NOTES
|
||||||
|
Author: Markus Fleschutz | License: CC0
|
||||||
|
#>
|
||||||
|
|
||||||
param (
|
param( [array]$Size=@(21,8,4), # tree height, trunk width, trunk height
|
||||||
[array]$Size=@(20,8,4),
|
[int]$XPos=50, # starting x position
|
||||||
[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 = 100,
|
[int]$count = 100,
|
||||||
[int]$duration = 250 # ms
|
[int]$duration = 250) # ms
|
||||||
)
|
|
||||||
|
|
||||||
Clear-Host
|
Clear-Host
|
||||||
do {
|
do {
|
||||||
[console]::SetCursorPosition(0,0)
|
[console]::SetCursorPosition(0,0)
|
||||||
Write-Host "`n`tMerry Christmas and a Happy New Year!`n`n" -foregroundColor Yellow
|
Write-Host "`n`t`t`tMerry Christmas" -foregroundColor yellow
|
||||||
|
Write-Host "`t`t`t &" -foregroundColor yellow
|
||||||
|
Write-Host "`t`t`t Happy New Year" -foregroundColor yellow
|
||||||
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
|
||||||
@ -30,8 +36,8 @@ do {
|
|||||||
Write-Host $line -foregroundColor DarkGreen
|
Write-Host $line -foregroundColor DarkGreen
|
||||||
}
|
}
|
||||||
|
|
||||||
Start-Sleep -milliseconds $duration
|
|
||||||
|
|
||||||
|
Start-Sleep -milliseconds $duration
|
||||||
$count--
|
$count--
|
||||||
} while ($count -gt 0)
|
} while ($count -gt 0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user