Advertisement
T3RRYT3RR0R

Text output in RGB color at X/Y Batch Macro

Aug 22nd, 2020 (edited)
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.07 KB | None | 0 0
  1. @Echo Off & Setlocal DisableDelayedExpansion
  2. mode 170,40
  3. rem // Creates variable /AE = Ascii-27 escape code.
  4.  For /F %%a in ('echo prompt $E ^| cmd')do set "/AE=%%a"
  5. (Set \n=^^^
  6. %=!Newline DNR!=%
  7. )
  8. Set "EOF=Pause > Nul & Endlocal & Endlocal & Goto :EOF" & rem // balance setlocal environment stacks
  9. rem // Usage: %Print%{Vt Color Sequence}{Y;X Position}{"text to be output"}
  10.   Set Print=For %%n in (1 2)Do If %%n==2 (%\n%
  11.    For /F "Delims=" %%G in ("!Args!")Do (%\n%
  12.     For /F "Tokens=1,2,3 Delims={}" %%i in ("%%G")Do Set "Output=%/AE%[%%~im%/AE%[%%~jH%%~k%/AE%[0m"%\n%
  13.     ^< Nul set /P "=!Output!"%\n%
  14.    )%\n%
  15.    Endlocal%\n%
  16.   )Else Setlocal EnableDelayedExpansion ^& Set Args=
  17.  Setlocal EnableDelayedExpansion
  18. rem // Usage example (complex)
  19.  Set "Chars=1<2>3?4^5&6$7(8)9|0@"
  20.  Set "[x1]=19 -2 1"& Set "[x2]=2 2 20"&Set "[y1]=20 -1 1"&Set "[y2]=0 1 20"
  21.  Set /A [g1]=75,[g2]=170
  22.  For %%v in (1 2) Do For /L %%Y in (![y%%v]!) Do for /L %%X in (![x%%v]!) Do %Print%{38;2;%%!!!!!%%v]!;%%X0}{%%Y;%%X}{"!Chars:~%%X,1!"}
  23. rem // exit script balancing environment stacks
  24. %EOF%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement