Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off & setlocal enableDelayedExpansion
- call :macros
- mode 100,100
- :GAME_ENGINE
- for /l %%# in () do (
- set "xx=0"
- for /l %%a in (100,-1,1) do (
- %smoothStep% 1 100 %%a yy
- set /a "xx+=1", "cc=xx * yy"
- %plot_HSL_RGB% !xx! !yy! 330 10000 !cc!
- )
- <nul set /p "=%esc%[2J!screen!" & set "screen="
- )
- pause
- exit
- :macros
- set ^"LF=^
- ^" Above empty line is required - do not remove
- set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
- for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
- <nul set /p "=!esc![?25l"
- rem %RGBplot% x y 0-255 0-255 0-255 CHAR
- set RGBplot=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-5" %%1 in ("^!args^!") do (%\n%
- set "screen=^!screen^!!esc![%%2;%%1H!esc![38;2;%%3;%%4;%%5mÛ!esc![0m"%\n%
- )) else set args=
- rem plot_HSL_RGB x y 0-360 0-10000 0-10000
- set plot_HSL_RGB=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-5" %%1 in ("^!args^!") do (%\n%
- set /a "H=%%3", "S=%%4", "L=%%5"%\n%
- if %%3 geq 360 set /a "H=360"%\n%
- if %%3 leq 0 set /a "H=0"%\n%
- set /a "va=2*L-10000"%\n%
- for /f "tokens=1" %%a in ("^!va^!") do if %%a lss 0 set /a "va=-va"%\n%
- set /a "C=(10000-va)*S/10000"%\n%
- set /a "h1=H*10000/60"%\n%
- set /a "mm=(h1 %% 20000) - 10000"%\n%
- for /f "tokens=1" %%a in ("^!mm^!") do if %%a lss 0 set /a "mm=-mm"%\n%
- set /a "X=C *(10000 - mm)/10000"%\n%
- set /a "m=L - C/2"%\n%
- for /f "tokens=1" %%a in ("^!H^!") do (%\n%
- if %%a lss 60 ( set /a "R=C+m", "G=X+m", "B=0+m" ) else (%\n%
- if %%a lss 120 ( set /a "R=X+m", "G=C+m", "B=0+m" ) else (%\n%
- if %%a lss 180 ( set /a "R=0+m", "G=C+m", "B=X+m" ) else (%\n%
- if %%a lss 240 ( set /a "R=0+m", "G=X+m", "B=C+m" ) else (%\n%
- if %%a lss 300 ( set /a "R=X+m", "G=0+m", "B=C+m" ) else (%\n%
- if %%a lss 360 ( set /a "R=C+m", "G=0+m", "B=X+m" ))))))%\n%
- )%\n%
- set /a "R=R*255/10000", "G=G*255/10000", "B=B*255/10000", "HSLX=%%1", "HSLY=%%2"%\n%
- for /f "tokens=1-5" %%a in ("^!HSLX^! ^!HSLY^! ^!R^! ^!G^! ^!B^!") do ^!RGBplot^! %%a %%b %%c %%d %%e%\n%
- )) else set args=
- rem clamp x min max RETURNVAR
- set clamp=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
- set /a "xx=%%~1", "yy=%%2", "zz=%%3"%\n%
- for /f "tokens=1-3" %%x in ("^!xx^! ^!yy^! ^!zz^!") do (%\n%
- if %%x lss %%y ( set /a "xx=%%y"%\n%
- ) else if %%x gtr %%z ( set /a "xx=%%z" )%\n%
- )%\n%
- for /f "tokens=1" %%x in ("^!xx^!") do (%\n%
- if "%%4" neq "" ( set /a "%%4=%%x" ) else ( echo=%%x)%\n%
- )%\n%
- )) else set args=
- rem smoothStep min max X RETURNVAR
- set smoothStep=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
- %= Scale, bias and saturate x to 0..100 range =%%\n%
- set /a "clamped=((%%3) - %%1) * 100 ^/ (%%2 - %%1) + 1"%\n%
- for /f "tokens=1" %%c in ("^!clamped^!") do ^!clamp^! %%c 0 100 CLAMPED_x %\n%
- %= Evaluate polynomial =%%\n%
- set /a "ss=^(3*100 - 2 * CLAMPED_x^) * CLAMPED_x^/100 * CLAMPED_x^/100"%\n%
- for /f "tokens=1" %%x in ("^!ss^!") do (%\n%
- if "%%4" neq "" ( set "%%4=%%x" ) else ( echo=%%x)%\n%
- )%\n%
- )) else set args=
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement