[go: up one dir, main page]

0% found this document useful (0 votes)
22 views2 pages

# Set Console Properties For Approx

The document is a PowerShell script that sets console properties to simulate a rain effect with characters in a 1920x1080 resolution. It creates columns of characters that fall down the console, randomly changing speed, length, and color. The script runs indefinitely, updating the display every 50 milliseconds.

Uploaded by

Kar Yan Lynn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

# Set Console Properties For Approx

The document is a PowerShell script that sets console properties to simulate a rain effect with characters in a 1920x1080 resolution. It creates columns of characters that fall down the console, randomly changing speed, length, and color. The script runs indefinitely, updating the display every 50 milliseconds.

Uploaded by

Kar Yan Lynn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# Set console properties for approximately 1920x1080 resolution

$Host.UI.RawUI.BackgroundColor = "Black"
Clear-Host

# Approximate 1920x1080 (16:9 aspect ratio) in console characters


# Using 120 columns (width) and 67 rows (height) to approximate 16:9
$width = 120
$height = 67

# Set console buffer and window size


$bufferSize = New-Object Management.Automation.Host.Size($width, $height)
$windowSize = New-Object Management.Automation.Host.Size($width, $height)
$Host.UI.RawUI.BufferSize = $bufferSize
$Host.UI.RawUI.WindowSize = $windowSize

# Array of characters to use


$chars = [char[]]('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F')

# Array for column positions


$columns = @()
for ($i = 0; $i -lt $width; $i++) {
$columns += [PSCustomObject]@{
X = $i
Y = Get-Random -Minimum 0 -Maximum $height
Speed = Get-Random -Minimum 1 -Maximum 3
Length = Get-Random -Minimum 5 -Maximum 15
Chars = @()
}
}

# Colors for the rain


$colors = @("Green", "DarkGreen", "White")

while ($true) {
# Update each column
foreach ($col in $columns) {
# Add new character at the top of the rain
if ($col.Y -lt $height) {
$col.Chars += [PSCustomObject]@{
Char = $chars | Get-Random
Y = $col.Y
Color = $colors | Get-Random
}
}

# Move column down


$col.Y += $col.Speed

# Remove old characters


$col.Chars = $col.Chars | Where-Object { $_ -and $_.Y -ge 0 -and $_.Y -lt
$height }

# Draw characters
foreach ($char in $col.Chars) {
if ($char.Y -ge 0 -and $char.Y -lt $height) {
[Console]::SetCursorPosition($col.X, $char.Y)
Write-Host $char.Char -ForegroundColor $char.Color -NoNewline
}
$char.Y += $col.Speed
}

# Clear old positions


if ($col.Chars.Count -gt $col.Length) {
$oldChar = $col.Chars[0]
[Console]::SetCursorPosition($col.X, $oldChar.Y)
Write-Host " " -NoNewline
$col.Chars = $col.Chars[1..($col.Chars.Count-1)]
}

# Reset column when it reaches bottom


if ($col.Y -ge $height + $col.Length) {
$col.Y = 0
$col.Chars = @()
$col.Speed = Get-Random -Minimum 1 -Maximum 3
$col.Length = Get-Random -Minimum 5 -Maximum 15
}
}

Start-Sleep -Milliseconds 50
}

You might also like