Page 1 of 1

Colorful animation using VT100 - Pure batch WIN 10 only

Posted: 22 Aug 2017 08:18
by IcarusLives
Hello Everyone!

Recently I've been playing with VT100 escape sequences, and learning how to utilize them. This is the begining of what I've come up with.

Image

I recycled my Rose petal algorithm, and implemented VT100 macros to move the cursor X;Y and to color the characters

Code: Select all

@echo off
set "moveCursor=<nul set /p "=;yH""
REM The important bit   ;yH
REM Contains ESC character[x;yH to position your cursor

%moveCursor:x;y=12;15%
echo Hello World




Code: Select all

@echo off & setlocal enableDelayedExpansion

for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"

set /a "hei=50", "wid=50", "heiXwid=hei * wid"
set "moveCursor=<nul set /p "=!ESC![x;yH""
mode con: cols=%wid% lines=%hei%

set "_SIN=a-a*a/1920*a/312500+a*a/1920*a/15625*a/15625*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000"
set "SIN(x)=(a=(x * 31416 / 180)%%62832, c=(a>>31|1)*a, a-=(((c-47125)>>31)+1)*((a>>31|1)*62832)  +  (-((c-47125)>>31))*( (((c-15709)>>31)+1)*(-(a>>31|1)*31416+2*a)  ), %_SIN%) / 10000"
set "COS(x)=(a=(15708 - x * 31416 / 180)%%62832, c=(a>>31|1)*a, a-=(((c-47125)>>31)+1)*((a>>31|1)*62832)  +  (-((c-47125)>>31))*( (((c-15709)>>31)+1)*(-(a>>31|1)*31416+2*a)  ), %_SIN%) / 10000"

for /l %%e in () do (
   
   set /a "angle+=1", "x=20 * !cos(x):x=5 * angle! * !sin(x):x=angle! + wid / 2", "y=20 * !cos(x):x=5 * angle! * !cos(x):x=angle! + hei / 2"
   
   %moveCursor:x;y=!x!;!y!%
   set /a "hue=angle / 15 %% 256"
   <nul set /p "=!ESC![38;5;!hue!m*!ESC![0m"
)



I really hope you all enjoy the pretty colors :)!

Re: Colorful animation using VT100 - Pure batch WIN 10 only

Posted: 22 Aug 2017 09:03
by penpen
It's a matter of taste, but you could also use this to initialize a variable with ESC-character, instead of hardcoding it:

Code: Select all

for /f "delims=#" %%a in ('"prompt #$E# &echo on &for %%b in (1) do rem"') do set "ESC=%%a"
set "ESC=!ESC:~0,1!"


penpen

Re: Colorful animation using VT100 - Pure batch WIN 10 only

Posted: 22 Aug 2017 09:08
by IcarusLives
Thanks for that, penpen! Perhaps I should be using that instead :P?!

I'll implement now so it's more clear where the ESC characters are.

Re: Colorful animation using VT100 - Pure batch WIN 10 only

Posted: 22 Aug 2017 09:32
by Aacini
The method to generate an ESC is simpler this way:

Code: Select all

for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"

Antonio

Re: Colorful animation using VT100 - Pure batch WIN 10 only

Posted: 22 Aug 2017 11:03
by Aacini
I tried this program in my Windows 8.1 computer using my AnsiSys.exe VT100 emulator. The result is just partially correct because my emulator have several bugs or incomplete sequences that I could not fix yet because I could not found an Ansy escape sequences table that describe the exact behavior when several sequences are combined (i.e. which sequences override previous ones?).

Image

Antonio

Re: Colorful animation using VT100 - Pure batch WIN 10 only

Posted: 22 Aug 2017 11:29
by elzooilogico
Antonio, did you ever tried ansicon? http://ansicon.adoxa.vze.com/

Re: Colorful animation using VT100 - Pure batch WIN 10 only

Posted: 22 Aug 2017 11:40
by IcarusLives
Aacini wrote:I tried this program in my Windows 8.1 computer using my AnsiSys.exe VT100 emulator. The result is just partially correct because my emulator have several bugs or incomplete sequences that I could not fix yet because I could not found an Ansy escape sequences table that describe the exact behavior when several sequences are combined (i.e. which sequences override previous ones?).

Image

Antonio


Perhaps this can be fixed by ending the ESC sequence after moving the cursor?

Code: Select all

%moveCursor:x;y=12;15%%esc%[0m

Re: Colorful animation using VT100 - Pure batch WIN 10 only

Posted: 22 Aug 2017 12:40
by miskox
Aacini wrote:...
The result is just partially correct because my emulator have several bugs or incomplete sequences that I could not fix yet because I could not found an Ansy escape sequences table that describe the exact behavior when several sequences are combined (i.e. which sequences override previous ones?).
Antonio


Antonio, maybe you could check VT420 or VT520/525 reference manual? You should look for DIGITAL's* manuals to get what you want/need (VT100 is DIGITAL's Video Terminal after all). Oh, OpenVMS memories.

Get some manuals here: www.kockarna.si/vt.zip (I will delete this file after a week or so - if anybody still wants if later just send me a message. I was working with VT220, VT420 and VT520 Video Terminals. Never had a chance to try VT525 (color version of 520))

(I have other manuals, too. I think this will do)

Saso


*DEC - Digital Equipment Corporation, later bought by Compaq, Compaq was bought by HP