Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @REM::::::: Multicolor Batch matrix Animations by T3RRY :::::::::::::::::::::::::::::::::::::::::::::
- ::: Updated 09 May 2020 :::
- ::: - Color gradiant Macro added for increased color range. :::
- ::: - Centering and spacing calculations added for displaying menu correctly at all screen Sizes :::
- ::: - Sring Length Macro added to facilitate the above :::
- ::: - Adjusted Menu Line spacing calculations to allow for easy addition of new lines :::
- @Echo Off & CD "%~dp0" & REM :::
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- CHCP 65001 >nul & REM Used for menu border characters
- ::: { Variable used in calling this script from the Self created resizing Batch.
- Set "AlignFile=%~dpnx0"
- ::: }
- ::: { Creates variable Æ = Ascii-27 escape code.
- ::: - http://www.dostips.com/forum/viewtopic.php?t=1733
- ::: - https://stackoverflow.com/a/34923514/12343998
- :::
- ::: - Æ (Alt 146) can be used with and without DelayedExpansion.
- Setlocal
- For /F "tokens=2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
- Endlocal
- Set "Æ=%%a"
- )
- ::: }
- ::: { Set environment state for Macro Definitions
- Setlocal DisableDelayedExpansion
- (Set LF=^
- %= Above Empty lines Required =%)
- Set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
- ::: { String length Macro %@strLen% <ResultVar> <String - Spaces must be substituted.>
- Set @strLen=for /L %%n in (1 1 2) do if %%n==2 (%\n%
- For /F "tokens=1,* delims=, " %%G in ("!argv!") do (%\n%
- Set tmpLen=%%H%\n%
- Set result=%%G%\n%
- Set LenTrim=Start%\n%
- For /L %%a in (1,1,250) Do (%\n%
- IF NOT "!LenTrim!"=="" (%\n%
- Set LenTrim=!tmpLen:~0,-%%a!%\n%
- If "!LenTrim!"=="" Set !result!=%%a%\n%
- )%\n%
- ) %\n%
- ) %\n%
- ) ELSE set argv=,
- ::: }
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Input / Color output Macros
- ::: { %MSG|% <"Your Message Value"> <%@Con%> <Y#;X#> <ColorName>
- Set "MSG|=Set Args-In="
- ::: }
- ::: { %@Con.Map% <Y#;X#> <Offset#> <ColorName> <StringLength#>
- Set @Con.Map=for /L %%n in (1 1 2) do if %%n==2 (%\n%
- For /F "tokens=1,2,3,4 delims=, " %%G in ("!argv!") do (%\n%
- Echo(%Æ%[%%GH!%%I!!CharacterSet:~%%H,%%J!!Off!^&^&Endlocal%\n%
- ) %\n%
- ) ELSE setlocal enableDelayedExpansion ^& set argv=,
- ::: }
- ::: { %@Gradient.Con.Map% <Y#;X#> <Offset#> <ColorName> <StringLength#>
- ::: - For all colors other than Red or Yellow RGB Color values will be totally random
- Set @Gradient.Con.Map=for /L %%n in (1 1 2) do if %%n==2 (%\n%
- For /F "tokens=1,2,3,4 delims=, " %%G in ("!argv!") do (%\n%
- Set /A RR#=!Random! %% 250,GG#=!Random! %% 250,BB#=!Random! %% 250 ^>Nul %\n%
- IF /I "%%I" == "red" Set /A RR#=!Random! %% 175 + 75,GG#=!Random! %% 10 + 10,BB#=!Random! %% 10 + 10 ^>Nul %\n%
- IF /I "%%I" == "yellow" Set /A RR#=!Random! %% 100 + 100,GG#=!Random! %% 40 + 100,BB#=!Random! %% 20 + 20 ^>Nul %\n%
- Echo(%Æ%[%%GH%Æ%!!!!!!;!GG#!;!BB#!m!CharacterSet:~%%H,%%J!!Off!^&^&Endlocal%\n%
- ) %\n%
- ) ELSE setlocal enableDelayedExpansion ^& set argv=,
- ::: }
- ::: { <%MSG|%> <"Your Message Value"> %@CON% <Y#;X#> <ColorName>
- Set @Con=^&for /L %%n in (1 1 2) do if %%n==2 (%\n%
- For /F "tokens=1,2 delims=, " %%G in ("!argv!") do (%\n%
- For %%O in (!Args-In!) do Echo(%Æ%[%%GH%Æ%[K!%%H!%%~O!Off!^&^&Endlocal%\n%
- ) %\n%
- ) ELSE setlocal enableDelayedExpansion ^& set argv=,
- ::: } End Macro Definitions
- ::: { Assigns ANSI color code values to each color, then builds an Array containing those color values to be accessed using random number.
- Setlocal EnableDelayedExpansion
- Set /A Red=31,Green=32,Yellow=33,Blue=34,Purple=35,Cyan=36,White=37,Grey=90,Pink=91,Beige=93,Aqua=94,Magenta=95,Teal=96,Off=0,Black=30,CI#=0
- For %%A in (Red,Yellow,Pink,Beige,Grey,Purple,Green,Cyan,White,Aqua,Magenta,Blue,Teal,Off,Black) do (
- Set "%%A=%Æ%[!%%A!m"
- Set /A "CI#+=1"
- Set "C#[!CI#!]=%%A"
- )
- ::: }
- ::: { Define character Set to be used. Accessed using Random number and Substring Modification to extract the character at that mapped position
- Set "CharacterSet=1qA{Z2W<sX[3EDC@4R}FV^5TG&BYHn7]UJM8-IK9OL0Ppo_iu>ytre$wQ\aSdf/gh~jkl+mN|bvc#xz"
- %!!%
- Set "BorderSet=•○ʘ¤"
- Set "Border[i]=3" & REM 1 less than number of Characters Due to use in Substring Offset
- ::: }
- ::: { Identifies when the program has been called by the resizing batch it creates and goes to label passed by call
- If Not "%~3"=="" (
- Set "Console_Hieght=%~1"
- Set "Console_Width=%~2"
- Set "AlignFile=%~4"
- Goto :%~3
- ) Else (Goto :main)
- ::: }
- ::: { Subroutine to process output of wmic command into usable variables for screen dimensions (resolution)
- :ChangeConsole <Lines> <Columns> <Label to Resume From> <If a 4th parameter is Defined, Aligns screen at top left>
- ::: - Get screen Dimensions
- For /f "delims=" %%# in ('"wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution /format:value"') do (
- Set "%%#">nul
- )
- ::: - Calculation of X axis relative to screen resolution and console size. Resolution scales to Max Columns ~ 165
- Set /A XresScale=CurrentHorizontalResolution / 165
- Set /A HorzCentre=CurrentHorizontalResolution / 2
- Set /A CentreX= ( HorzCentre - ( ( %~2 * XresScale ) / 2 ) ) - 8
- ::: - Calculation of Y axis relative to screen resolution and console size. Resolution scales to Max Lines ~ 43
- Set /A YresScale= CurrentVerticalResolution / 43
- Set /A VertCentre=CurrentVerticalResolution / 2
- Set /A CentreY= VertCentre - ( ( %~1 * YresScale ) / 2 )
- ::: - Optional 4th parameter can be used to align console at top left of screen instead of screen centre
- If Not "%~4"=="" (Set /A CentreY=0,CentreX=-8)
- Set "Console_Width=%~2"
- ::: - Creates a batch file to reopen the main script using Call with parameters to define properties for console change and the label to resume from.
- (
- Echo.@Mode Con: lines=%~1 cols=%~2
- Echo.@Title Rainbow Matrix by T3RRY
- Echo.@Call "%AlignFile%" "%~1" "%~2" "%~3" "%AlignFile%"
- )>"%temp%\ChangeConsole.bat"
- ::: - .Vbs script creation and launch to reopen batch with new console settings, with aid of above batch script
- (
- Echo.Set objWMIService = GetObject^("winmgmts:\\.\root\cimv2"^)
- Echo.Set objConfig = objWMIService.Get^("Win32_ProcessStartup"^)
- Echo.objConfig.SpawnInstance_
- Echo.objConfig.X = %CentreX%
- Echo.objConfig.Y = %CentreY%
- Echo.Set objNewProcess = objWMIService.Get^("Win32_Process"^)
- Echo.intReturn = objNewProcess.Create^("%temp%\ChangeConsole.bat", Null, objConfig, intProcessID^)
- )>"%temp%\Consolepos.vbs"
- ::: - Starts the companion batch script to Change Console properties, ends the parent.
- Start "" "%temp%\Consolepos.vbs" & Exit
- ::: { creates a companion batch file thats called with arguments for trackpath, volume and loop tf values
- :Sound.Components
- (
- Echo.@ECHO OFF
- Echo.Set "MusicPath=%%~1"
- ECHO.IF Not Exist "%%MusicPath%%" Goto :Eof
- Echo.Set "vol=%%~2"
- Echo.Set "Loop_TF=%%~3"
- ::: - Change to the Directory you want to create the Music Launcher in.
- Echo.PUSHD %%sounds%%
- ::: - Ensure no Conflict with the Previous Script.
- Echo.IF exist PlayMusic.vbs ^(
- Echo.DEL PlayMusic.vbs
- Echo.^)
- ::: - Creates a vbs Script to Launch the music (Occurs without any visual indication or prompting)
- Echo.^( echo Set Sound = CreateObject^("WMPlayer.OCX.7"^^^)
- Echo.echo Sound.URL = "%%MusicPath%%"
- Echo.echo Sound.settings.volume = %%vol%%
- Echo.echo Sound.settings.setMode "loop", %%Loop_TF%%
- Echo.echo Sound.Controls.play
- Echo.echo While Sound.playState ^^^<^^^> 1
- Echo.echo WScript.Sleep 1000
- Echo.echo Wend
- Echo.^)^>PlayMusic.vbs
- Echo.start /min PlayMusic.vbs
- ::: - Return to the Previous Directory
- Echo.POPD
- ::: - Exit the Launcher and return to Previous batch program.
- Echo.Goto :EOF
- )>"%Player%"
- ::: { Monitor checks process status of cmd.exe every 1500 ms and calls StopMusic batch file to taskill all vbs scripts when
- ::: - cmd.exe process count is 0. Delay is to reduce CPU usage of the WMI service
- (
- ECHO Set objWMIService = GetObject ("winmgmts:"^)
- ECHO Set proc = objWMIService.ExecQuery("select * from Win32_Process Where Name='cmd.exe'"^)
- ECHO DO while proc.count ^> 0
- ECHO Set proc = objWMIService.ExecQuery("select * from Win32_Process Where Name='cmd.exe'"^)
- ECHO if proc.count ^< 1 then exit do
- ECHO wscript.sleep 250
- ECHO loop
- ECHO Set WshShell=createobject("wscript.shell"^)
- ECHO WshShell.run "%MusicStopper%", 0, true
- )>"%Monitor%"
- ::: }
- ::: { Simple taskkill script to terminate vbs scripts on program exit
- (
- Echo.@ECHO OFF
- Echo.taskkill /pid WScript.exe /f /t ^>nul
- Echo.Goto :EOF
- )>"%MusicStopper%"
- Exit /B
- ::: }
- ::: { Download the songs this script uses.
- :Download_Songs
- %!!|%"Downloading song. %blue%1%green% of %yellow%5"%@Con% 1;1 green
- PUSHD %Sounds%
- Curl -s -O https://files.freemusicarchive.org/storage-freemusicarchive-org/music/ccCommunity/Kai_Engel/Caeli/Kai_Engel_-_07_-_modum.mp3
- %!!|%"Downloading song. %aqua%2%green% of %yellow%5"%@Con% 1;1 green
- Curl -s -O https://files.freemusicarchive.org/storage-freemusicarchive-org/music/ccCommunity/Kai_Engel/Atlantida/Kai_Engel_-_05_-_When_the_World_Falls_Down.mp3
- %!!|%"Downloading song. %cyan%3%green% of %yellow%5"%@Con% 1;1 green
- Curl -s -O https://files.freemusicarchive.org/storage-freemusicarchive-org/music/ccCommunity/Kai_Engel/Caeli/Kai_Engel_-_08_-_daemones.mp3
- %!!|%"Downloading song. %teal%4%green% of %yellow%5"%@Con% 1;1 green
- Curl -s -O https://files.freemusicarchive.org/storage-freemusicarchive-org/music/ccCommunity/Kai_Engel/Chapter_Four__Fall/Kai_Engel_-_07_-_Downpour_Pon_X.mp3
- %!!|%"Downloading song. %yellow%5%green% of %yellow%5"%@Con% 1;1 green
- Curl -s -O https://files.freemusicarchive.org/storage-freemusicarchive-org/music/ccCommunity/Kai_Engel/Satin/Kai_Engel_-_08_-_Downfall.mp3
- POPD
- CLS
- Exit /B
- ::: }
- :main
- ::: { Call Subroutine to Resize and Position the Console
- Call :ChangeConsole 40 165 Matrix
- ::: }
- ::: { Display Elements
- :Matrix
- Setlocal enableDelayedExpansion
- ::: { Define pathways and create subfolders used for self generated component files
- ::: - calls subroutines to create component files.
- For %%A in ("%AlignFile%") Do Set "ProgDir=%%~dpA"
- If not exist "%ProgDir%Sounds" MD "%ProgDir%Sounds"
- Set "Sounds=%ProgDir%Sounds"
- Set "Player=%Sounds%\BatchMusicPlayer.bat"
- Set "MusicStopper=%Sounds%\StopMusic.bat"
- Set "Monitor=%Sounds%\BatchMonitor.vbs"
- Call :Sound.Components
- ::: }
- ::: { Initiate script to close vbs scripts on exit
- Start "" "%monitor%"
- ::: }
- ::: { Define variables for songs
- Set "Modum=%Sounds%\Kai_Engel_-_07_-_modum.mp3"
- Set "World_Falls_Down=%Sounds%/Kai_Engel_-_05_-_When_the_World_Falls_Down.mp3"
- Set "Daemones=%Sounds%\Kai_Engel_-_08_-_daemones.mp3"
- Set "Downpour=%Sounds%\Kai_Engel_-_07_-_Downpour_Pon_X.mp3"
- Set "Downfall=%Sounds%\Kai_Engel_-_08_-_Downfall.mp3"
- IF Not exist "%Downfall%" Call :Download_Songs
- ::: }
- CALL "%Player%" "%Modum%" "100" "true"
- ::: { Variables used to animate Border
- Set /A BorderLeft=Console_Width / 3,BorderRight=(Console_Width / 3) * 2,BorderTop=5,BorderBase=Console_Hieght - 5,aCI=0,Char=0
- ::: }
- ::: { Calculate X Y Coordinates required to Centre Text Horizontally using String Length and Border Dimensions
- ::: Define number of menu options. Used to calculate even Line spacing.
- Set /A TextHCentre=Console_Width / 2
- %@StrLen% Line[1] [W]aterfall_Matrix
- %@StrLen% Line[2] [C]haos_Matrix
- %@StrLen% Line[3] [R]ainbow_Painting
- %@StrLen% Line[4] [F]laming_Matrix
- Set "Menu.Options=4"
- ::: - Calculate Spacing available for Lines of text relative to border size and number of menu options
- Set /A TextSpace=(BorderBase - BorderTop) / (Menu.Options + 1)
- ::: - Final Calculation of X Y values needed to centre text horizontaly and space / centre lines vertically.
- For /L %%P in (1,1,%Menu.Options%) Do Set /A Column[%%P]=TextHCentre - (Line[%%P] / 2) & Set /A Line[%%P]=BorderTop + ( %%P * %TextSpace% )
- ::: }
- ::: - Psuedo-pipe Strings for display into @Con Macro at [ARG 1 calculated Y;X Position] in [ARG 2 Color]
- :: Method allows for handling of complex strings containing additional color changes.
- %!!|% "[W]aterfall %cyan%Matrix" %@Con% %Line[1]%;%Column[1]% blue
- %!!|% "[C]haos %red%M%yellow%a%green%t%blue%r%purple%i%magenta%x" %@Con% %Line[2]%;%Column[2]% magenta
- %!!|% "%red%[%pink%R%magenta%]%purple%a%blue%i%aqua%n%cyan%b%green%o%yellow%w %red%painting" %@Con% %Line[3]%;%Column[3]% aqua
- %!!|% "[F]laming %yellow%Matrix" %@Con% %Line[4]%;%Column[4]% red
- ::: - Numbers higher than actual console hieght cause the the console to scroll. the higher the number, the smoother the scroll
- ::: - and the less dense the characters on screen will be.
- Set /A Console_Hieght=(Console_Hieght * 5) / 4
- :AnimateLoop
- ::: { Manipulate color and characters used for border.
- Set /A aCI+=1
- ::: - Loop through the Character set using String Substitution to Isolate a given Character
- IF "%Char%" EQU "%Border[i]%" (Set Char=0) Else (Set /A Char+=1)
- ::: - Loop through the Color Array
- IF "%aCI%"=="%CI#%" Set "aCI=1"
- ::: - Preface the Output string with the current Color
- FOR %%A in (!C#[%aCI%]!) do Set "ANIM=Echo.!%%A!"
- ::: - Build the Border box
- For /L %%X in (!BorderLeft!,1,!BorderRight!) do Set "ANIM=!ANIM!%Æ%[!BorderTop!;%%XH!BorderSet:~%Char%,1!%Æ%[!BorderBase!;%%XH!BorderSet:~%Char%,1!"
- For /L %%Y in (!BorderTop!,1,!BorderBase!) Do Set "ANIM=!ANIM!%Æ%[%%Y;!BorderLeft!H!BorderSet:~%Char%,1!%Æ%[%%Y;!BorderRight!H!BorderSet:~%Char%,1!"
- ::: - Output the border
- %ANIM%
- ::: }
- ::: { manipulate variables for color and line position to animate the prompt, with the aid of a Loop and Choice Timeout with Default Switch.
- For /F "Delims=" %%C in ('Choice /T 1 /N /C:WCRFA /D A') Do (Set "Selection=%%C" & IF /I "%%C"=="A" Goto :AnimateLoop)
- ::: }
- CLS & (CALL "%MusicStopper%" && Start "" "%monitor%") & Goto :loop.%Selection%
- ::: {** Script Break. Matrix Animation loops below. **}
- :loop.W
- TITLE Flow Matrix By T3RRY
- CALL "%Player%" "%Downpour%" "100" "true"
- :waterfall.loop
- For /L %%A in (1,1,125) do (
- Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%3 + 1
- %@Con.Map% !Ypos!;!Xpos! !Char! !C#[%nCI%]! !CharCount!
- )
- Goto :waterfall.loop
- :loop.C
- TITLE Chaos Matrix By T3RRY
- CALL "%Player%" "%Downfall%" "100" "true"
- :chaos.loop
- For /L %%A in (1,1,5000) do (
- Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%3 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[%%B]! !CharCount!
- )
- Goto :chaos.loop
- :loop.R
- TITLE Rainbow painter By T3RRY
- Set /A Console_Hieght=((Console_Hieght / 5) * 4) - 4
- CALL "%Player%" "%World_Falls_Down%" "100" "true"
- :rainbow.loop
- Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%3 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[%%B]! !CharCount!
- Goto :rainbow.loop
- :loop.F
- TITLE Flaming Matrix By T3RRY
- CALL "%Player%" "%Daemones%" "100" "true"
- :flame.loop
- For /L %%A in (1,1,100) do (
- Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%5 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[2]! !CharCount!
- Set /A Xpos-=1,Ypos+=1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%6 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[1]! !CharCount!
- Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%5 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[2]! !CharCount!
- Set /A Xpos-=1,Ypos+=1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%6 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[1]! !CharCount!
- Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%5 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[2]! !CharCount!
- Set /A Xpos+=1,Ypos+=1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%6 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[1]! !CharCount!
- Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%5 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[2]! !CharCount!
- Set /A Xpos+=1,Ypos-=1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%6 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[1]! !CharCount!
- Set /A Xpos=!random! %%!Console_Width! + 1,Ypos=!random! %%!Console_Hieght! + 1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%5 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[2]! !CharCount!
- Set /A Xpos-=1,Ypos-=1,Char=!random! %%79 + 1,nCI=!random! %%!CI#! + 1,CharCount=!random! %%6 + 1
- For %%B in (!nCI!) do %@Gradient.Con.Map% !Ypos!;!Xpos! !Char! !C#[1]! !CharCount!
- )
- Goto :flame.loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement