Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Echo off
- REM Chaos Box by T3RRY
- REM ! EPILIPSY WARNING ! rapildly draws colored patterns with varying frequency
- REM This script Randomly generates Patterns by drawing Solid or Segmented boxes.
- REM nothing useful, Just for fun.
- CHCP 65001 > nul
- CLS
- Rem requires Windows 10
- (Set \n=^^^
- %= \n linefeed for macro definition. Do not modify =%)
- for /F %%a in ('Echo(prompt $E^| cmd')Do Set \E=%%a
- REM BuildLine is a macro implementation of Bresenham's line algorithm.
- REM Macro refactored from Line and Plot macro's by IcarusLives As seen at https://www.dostips.com/forum/viewtopic.php?t=8469#p56154
- REM this version is not escaped for definition with Delayed expansion enabled.
- If "!!" == "" (
- Echo(DelayedExpansion not permitted at this time
- Pause > nul
- Exit /B 1
- )
- Set ^"DQ=""
- Set CompArg=^!Argset:~0,1^!^!Argset:~-1^!
- Set BuildLine=For %%n in (1 2)Do if %%n==2 (%\n%
- If "!ArgSet:~0,1!"==" " Set "ArgSet=!ArgSet:~1!"%\n%
- Set ^"ArgSet=!ArgSet:"={DQ}!"%\n%
- If not "!ArgSet:~0,4!!ArgSet:~-4!"=="{DQ}{DQ}" Set "ArgSet={DQ}!ArgSet!{DQ}"%\n%
- Set ^"ArgSet=!ArgSet:{DQ}="!"%\n%
- For %%A in (!ArgSet!) Do (%\n%
- Set "BuildLineArgs=%%~A"%\n%
- 2^> nul (%!!%
- 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] =%
- 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%
- Set "Screen=!Screen!!\E![38;5;!FGc!m"%\n%
- Set Char=^^%%M%\n%
- )%\n%
- If not "!BuildlineArgs:/O=!"=="!BuildLineArgs!" Set "Cout=1"%\n%
- If not "!BuildlineArgs:/D:=!"=="!BuildLineArgs!" (%\n%
- Set /A "aDelay=!BuildlineArgs:*/D:=!"%\n%
- Set "Anim=1"%\n%
- )%\n%
- If not "!BuildlineArgs:/A=!"=="!BuildLineArgs!" Set "Anim=1"%\n%
- If not "!BuildlineArgs:/R=!"=="!BuildLineArgs!" Set "Screen=!\E![38;5;!FGc!m"%\n%
- If not "!BuildlineArgs:/C=!"=="!BuildLineArgs!" (%\n%
- Set "Cursor=1"%\n%
- Set "Screen=%\E%[?25l!Screen!"%\n%
- )%\n%
- if !dy! lss 0 set /a "dy=-dy", "stepy=-1"%\n%
- if !dx! lss 0 set /a "dx=-dx", "stepx=-1"%\n%
- set /a "dx<<=1", "dy<<=1"%\n%
- if !dx! gtr !dy! (%\n%
- set /a "fraction=dy - (dx >> 1)"%\n%
- for /l %%x in (!xa!,!stepx!,!xb!) do (%\n%
- If !Fraction! geq 0 set /a "ya+=stepy", "fraction-=dx"%\n%
- Set /A "Interval=Interval %% !iMOD! + 1","fraction+=dy"%\n%
- If !Interval!==!iMOD! if 0 leq %%x if %%x lss 199 if 0 leq !ya! if !ya! lss 199 If !Interval!==!iMod! (%\n%
- set "Screen=!Screen!!\E![!ya!;%%xH!Char!"%\n%
- If !Anim!==1 (%\n%
- ^<nul Set /P "=!\E![!ya!;%%xH!\E![38;5;!FGc!m!Char!!\E![0m"%\n%
- For /L %%i in (1 1 !aDelay!)Do REM Delay%\n%
- ) ) )%\n%
- ) else (%\n%
- set /a "fraction=dx - (dy >> 1)"%\n%
- for /l %%y in (!ya!,!stepy!,!yb!) do (%\n%
- If !Fraction! geq 0 set /a "xa+=stepx", "fraction-=dy"%\n%
- Set /A "Interval=Interval %% !iMOD! + 1","fraction+=dx"%\n%
- 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%
- set "Screen=!Screen!!\E![%%y;!xa!H!Char!"%\n%
- If !Anim!==1 (%\n%
- ^<nul Set /P "=!\E![%%y;!xa!H!\E![38;5;!FGc!m!Char!!\E![0m"%\n%
- For /L %%i in (1 1 !aDelay!)Do REM Delay%\n%
- ) ) )%\n%
- )%\n%
- If !Cursor!==1 Set "Screen=!Screen!%\E%[?25h"%\n%
- If !Cout!==1 ^<nul Set /P "=!Screen!!\E![0m"%\n%
- If "!BuildLineArgs:/N=!"=="!BuildLineArgs!" If not "!Screen:~1023,1!"=="" (%\n: Dump the screen buffer if StrLen GEQ 1024 ~ optimal buffer size =%
- ^<nul Set /P "=!Screen!%\E%[0m"%\n%
- If "!BuildLineArgs:/P=!"=="!BuildLineArgs!" Set "Screen="%\n: If not /P used to Preserve Screen 'buffer'. =%
- )%\n%
- )%\n%
- )%\n%
- )Else Set Argset=
- Setlocal EnableDelayedExpansion
- Mode 120,25
- REM (%%x*%%y) %%101 + 1l%%y+%%x+15
- <nul Set /P "=%\E%[?25l"
- 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"
- Set "signX=1 %sxChaos% 60"
- Set "signY=1 %syChaos% 11"
- If "%XsChaos%"=="1" Set "signX=60 -%sxChaos% 1"
- If "%ysChaos%"=="1" Set "signY=11 -%syChaos% 1"
- Set "replay=0"
- If exist "%TEMP%\%~n0_chaos.dat" (
- Choice /N /M "replay last Y/N?"
- If not errorlevel 2 (
- For /F "usebackq delims=" %%G in ("%TEMP%\%~n0_chaos.dat")Do Set "%%G"
- Set "replay=1"
- )
- Cls
- )
- For /L %%x in (!signX!)Do For /L %%y in (!signY!)Do (
- Set /A "x1=%%x","x2=121-%%x","y1=%%y","y2=22-%%y","c=(c+((%%x*%%y) %%125 + 1)<<3)&%fChaos%"
- %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"
- )
- <nul Set /P "=!screen!%\E%[22;1H%\E%[?25h!\E![0m!\E![1E"
- If not "%replay%"=="1" (
- Set | findstr /li "chaos sign" >"%TEMP%\%~n0_chaos.dat"
- choice /n /m "View Data Y/N"
- If not errorlevel 2 notepad "%TEMP%\%~n0_chaos.dat"
- )
- Endlocal & Goto:Eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement