Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ================================================================
- # Matrix Animation Launcher (Full Glyph Set + Classic Green Trail)
- # ================================================================
- $Directory = "C:\Install\Matrix"
- $File = Join-Path $Directory "Matrix.ps1"
- $ErrorLog = Join-Path $Directory "error.log"
- # Ensure directory exists
- If (-Not (Test-Path -Path $Directory)) {
- New-Item -Path $Directory -ItemType Directory | Out-Null
- }
- $Matrix = @'
- Start-Sleep -Milliseconds 50
- [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
- # --- Logging ---
- $ErrorActionPreference = "Continue"
- $LogFile = "C:\Install\Matrix\error.log"
- Start-Transcript -Path $LogFile -Append | Out-Null
- class Glyph {
- [int]$LastPosition
- [int]$CurrentPosition
- [int]$Velocity
- [int]$Intensity
- [double]$IntensityChange
- [char]$Current
- [char]$Last
- Glyph() { $this.Setup() }
- [void]Setup() {
- $this.CurrentPosition = $script:rand.Next(-$script:ScreenHeight, [Math]::Floor(0.6*$script:ScreenHeight))
- $this.Velocity = 1
- $this.Intensity = 0
- $this.IntensityChange = $script:rand.Next(1,20)/100
- $this.Current = $script:PossibleGlyphs[$script:rand.Next($script:glyphCount)]
- $this.Last = $script:PossibleGlyphs[$script:rand.Next($script:glyphCount)]
- }
- [void]Move() {
- $this.LastPosition = $this.CurrentPosition
- $this.Intensity += [Math]::Floor(255*$this.IntensityChange)
- if ($this.Intensity -gt 255) { $this.Intensity = 255 }
- $this.CurrentPosition += $this.Velocity
- $this.Last = $this.Current
- if ($this.Current -ne ' ') { $this.Current = $script:PossibleGlyphs[$script:rand.Next($script:glyphCount)] }
- if ($this.CurrentPosition -gt $script:ScreenHeight-1) { $this.Setup() }
- }
- }
- # --- Setup ---
- $script:rand = [System.Random]::new()
- $script:ScreenWidth = $host.UI.RawUI.WindowSize.Width
- $script:ScreenHeight = $host.UI.RawUI.WindowSize.Height
- $script:e = [char]27
- # --- Build full CJK glyph set ---
- $chars = [System.Collections.Generic.List[char]]::new()
- $allRanges = @(0x3040..0x309F) + @(0x30A0..0x30FF) + @(0x31F0..0x31FF) + @(0x3400..0x4DBF) + @(0x4E00..0x9FFF)
- foreach ($c in $allRanges) { $null = $chars.Add([char]$c) }
- [string[]]$script:PossibleGlyphs = $chars
- $script:glyphCount = $script:PossibleGlyphs.Count
- # --- Create Glyph objects ---
- [Glyph[]]$AllGlyphs = [Glyph[]]::new($script:ScreenWidth)
- for ($i=0;$i -lt $AllGlyphs.Count;$i++) { $AllGlyphs[$i] = [Glyph]::new() }
- # --- Prepare screen ---
- [Console]::CursorVisible = $false
- Clear-Host
- Write-Host "$e[38;5;16m$e[48;5;16m$e[H$e[J" -NoNewline
- $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
- # --- Main loop ---
- while (-not [System.Console]::KeyAvailable) {
- if ($stopwatch.Elapsed.TotalMilliseconds -gt 33.33) {
- for ($i=0;$i -lt $script:ScreenWidth;$i++) {
- $g = $AllGlyphs[$i]
- $g.Move()
- # Leader glyph in bright white
- if ($g.CurrentPosition -ge 0) {
- [Console]::CursorLeft = $i
- [Console]::CursorTop = [Math]::Floor($g.CurrentPosition)
- [Console]::Write("$e[48;5;16m$e[38;5;15m$($g.Current)")
- }
- # Tail glyph in green fading
- if ($g.LastPosition -ge 0) {
- [Console]::CursorLeft = $i
- [Console]::CursorTop = [Math]::Floor($g.LastPosition)
- [Console]::Write("$e[48;5;16m$e[38;2;0;$($g.Intensity);0m$($g.Last)")
- }
- }
- $stopwatch.Restart()
- }
- }
- [Console]::CursorVisible = $true
- Stop-Transcript | Out-Null
- $null = [Console]::ReadKey($true)
- Clear-Host
- '@
- # Save the script and run it
- $Matrix | Out-File -FilePath $File -Encoding UTF8
- Start-Process powershell -ArgumentList "-NoExit","-ExecutionPolicy Bypass","-File `"$File`" 2>`"$ErrorLog`""
Advertisement
Add Comment
Please, Sign In to add comment