Colorful animation using VT100 - Pure batch WIN 10 only

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
IcarusLives
Posts: 175
Joined: 17 Jan 2016 23:55

Colorful animation using VT100 - Pure batch WIN 10 only

#1 Post by IcarusLives » 22 Aug 2017 08:18

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 :)!
Last edited by IcarusLives on 22 Aug 2017 16:51, edited 3 times in total.

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

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

#2 Post by penpen » 22 Aug 2017 09:03

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

IcarusLives
Posts: 175
Joined: 17 Jan 2016 23:55

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

#3 Post by IcarusLives » 22 Aug 2017 09:08

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.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

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

#4 Post by Aacini » 22 Aug 2017 09:32

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

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

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

#5 Post by Aacini » 22 Aug 2017 11:03

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

elzooilogico
Posts: 128
Joined: 23 May 2016 15:39
Location: Spain

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

#6 Post by elzooilogico » 22 Aug 2017 11:29

Antonio, did you ever tried ansicon? http://ansicon.adoxa.vze.com/

IcarusLives
Posts: 175
Joined: 17 Jan 2016 23:55

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

#7 Post by IcarusLives » 22 Aug 2017 11:40

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

miskox
Posts: 630
Joined: 28 Jun 2010 03:46

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

#8 Post by miskox » 22 Aug 2017 12:40

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

Post Reply