Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
IcarusLives
- Posts: 175
- Joined: 17 Jan 2016 23:55
#1
Post
by IcarusLives » 07 May 2019 22:07
Hello everyone,
Here is a particle system! they change colors as they rise. Not much to be impressed about, just a fun visual. Enjoy!
Code: Select all
@echo off & setlocal enableDelayedExpansion
( for /f %%a in ('echo prompt $E^| cmd') do set "esc=%%a" ) & echo !esc![?25l
set "temperature[0]=[38;2;7;7;7mÛ[0m"
set "temperature[1]=[38;2;31;7;7mÛ[0m"
set "temperature[2]=[38;2;47;15;7mÛ[0m"
set "temperature[3]=[38;2;71;15;7mÛ[0m"
set "temperature[4]=[38;2;87;23;7mÛ[0m"
set "temperature[5]=[38;2;103;31;7mÛ[0m"
set "temperature[6]=[38;2;119;31;7mÛ[0m"
set "temperature[7]=[38;2;143;39;7mÛ[0m"
set "temperature[8]=[38;2;159;47;7mÛ[0m"
set "temperature[9]=[38;2;175;63;7mÛ[0m"
set "temperature[10]=[38;2;191;71;7mÛ[0m"
set "temperature[11]=[38;2;199;71;7mÛ[0m"
set "temperature[12]=[38;2;223;79;7mÛ[0m"
set "temperature[13]=[38;2;223;87;7mÛ[0m"
set "temperature[14]=[38;2;223;87;7mÛ[0m"
set "temperature[15]=[38;2;215;95;7mÛ[0m"
set "temperature[16]=[38;2;215;95;7mÛ[0m"
set "temperature[17]=[38;2;215;103;15mÛ[0m"
set "temperature[18]=[38;2;207;111;15mÛ[0m"
set "temperature[19]=[38;2;207;119;15mÛ[0m"
set "temperature[20]=[38;2;207;127;15mÛ[0m"
set "temperature[21]=[38;2;207;135;23mÛ[0m"
set "temperature[22]=[38;2;199;135;23mÛ[0m"
set "temperature[23]=[38;2;199;143;23mÛ[0m"
set "temperature[24]=[38;2;199;151;31mÛ[0m"
set "temperature[25]=[38;2;191;159;31mÛ[0m"
set "temperature[26]=[38;2;191;159;31mÛ[0m"
set "temperature[27]=[38;2;191;167;39mÛ[0m"
set "temperature[28]=[38;2;191;167;39mÛ[0m"
set "temperature[29]=[38;2;191;175;47mÛ[0m"
set "temperature[30]=[38;2;183;175;47mÛ[0m"
set "temperature[31]=[38;2;183;183;47mÛ[0m"
set "temperature[32]=[38;2;183;183;55mÛ[0m"
set "temperature[33]=[38;2;207;207;111mÛ[0m"
set "temperature[34]=[38;2;223;223;159mÛ[0m"
set "temperature[35]=[38;2;239;239;199mÛ[0m"
set "temperature[36]=[38;2;255;255;255mÛ[0m"
set /a "max=36", "mag=4"
set /a "hei=wid=max", "objects=max * mag"
mode %wid%,%hei%
for /l %%a in (1,1,%objects%) do set /a "y[%%a]=!random! %% hei + hei","x[%%a]=%%a / mag","ys[%%a]=!random! %% mag + 1"
for /l %%# in () do (
for /l %%a in (1,1,%objects%) do (
if !y[%%a]! lss 0 ( set /a "y[%%a]=hei" ) else set /a "ly=y[%%a]","y[%%a]-=ys[%%a]"
for %%y in (!y[%%a]!) do set "screen=!screen!%esc%[!ly!;!x[%%a]!H %esc%[!y[%%a]!;!x[%%a]!H!temperature[%%y]!"
)
<nul set /p "=!screen!" & set "screen="
)
-
Jer
- Posts: 177
- Joined: 23 Nov 2014 17:13
- Location: California USA
#2
Post
by Jer » 08 May 2019 09:23
Any idea why the batch code does this? The termination is my doing.
This is all displayed in a smaller window, same as your image.
My O/S: Microsoft Windows [Version 10.0.17134.706]
Code: Select all
[38;2;191;71;7m█[0m [38;2;175; 63;7m█[0m;199;7[3[38;2;199;71;[38;2; 175;63;7m█[0m38;2;223;79;7m█[0m38;[3 8;2;191;71;7m█[0m[38;2;215;95;7m█[0m
38;2;207;1[38;2;215;95;7 █[0m [3
8;[3 ;2;215;95; m [0m2;207 38; 38;2;
[38;2;215;95 7m█[0m█[0m27;15m█ 0m0 3
[38; ;20[38;2[38;2;21[38;2;215;1[38; 2;215;95;7m█[0m3m█[0m[38;2;207;127 1
38;2;207;119;1[38;2;207;119;1[38;2; 215;103;15m█[0m;2;207 127;15m█[0m;2;
207;135; 3m█[ m;2;199 143;23m[38 2;2
07;119;15m█[0m5 ;31[38;2;199;135;23m
█[0m2;19 ;16 3 m█[[38;2;191;1 9 31m
█[0 159;31m█ 0m ;39m[38;2;199 151;31
m█[0m7;3 [[[3[38[38 2;191;159;31m█[0
m█[0m75;4[[38;2;191 [38[38;2;191;167
;39m█[0m[38;2;191;16[38[38;2;191;[38 ;2;191;159;31m█[0m2; 91;167[38;2;191
;159;31m█[0m7 ;4 m█[0m8 2;[38;[38 2;
191;167;39m█[0m[0mm█[38;2;183;175;47
m█[0m0m3[[38;2;183;183;47m 0[38; ;1
91;175;47m█[0m83;183;5[38;2;[38;2;18
3;175;47m█[0m[38;2;2 7 207;[38 2;183
;183;47m█[0m23;223[38;2;2[38 ;207;2
07;111m█[0m38 [3[3 [38;2;23[3[3[[38; 2;207;207;111m█[0m 2 [3[38;2;[38;2;
223;223;159m█[0m [ 8;2;239;
239;199m█[0m ^ CTerminate batch job (Y/N)?
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#3
Post
by aGerman » 08 May 2019 09:39
Did you check "Use legacy console" in the console properties? If so, uncheck it.
Steffen
EDIT Nope, I'm facing the same problem with this particular code.
-
penpen
- Expert
- Posts: 2009
- Joined: 23 Jun 2013 06:15
- Location: Germany
#4
Post
by penpen » 08 May 2019 11:19
I think IcarusLives initially used the esc-character itself in that batch and replaced it by a delayed variable later (adding some slight errors), so the following should work:
Code: Select all
@echo off & setlocal enableDelayedExpansion
( for /f %%a in ('echo prompt $E^| cmd') do set "esc=%%a" ) & echo !esc![?25l
set "temperature[0]=[38;2;7;7;7mÛ"
set "temperature[1]=[38;2;31;7;7mÛ"
set "temperature[2]=[38;2;47;15;7mÛ"
set "temperature[3]=[38;2;71;15;7mÛ"
set "temperature[4]=[38;2;87;23;7mÛ"
set "temperature[5]=[38;2;103;31;7mÛ"
set "temperature[6]=[38;2;119;31;7mÛ"
set "temperature[7]=[38;2;143;39;7mÛ"
set "temperature[8]=[38;2;159;47;7mÛ"
set "temperature[9]=[38;2;175;63;7mÛ"
set "temperature[10]=[38;2;191;71;7mÛ"
set "temperature[11]=[38;2;199;71;7mÛ"
set "temperature[12]=[38;2;223;79;7mÛ"
set "temperature[13]=[38;2;223;87;7mÛ"
set "temperature[14]=[38;2;223;87;7mÛ"
set "temperature[15]=[38;2;215;95;7mÛ"
set "temperature[16]=[38;2;215;95;7mÛ"
set "temperature[17]=[38;2;215;103;15mÛ"
set "temperature[18]=[38;2;207;111;15mÛ"
set "temperature[19]=[38;2;207;119;15mÛ"
set "temperature[20]=[38;2;207;127;15mÛ"
set "temperature[21]=[38;2;207;135;23mÛ"
set "temperature[22]=[38;2;199;135;23mÛ"
set "temperature[23]=[38;2;199;143;23mÛ"
set "temperature[24]=[38;2;199;151;31mÛ"
set "temperature[25]=[38;2;191;159;31mÛ"
set "temperature[26]=[38;2;191;159;31mÛ"
set "temperature[27]=[38;2;191;167;39mÛ"
set "temperature[28]=[38;2;191;167;39mÛ"
set "temperature[29]=[38;2;191;175;47mÛ"
set "temperature[30]=[38;2;183;175;47mÛ"
set "temperature[31]=[38;2;183;183;47mÛ"
set "temperature[32]=[38;2;183;183;55mÛ"
set "temperature[33]=[38;2;207;207;111mÛ"
set "temperature[34]=[38;2;223;223;159mÛ"
set "temperature[35]=[38;2;239;239;199mÛ"
set "temperature[36]=[38;2;255;255;255mÛ"
set /a "max=36", "mag=4"
set /a "hei=wid=max", "objects=max * mag"
mode %wid%,%hei%
for /l %%a in (1,1,%objects%) do set /a "y[%%a]=!random! %% hei + hei","x[%%a]=%%a / mag","ys[%%a]=!random! %% mag + 1"
for /l %%# in () do (
for /l %%a in (1,1,%objects%) do (
if !y[%%a]! lss 0 ( set /a "y[%%a]=hei" ) else set /a "ly=y[%%a]","y[%%a]-=ys[%%a]"
for %%y in (!y[%%a]!) do set "screen=!screen!%esc%[!ly!;!x[%%a]!H %esc%[!y[%%a]!;!x[%%a]!H!esc!!temperature[%%y]!!esc![0m"
)
<nul set /p "=!screen!" & set "screen="
for /l %%a in (1, 1, 150000) do rem
)
Sidenote: Note i added the loop "for /l %%a in (1, 1, 150000) do rem" in order to slow down that; you might want to delete that loop or change the values.
penpen
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#5
Post
by aGerman » 08 May 2019 11:49
Haha, I was about to post almost the same code. Every [ needs its own escape character.
Steffen
-
Jer
- Posts: 177
- Joined: 23 Nov 2014 17:13
- Location: California USA
#6
Post
by Jer » 08 May 2019 12:19
I have questions about two lines. If someone could explain, that would be great.
What does "& echo !esc![?25l" do?
In the assignment of screen, how is "H" doing its job?
Changing it to some other character gives different spacing and frequency.
"G" and "I" produce many more characters than H.
Thanks.
Jerry