Guest User

Matrix

a guest
Oct 27th, 2025
138
0
179 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 3.89 KB | Source Code | 0 0
  1. # ================================================================
  2. # Matrix Animation Launcher (Full Glyph Set + Classic Green Trail)
  3. # ================================================================
  4.  
  5. $Directory = "C:\Install\Matrix"
  6. $File = Join-Path $Directory "Matrix.ps1"
  7. $ErrorLog = Join-Path $Directory "error.log"
  8.  
  9. # Ensure directory exists
  10. If (-Not (Test-Path -Path $Directory)) {
  11.     New-Item -Path $Directory -ItemType Directory | Out-Null
  12. }
  13.  
  14. $Matrix = @'
  15. Start-Sleep -Milliseconds 50
  16. [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
  17.  
  18. # --- Logging ---
  19. $ErrorActionPreference = "Continue"
  20. $LogFile = "C:\Install\Matrix\error.log"
  21. Start-Transcript -Path $LogFile -Append | Out-Null
  22.  
  23. class Glyph {
  24.    [int]$LastPosition
  25.    [int]$CurrentPosition
  26.    [int]$Velocity
  27.    [int]$Intensity
  28.    [double]$IntensityChange
  29.    [char]$Current
  30.    [char]$Last
  31.  
  32.    Glyph() { $this.Setup() }
  33.  
  34.    [void]Setup() {
  35.        $this.CurrentPosition = $script:rand.Next(-$script:ScreenHeight, [Math]::Floor(0.6*$script:ScreenHeight))
  36.        $this.Velocity = 1
  37.        $this.Intensity = 0
  38.        $this.IntensityChange = $script:rand.Next(1,20)/100
  39.        $this.Current = $script:PossibleGlyphs[$script:rand.Next($script:glyphCount)]
  40.        $this.Last = $script:PossibleGlyphs[$script:rand.Next($script:glyphCount)]
  41.    }
  42.  
  43.    [void]Move() {
  44.        $this.LastPosition = $this.CurrentPosition
  45.        $this.Intensity += [Math]::Floor(255*$this.IntensityChange)
  46.        if ($this.Intensity -gt 255) { $this.Intensity = 255 }
  47.        $this.CurrentPosition += $this.Velocity
  48.  
  49.        $this.Last = $this.Current
  50.        if ($this.Current -ne ' ') { $this.Current = $script:PossibleGlyphs[$script:rand.Next($script:glyphCount)] }
  51.  
  52.        if ($this.CurrentPosition -gt $script:ScreenHeight-1) { $this.Setup() }
  53.    }
  54. }
  55.  
  56. # --- Setup ---
  57. $script:rand = [System.Random]::new()
  58. $script:ScreenWidth = $host.UI.RawUI.WindowSize.Width
  59. $script:ScreenHeight = $host.UI.RawUI.WindowSize.Height
  60. $script:e = [char]27
  61.  
  62. # --- Build full CJK glyph set ---
  63. $chars = [System.Collections.Generic.List[char]]::new()
  64. $allRanges = @(0x3040..0x309F) + @(0x30A0..0x30FF) + @(0x31F0..0x31FF) + @(0x3400..0x4DBF) + @(0x4E00..0x9FFF)
  65. foreach ($c in $allRanges) { $null = $chars.Add([char]$c) }
  66. [string[]]$script:PossibleGlyphs = $chars
  67. $script:glyphCount = $script:PossibleGlyphs.Count
  68.  
  69. # --- Create Glyph objects ---
  70. [Glyph[]]$AllGlyphs = [Glyph[]]::new($script:ScreenWidth)
  71. for ($i=0;$i -lt $AllGlyphs.Count;$i++) { $AllGlyphs[$i] = [Glyph]::new() }
  72.  
  73. # --- Prepare screen ---
  74. [Console]::CursorVisible = $false
  75. Clear-Host
  76. Write-Host "$e[38;5;16m$e[48;5;16m$e[H$e[J" -NoNewline
  77.  
  78. $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
  79.  
  80. # --- Main loop ---
  81. while (-not [System.Console]::KeyAvailable) {
  82.    if ($stopwatch.Elapsed.TotalMilliseconds -gt 33.33) {
  83.        for ($i=0;$i -lt $script:ScreenWidth;$i++) {
  84.            $g = $AllGlyphs[$i]
  85.            $g.Move()
  86.  
  87.            # Leader glyph in bright white
  88.            if ($g.CurrentPosition -ge 0) {
  89.                [Console]::CursorLeft = $i
  90.                [Console]::CursorTop = [Math]::Floor($g.CurrentPosition)
  91.                [Console]::Write("$e[48;5;16m$e[38;5;15m$($g.Current)")
  92.            }
  93.  
  94.            # Tail glyph in green fading
  95.            if ($g.LastPosition -ge 0) {
  96.                [Console]::CursorLeft = $i
  97.                [Console]::CursorTop = [Math]::Floor($g.LastPosition)
  98.                [Console]::Write("$e[48;5;16m$e[38;2;0;$($g.Intensity);0m$($g.Last)")
  99.            }
  100.        }
  101.        $stopwatch.Restart()
  102.    }
  103. }
  104.  
  105. [Console]::CursorVisible = $true
  106. Stop-Transcript | Out-Null
  107. $null = [Console]::ReadKey($true)
  108. Clear-Host
  109. '@
  110.  
  111. # Save the script and run it
  112. $Matrix | Out-File -FilePath $File -Encoding UTF8
  113. Start-Process powershell -ArgumentList "-NoExit","-ExecutionPolicy Bypass","-File `"$File`" 2>`"$ErrorLog`""
  114.  
Advertisement
Add Comment
Please, Sign In to add comment