-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrix.ps1
336 lines (300 loc) · 26.7 KB
/
Matrix.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<#
|====================================================================================>|
Matrix Animation [PwShell] by APoorv Verma [AP] on 8/21/2024
|====================================================================================>|
$) Multiple renderers (Windows, Unix)
$) Random Character Generation (+ Special Character Mode, like from the movie)
$) Object Oriented Model for Matrix Line (using Ticking logic)
$) Buffer / Cursor Position Saving (platform agnostic)
$) Dynamic Console Size Detection
$) Restore Console Properties upon Close
|====================================================================================>|
#>
using namespace System.Management.Automation.Host
param(
# Sparsity of the matrix effect (1 is fully dense, 0.1 is sparse)
[ValidateRange(0.0001, 1)][double]$Sparsity = 0.1,
# Sleep time in milliseconds between each frame
[ValidateRange(1)][int]$SleepTime = 50,
[ValidateSet("Windows", "Unix")][string]$Renderer = "Unix",
[Switch]$SpecialChars,
[Switch]$Debug
)
# =======================================START=OF=COMPILER==========================================================|
# The Following Code was added by AP-Compiler 1.6 (APC: 1.2) To Make this program independent of AP-Core Engine
# GitHub: https://github.com/avdaredevil/AP-Compiler
# ==================================================================================================================|
$Script:PSHell=$(if($PSHell){$PSHell}elseif($PSScriptRoot){$PSScriptRoot}else{"."});
$Script:AP_Console = @{version=[version]'1.2'; isShim = $true}
function B64 {param([Parameter(ValueFromPipeline=$true)][String]$Text, [ValidateSet("UTF8","Unicode")][String]$Encoding = "UTF8") [System.Text.Encoding]::$Encoding.GetString([System.Convert]::FromBase64String($Text))}
# This syntax is to prevent AV's from misclassifying this as anything but innocuous
& (Get-Alias iex) (B64 "ZnVuY3Rpb24gU3RyaXAtQ29sb3JDb2RlcyB7cGFyYW0oJFN0cikKDQogICAgJFN0ciB8ICUgeyRfIC1yZXBsYWNlICIkKFtyZWdleF06OmVzY2FwZSgiJChHZXQtRXNjYXBlKVsiKSlcZCsoXDtcZCspKm0iLCIifQ0KfQoKZnVuY3Rpb24gQVAtUmVxdWlyZSB7cGFyYW0oW1BhcmFtZXRlcihNYW5kYXRvcnk9JFRydWUpXVtBbGlhcygiRnVuY3Rpb25hbGl0eSIsIkxpYnJhcnkiKV1bU3RyaW5nXSRMaWIsIFtTY3JpcHRCbG9ja10kT25GYWlsLCBbU3dpdGNoXSRQYXNzVGhydSkKDQogICAgJExvYWRNb2R1bGUgPSB7DQogICAgICAgIHBhcmFtKCRGaWxlLFtib29sXSRJbXBvcnQpDQogICAgICAgIHRyeSB7SW1wb3J0LU1vZHVsZSAkRmlsZSAtZWEgc3RvcDtyZXR1cm4gMX0gY2F0Y2gge30NCiAgICAgICAgJExpYj1BUC1Db252ZXJ0UGF0aCAiPExJQj4iOyRMRiA9ICIkTGliXCRGaWxlIg0KICAgICAgICBbc3RyaW5nXSRmID0gaWYodGVzdC1wYXRoIC10IGxlYWYgJExGKXskTEZ9ZWxzZWlmKHRlc3QtcGF0aCAtdCBsZWFmICIkTEYuZGxsIil7IiRMRi5kbGwifQ0KICAgICAgICBpZiAoJGYgLWFuZCAkSW1wb3J0KSB7SW1wb3J0LU1vZHVsZSAkZn0NCiAgICAgICAgcmV0dXJuICRmDQogICAgfQ0KICAgICRTdGF0ID0gJChzd2l0Y2ggLXJlZ2V4ICgkTGliLnRyaW0oKSkgew0KICAgICAgICAiXkludGVybmV0JCIgICAgICAgICAgICAgICB7dGVzdC1jb25uZWN0aW9uIGdvb2dsZS5jb20gLUNvdW50IDEgLVF1aWV0fQ0KICAgICAgICAiXm9zOih3aW58bGludXh8dW5peCkkIiAgICB7JElzVW5peCA9ICRQU1ZlcnNpb25UYWJsZS5QbGF0Zm9ybSAtZXEgIlVuaXgiO2lmICgkTWF0Y2hlc1sxXSAtZXEgIndpbiIpIHshJElzVW5peH0gZWxzZSB7JElzVW5peH19DQogICAgICAgICJeYWRtaW4kIiAgICAgICAgICAgICAgICAgIHtUZXN0LUFkbWluaXN0cmF0b3J9DQogICAgICAgICJeZGVwOiguKikkIiAgICAgICAgICAgICAgIHtHZXQtV2hlcmUgJE1hdGNoZXNbMV19DQogICAgICAgICJeKGxpYnxtb2R1bGUpOiguKikkIiAgICAgIHskTG9hZE1vZHVsZS5pbnZva2UoJE1hdGNoZXNbMl0sICR0cnVlKX0NCiAgICAgICAgIl4obGlifG1vZHVsZSlfdGVzdDooLiopJCIgeyRMb2FkTW9kdWxlLmludm9rZSgkTWF0Y2hlc1syXSl9DQogICAgICAgICJeZnVuY3Rpb246KC4qKSQiICAgICAgICAgIHtnY20gJE1hdGNoZXNbMV0gLWVhIFNpbGVudGx5Q29udGludWV9DQogICAgICAgICJec3RyaWN0X2Z1bmN0aW9uOiguKikkIiAgIHtUZXN0LVBhdGggIkZ1bmN0aW9uOlwkKCRNYXRjaGVzWzFdKSJ9DQogICAgICAgIG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N0aW9uIEFsaWduLVRleHQge3BhcmFtKFtQYXJhbWV0ZXIoTWFuZGF0b3J5PSRUcnVlKV1bU3RyaW5nW11dJFRleHQsIFtWYWxpZGF0ZVNldCgiQ2VudGVyIiwiUmlnaHQiLCJMZWZ0IildW1N0cmluZ10kQWxpZ249J0NlbnRlcicpCg0KICAgIGlmICgkVGV4dC5jb3VudCAtZ3QgMSkgew0KICAgICAgICAkYW5zID0gQCgpDQogICAgICAgIGZvcmVhY2ggKCRsbiBpbiAkVGV4dCkgeyRBbnMgKz0gQWxpZ24tVGV4dCAkbG4gJEFsaWdufQ0KICAgICAgICByZXR1cm4gKCRhbnMpDQogICAgfSBlbHNlIHsNCiAgICAgICAgJFdpblNpemUgPSBbY29uc29sZV06OkJ1ZmZlcldpZHRoDQogICAgICAgICRDbGVhblRleHRTaXplID0gKFN0cmlwLUNvbG9yQ29kZXMgKCIiKyRUZXh0KSkuTGVuZ3RoDQogICAgICAgIGlmICgkQ2xlYW5UZXh0U2l6ZSAtZ2UgJFdpblNpemUpIHsNCiAgICAgICAgICAgICRBcHBlbmRlciA9IEAoIiIpOw0KICAgICAgICAgICAgJGogPSAwDQogICAgICAgICAgICBmb3JlYWNoICgkcCBpbiAwLi4oJENsZWFuVGV4dFNpemUtMSkpew0KICAgICAgICAgICAgICAgIGlmICgoJHArMSklJHdpbnNpemUgLWVxIDApIHskaisrOyRBcHBlbmRlciArPSAiIn0NCiAgICAgICAgICAgICAgICAjICIiKyRqKyIgLSAiKyRwDQogICAgICAgICAgICAgICAgJEFwcGVuZGVyWyRqXSArPSAkVGV4dC5jaGFycygkcCkNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIHJldHVybiAoQWxpZ24tVGV4dCAkQXBwZW5kZXIgJEFsaWduKQ0KICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgaWYgKCRBbGlnbiAtZXEgIkNlbnRlciIpIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gKCIgIipbbWF0aF06OnRydW5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AgIGlmICgkUGFzc1RocnUpIHtyZXR1cm4gJERhdGF9DQogICAgfQ0KfQo=")
# ========================================END=OF=COMPILER===========================================================|
function Get-RandomChar {
if (!$SpecialChars) {return [char](Get-Random -Minimum 33 -Maximum 126)}
$charSets = @(
# Katakana characters
@(0x30A0..0x30FF),
# Latin letters (uppercase and lowercase)
@(0x0041..0x005A + 0x0061..0x007A),
# Digits
@(0x0030..0x0039),
# Some special characters
@(0x0021, 0x0023, 0x0024, 0x0025, 0x002B, 0x003D, 0x003F, 0x0040),
# Additional Matrix-like symbols
@(0x25A0, 0x25A1, 0x25B2, 0x25B3, 0x25BC, 0x25BD)
)
$weights = @(
70, # Weight for Katakana
20, # Weight for Latin letters
5, # Weight for digits
3, # Weight for special characters
2 # Weight for additional symbols
)
$totalWeight = ($weights | Measure-Object -Sum).Sum
$randomValue = Get-Random -Minimum 1 -Maximum ($totalWeight + 1)
$currentWeight = 0
$selectedSet = -1
for ($i = 0; $i -lt $weights.Count; $i++) {
$currentWeight += $weights[$i]
if ($randomValue -le $currentWeight) {
$selectedSet = $i
break
}
}
try {
$char = [char](Get-Random -InputObject $charSets[$selectedSet])
} catch {
Write-Host "Selected set: $selectedSet | Set count: $($charSets.Count)"
exit
}
return $char
}
class MatrixLine {
[char[]]$Line
[int]$xOffset
[int]$Speed = 1
[int]$Size = 1
[bool]$IsDead = $false
hidden [int]$yOffset = 0
MatrixLine([int]$xOffset) {
$this.xOffset = $xOffset
$this.initialize()
$this.Speed = Get-Random -Minimum 1 -Maximum ([Math]::Max(2, $this.Size * .3))
}
MatrixLine([int]$xOffset, [int]$Speed) {
$this.xOffset = $xOffset
$this.Speed = $Speed
$this.initialize()
}
Hidden initialize() {
$this.Line = @()
$ConsoleHeight = $global:Host.UI.RawUI.WindowSize.Height
# Randomize the length of the line between 9% and 40% of the console height
$this.Size = Get-Random -Minimum ([Math]::Max(1, $ConsoleHeight * .09)) -Maximum ([Math]::Min([Math]::Max(2, $ConsoleHeight * .70), 50))
}
[bool]ValidateIsInBounds() {
if ($this.IsDead) { return $false }
$ConsoleWidth = $global:Host.UI.RawUI.WindowSize.Width
$ConsoleHeight = $global:Host.UI.RawUI.WindowSize.Height
if (($this.yOffset - $this.Size - 1) -gt $ConsoleHeight) {
$this.Die()
return $false
}
if ($this.xOffset -lt 0 -or $this.xOffset -ge $ConsoleWidth) {
$this.Die()
return $false
}
return $true
}
Tick() {
# Write-AP "x*","n_Ticking ($($this.IsDead) | $($this.ValidateIsInBounds()) | $($this.Line.Length) | $($this.Size) | $($this.yOffset) | $($this.xOffset))"
if (!$this.ValidateIsInBounds()) { return }
if ($this.Line.Length -lt $this.Size) {
$this.Line += Get-RandomChar
}
$this.Draw()
$this.yOffset += $this.Speed
}
Draw() {
$ConsoleHeight = $global:Host.UI.RawUI.WindowSize.Height
for ($i = 0; $i -lt $this.Line.Length; $i++) {
if ($this.yOffset + $i -ge $ConsoleHeight) { break }
$char = Get-RandomChar
if ($Script:Debug) {Place-BufferedContent -x ([Console]::WindowWidth - 50) -y 0 -Text " i: $i | $char | $($this.Line.Length) | $($this.yOffset + $i) | $($this.Line.Length - 1) "}
$RatioToFront = $(if ($i -eq ($this.Line.Length - 1) -and $this.yOffset) {1} else {$i / $this.Line.Length})
# WriteTo the Correct position
DrawTo -x $this.xOffset -y ($this.yOffset + $i) -RatioToFront $RatioToFront -text $char
}
# Erase the last character of the line
$LastYs = ($this.yOffset - $this.Line.Length)..($this.yOffset - $this.Line.Length - $this.Speed)
$LastYs | ? {$_ -ge 0 -and $_ -le $ConsoleHeight} | % {
DrawTo -x $this.xOffset -y $_ -RatioToFront -1 -text " "
}
}
Die() {
$this.IsDead = $true
}
}
function DrawTo([int]$x, [int]$y, [decimal]$RatioToFront, [string]$text) {
if ($Renderer -eq "Windows") {
if ($RatioToFront -eq -1) {
# Clear the position
Place-BufferedContent -x $x -y $y -Text " "
return
}
$Styles = @{
ForegroundColor = ""
BackgroundColor = [Console]::BackgroundColor
}
$Styles.ForegroundColor = $(if ($RatioToFront -eq 1) {"White"} elseif ($RatioToFront -ge 0.7) {"Green"} else {"DarkGreen"})
if ($RatioToFront -ge 0.7) {$Styles.BackgroundColor = "DarkGreen"}
Place-BufferedContent -x $x -y $y -Text "$text" @Styles
} elseif ($Renderer -eq "Unix") {
if ($RatioToFront -eq -1) {
# Clear the position
Write-Host -NoNewline "`e[$y;${x}H "
return
}
# Base green color (dark green to bright green)
$baseGreen = [Math]::Max(0, [Math]::Min(255, [int](50 + (205 * $RatioToFront))))
# Enhanced glow effect for leading characters
if ($RatioToFront -gt 0.7) {
$glowIntensity = ($RatioToFront - 0.7) / 0.3 # Normalized to 0-1 range
$red = [Math]::Min(255, [int](200 * $glowIntensity))
$green = 255 # Max brightness for green
$blue = [Math]::Min(255, [int](100 * $glowIntensity))
$escapeSequence = "`e[$y;${x}H`e[38;2;$red;$green;$blue m"
} else {
$escapeSequence = "`e[$y;${x}H`e[38;2;0;$baseGreen;0m"
}
Write-Host -NoNewline "$escapeSequence$text`e[0m"
}
}
function Setup-Console {
# Back up the current terminal buffer content
$Script:CurrBuffer = [Rectangle]::new(0, 0, $Host.UI.RawUI.BufferSize.Width, $Host.UI.RawUI.BufferSize.Height)
if ($Renderer -eq "Windows") {
try {
$Script:BufferContent = $Host.UI.RawUI.GetBufferContents($Script:CurrBuffer)
# Save the current cursor position
$Script:CursorPos = $Host.UI.RawUI.CursorPosition
# Hide the cursor
[Console]::CursorVisible = $false
} catch {
Write-AP "x*","n_Failed to get the current terminal buffer content: $_"
Start-Sleep 1
}
} elseif ($Renderer -eq "Unix") {
# Print ESC[?47h to save the current terminal buffer content
Write-Host "`e[?47h"
# # Save the current cursor position with ESC[s
# Write-Host "`e[s"
# Save Cursor Exact Position with ESC[6n
Write-Host "`e[6n"
while (!$Host.UI.RawUI.KeyAvailable) {Start-Sleep -Milliseconds 10; if ($iters -gt 15) {
Write-AP "-[Unix Renderer] Failed to get the cursor position"
exit
}}
$Global:cp = $Script:CursorPosUnix = $(while ($Host.UI.RawUI.KeyAvailable) {
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown,IncludeKeyUp")
}).Character -join ""
# Hide the cursor with ESC[?25l
Write-Host -NoNewline "`e[?25l"
}
Clear-Host
}
function Reset-Console {
if ($Renderer -eq "Windows") {
# Show the cursor
[Console]::CursorVisible = $true
# Clear the screen
Clear-Host
# Restore the original terminal buffer content
if ($Script:BufferContent) {
try {
Write-AP "x*","n_Restoring the original terminal buffer content"
$Coords = [Coordinates]::new(0, 0)
$Host.UI.RawUI.SetBufferContents($Coords, $Script:BufferContent)
} catch {
Write-Host -f Red "Failed to restore the original terminal buffer content: $_"
}
}
# Restore the original cursor position
if ($Script:CursorPos) {
try {
$Host.UI.RawUI.CursorPosition = $Script:CursorPos
} catch {
Write-Host -f Red "Failed to restore the original cursor position: $_"
}
}
} elseif ($Renderer -eq "Unix") {
# Print ESC[?47l to restore the original terminal buffer content
Write-Host "`e[?47l"
# Show the cursor with ESC[?25h
Write-Host "`e[?25h"
# # Restore the original cursor position with ESC[u
# Write-Host "`e[u"
# Restor the cursor position with ESC[<row>;<column>R
Write-Host "$Script:CursorPosUnix"
}
}
$Script:CurrMatrixLines = @()
function Get-GridColumns {
$ConsoleWidth = $global:Host.UI.RawUI.WindowSize.Width
return [Math]::Max(1, [Math]::Floor($ConsoleWidth * $Sparsity))
}
function Tick-MatrixAnimation {
$ConsoleWidth = $global:Host.UI.RawUI.WindowSize.Width
$TotalColumns = Get-GridColumns
# Make sure CurrMatrixLines is the same length as the console width
while ($Script:CurrMatrixLines.Length -lt $TotalColumns) {$Script:CurrMatrixLines += $null} # Add nulls until the length is correct
$Script:CurrMatrixLines = $Script:CurrMatrixLines[0..($TotalColumns - 1)] # Trim the array to the correct length
$EmptyLineIndeces = 0..($TotalColumns - 1) | ? { !$Script:CurrMatrixLines[$_] }
0..$Script:CurrMatrixLines.length | % {
if (!$Script:CurrMatrixLines[$_].IsDead) { return }
$Script:CurrMatrixLines[$_] = $null # Remove dead lines
}
if ($EmptyLineIndeces.Count -ne 0) {
# Generate Bounds for new Line
$ColumnWidth = [Math]::Max(1, [int]($ConsoleWidth / $TotalColumns))
$EmptyLineIndeces | Get-Random | % {
$ColumnIdx = $_
$ColumnMin = $ColumnIdx * $ColumnWidth
$ColumnMax = [Math]::Max($ColumnMin + 1, $ColumnWidth * ($ColumnIdx + 1))
if ($Debug) {Place-BufferedContent -x ([Console]::WindowWidth - 50) -y 1 -Text " $ColumnIdx | $ColumnMin | $ColumnMax | $ColumnWidth | $ConsoleWidth/$TotalColumns "}
$RandomX = [Math]::Floor((Get-Random -Minimum $ColumnMin -Maximum $ColumnMax))
$Script:CurrMatrixLines[$ColumnIdx] = [MatrixLine]::new($RandomX)
}
}
$CurrMatrixLines | ? {$_} | % { $_.Tick() }
}
function Script-Tick {
# Detect Escape and reset the terminal
While ($Host.UI.RawUI.KeyAvailable) {
$Store = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown,IncludeKeyUp")
if (KeyPressed "~~Escape~~" $Store) {
Reset-Console
exit
}
}
Tick-MatrixAnimation
Start-Sleep -Milliseconds $SleepTime
}
# Set up the console
Setup-Console
# Run the matrix effect
$Script:KnownDims = $Host.UI.RawUI.WindowSize
$SizeChanged = $false
while ($true) {
# Reset the console if the window size has changed
while (($Host.UI.RawUI.WindowSize.Width -ne $Script:KnownDims.Width) -or ($Host.UI.RawUI.WindowSize.Height -ne $Script:KnownDims.Height)) {
Clear-Host
$Script:KnownDims = $Host.UI.RawUI.WindowSize
Write-Host "Window size changed. Resetting console. | $($Host.UI.RawUI.WindowSize.Width) | $($Host.UI.RawUI.WindowSize.Height) | $($Script:KnownDims.Width) | $($Script:KnownDims.Height) | $(Get-Random)"
$SizeChanged = $true
Start-Sleep 1
}
if ($SizeChanged) {Clear-Host;$SizeChanged = $false}
Script-Tick
}