I finally figure out my LERP function formula! Please view https://en.wikipedia.org/wiki/Linear_interpolation
Code: Select all
set "lerp=?=(a+c*(b-a)*1000)/100000+a"
Code: Select all
@echo off & setlocal enableDelayedExpansion & mode 100,100
( for /f %%a in ('echo prompt $E^| cmd') do set "esc=%%a" ) & echo !esc![?25l
set "lerp=?=(a+c*(b-a)*1000)/100000+a"
set /a "hei=80", "wid=80"
set /a "ax=wid/2","ay=0"
set /a "bx=0","by=hei"
set /a "cx=wid","cy=hei"
set /a "x=!random! %% wid + 1"
set /a "y=!random! %% hei + 1"
for /l %%# in () do (
set /a "r=!random! %% 3"
if !r! equ 0 (
<nul set /p "=%esc%[38;5;9m"
set /a "a=x", "b=ax", "c=50", "%lerp:?=x%"
set /a "a=y", "b=ay", "c=50", "%lerp:?=y%"
) else if !r! equ 1 (
<nul set /p "=%esc%[38;5;10m"
set /a "a=x", "b=bx", "c=50", "%lerp:?=x%"
set /a "a=y", "b=by", "c=50", "%lerp:?=y%"
) else if !r! equ 2 (
<nul set /p "=%esc%[38;5;11m"
set /a "a=x", "b=cx", "c=50", "%lerp:?=x%"
set /a "a=y", "b=cy", "c=50", "%lerp:?=y%"
)
<nul set /p "=%esc%[!y!;!x!HÛ"
)