Advertisement
T3RRYT3RR0R

ChaosBox

Jan 14th, 2023 (edited)
1,201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 5.33 KB | Source Code | 0 0
  1. @Echo off
  2.  
  3. REM Chaos Box by T3RRY
  4. REM ! EPILIPSY WARNING ! rapildly draws colored patterns with varying frequency
  5. REM This script Randomly generates Patterns by drawing Solid or Segmented boxes.
  6. REM nothing useful, Just for fun.
  7.  
  8. CHCP 65001 > nul
  9.  
  10. CLS
  11. Rem requires Windows 10
  12.  
  13. (Set \n=^^^
  14.  
  15. %= \n linefeed for macro definition. Do not modify =%)
  16.  
  17.     for /F %%a in ('Echo(prompt $E^| cmd')Do Set \E=%%a
  18.  
  19.     REM BuildLine is a macro implementation of Bresenham's line algorithm.
  20.     REM Macro refactored from Line and Plot macro's by IcarusLives As seen at https://www.dostips.com/forum/viewtopic.php?t=8469#p56154
  21.     REM this version is not escaped for definition with Delayed expansion enabled.
  22.     If "!!" == "" (
  23.         Echo(DelayedExpansion not permitted at this time
  24.         Pause > nul
  25.         Exit /B 1
  26.     )
  27.  
  28.     Set ^"DQ=""
  29.     Set CompArg=^!Argset:~0,1^!^!Argset:~-1^!
  30.  
  31.     Set BuildLine=For %%n in (1 2)Do if %%n==2 (%\n%
  32.         If "!ArgSet:~0,1!"==" " Set "ArgSet=!ArgSet:~1!"%\n%
  33.         Set ^"ArgSet=!ArgSet:"={DQ}!"%\n%
  34.         If not "!ArgSet:~0,4!!ArgSet:~-4!"=="{DQ}{DQ}" Set "ArgSet={DQ}!ArgSet!{DQ}"%\n%
  35.         Set ^"ArgSet=!ArgSet:{DQ}="!"%\n%
  36.         For %%A in (!ArgSet!) Do (%\n%
  37.             Set "BuildLineArgs=%%~A"%\n%
  38.         2^> nul (%!!%
  39.                 For /F "tokens=1-7 Delims= " %%G in ("!BuildLineArgs!")Do (%\n:Args - x1 y1 x2 y2 ForegroundCol CellSpacing Character [/C /O /R /P /A /N /D:Integer] =%
  40.                     set /a "stepY=1","stepX=1","xa=%%G", "ya=%%H", "xb=%%I", "yb=%%J", "dx=xb - xa","dy=yb - ya","FGc=%%K","interval=0","iMOD=%%L","Cout=0","Anim=0","aDelay=2500"%\n%
  41.                     Set "Screen=!Screen!!\E![38;5;!FGc!m"%\n%
  42.                     Set Char=^^%%M%\n%
  43.                 )%\n%
  44.                 If not "!BuildlineArgs:/O=!"=="!BuildLineArgs!" Set "Cout=1"%\n%
  45.                 If not "!BuildlineArgs:/D:=!"=="!BuildLineArgs!" (%\n%
  46.                     Set /A "aDelay=!BuildlineArgs:*/D:=!"%\n%
  47.                     Set "Anim=1"%\n%
  48.                 )%\n%
  49.                 If not "!BuildlineArgs:/A=!"=="!BuildLineArgs!" Set "Anim=1"%\n%
  50.                 If not "!BuildlineArgs:/R=!"=="!BuildLineArgs!" Set "Screen=!\E![38;5;!FGc!m"%\n%
  51.                 If not "!BuildlineArgs:/C=!"=="!BuildLineArgs!" (%\n%
  52.                     Set "Cursor=1"%\n%
  53.                     Set "Screen=%\E%[?25l!Screen!"%\n%
  54.                 )%\n%
  55.                 if !dy! lss 0 set /a "dy=-dy", "stepy=-1"%\n%
  56.                 if !dx! lss 0 set /a "dx=-dx", "stepx=-1"%\n%
  57.                 set /a "dx<<=1", "dy<<=1"%\n%
  58.                 if !dx! gtr !dy! (%\n%
  59.                     set /a "fraction=dy - (dx >> 1)"%\n%
  60.                     for /l %%x in (!xa!,!stepx!,!xb!) do (%\n%
  61.                         If !Fraction! geq 0 set /a "ya+=stepy", "fraction-=dx"%\n%
  62.                         Set /A "Interval=Interval %% !iMOD! + 1","fraction+=dy"%\n%
  63.                         If !Interval!==!iMOD! if 0 leq %%x if %%x lss 199 if 0 leq !ya! if !ya! lss 199 If !Interval!==!iMod! (%\n%
  64.                             set "Screen=!Screen!!\E![!ya!;%%xH!Char!"%\n%
  65.                             If !Anim!==1 (%\n%
  66.                                 ^<nul Set /P "=!\E![!ya!;%%xH!\E![38;5;!FGc!m!Char!!\E![0m"%\n%
  67.                                 For /L %%i in (1 1 !aDelay!)Do REM Delay%\n%
  68.                     )   )   )%\n%
  69.                 ) else (%\n%
  70.                     set /a "fraction=dx - (dy >> 1)"%\n%
  71.                     for /l %%y in (!ya!,!stepy!,!yb!) do (%\n%
  72.                         If !Fraction! geq 0 set /a "xa+=stepx", "fraction-=dy"%\n%
  73.                         Set /A "Interval=Interval %% !iMOD! + 1","fraction+=dx"%\n%
  74.                         If !Interval!==!iMOD! If !xa! LEQ !xb! If 0 leq !xa! if !xa! lss 199 if 0 leq %%y if %%y lss 199 if 0 leq !xa! if !xy! lss 199 if 0 leq %%y if %%y lss 199 (%\n%
  75.                             set "Screen=!Screen!!\E![%%y;!xa!H!Char!"%\n%
  76.                             If !Anim!==1 (%\n%
  77.                                 ^<nul Set /P "=!\E![%%y;!xa!H!\E![38;5;!FGc!m!Char!!\E![0m"%\n%
  78.                                 For /L %%i in (1 1 !aDelay!)Do REM Delay%\n%
  79.                     )   )   )%\n%
  80.                 )%\n%
  81.                 If !Cursor!==1 Set "Screen=!Screen!%\E%[?25h"%\n%
  82.                 If !Cout!==1 ^<nul Set /P "=!Screen!!\E![0m"%\n%
  83.                 If "!BuildLineArgs:/N=!"=="!BuildLineArgs!" If not "!Screen:~1023,1!"=="" (%\n: Dump the screen buffer if StrLen GEQ 1024 ~ optimal buffer size =%
  84.                     ^<nul Set /P "=!Screen!%\E%[0m"%\n%
  85.                     If "!BuildLineArgs:/P=!"=="!BuildLineArgs!" Set "Screen="%\n: If not /P used to Preserve Screen 'buffer'. =%
  86.                 )%\n%
  87.             )%\n%
  88.         )%\n%
  89.     )Else Set Argset=
  90.     Setlocal EnableDelayedExpansion
  91.  
  92. Mode 120,25
  93. REM (%%x*%%y) %%101 + 1l%%y+%%x+15
  94.     <nul Set /P "=%\E%[?25l"
  95.  
  96.     Set /A "ChaosShift=!random!%%3+1","fChaos=!Random! %%50 + 50","cChaos=!Random! %%155 +1","sXChaos=!Random!%%4+1","sYChaos=!Random!%%2+1","xsChaos=!Random!%%2+1","ysChaos=!Random!%%2+1","iXchaos=!Random!%%5+1","iYchaos!Random!%%3+1"
  97.     Set "signX=1 %sxChaos% 60"
  98.     Set "signY=1 %syChaos% 11"
  99.     If "%XsChaos%"=="1" Set "signX=60 -%sxChaos% 1"
  100.     If "%ysChaos%"=="1" Set "signY=11 -%syChaos% 1"
  101.  
  102.     Set "replay=0"
  103.     If exist "%TEMP%\%~n0_chaos.dat" (
  104.         Choice /N /M "replay last Y/N?"
  105.         If not errorlevel 2 (
  106.             For /F "usebackq delims=" %%G in ("%TEMP%\%~n0_chaos.dat")Do Set "%%G"
  107.             Set "replay=1"
  108.         )
  109.         Cls
  110.     )
  111.  
  112.     For /L %%x in (!signX!)Do For /L %%y in (!signY!)Do (
  113.         Set /A "x1=%%x","x2=121-%%x","y1=%%y","y2=22-%%y","c=(c+((%%x*%%y) %%125 + 1)<<3)&%fChaos%"
  114.         %Buildline% "!x1! !y1! !x2! !y1! !c! !iXchaos! ░ /R /O","!x1! !y2! !x2! !y2! !c! !iXchaos! ░ /R /O","!x1! !y1! !x1! !y2! !c! 1 ░ /R /O","!x2! !y1! !x2! !y2! !c! 1 ░ /R /O"
  115.     )
  116.  
  117.     <nul Set /P "=!screen!%\E%[22;1H%\E%[?25h!\E![0m!\E![1E"
  118.     If not "%replay%"=="1" (
  119.         Set | findstr /li "chaos sign" >"%TEMP%\%~n0_chaos.dat"
  120.         choice /n /m "View Data Y/N"
  121.         If not errorlevel 2 notepad "%TEMP%\%~n0_chaos.dat"
  122.     )
  123.  
  124. Endlocal & Goto:Eof
  125.  
  126.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement