http://mathworld.wolfram.com/HeartCurve.html
I attempted to recreate this in batch. Here is my attempt. The algorithm is correct. This is the 6th example.
I tried to "fine tune" the heart to appear more.. hearty..? A deeper point in the top would be nice, but I cannot seem to manage.
Enjoy
Code: Select all
@echo off & setlocal enableDelayedExpansion
for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
set /a "PI=(35500000/113+5)/10, HALF_PI=(35500000/113/2+5)/10, TWO_PI=2*PI, PI32=PI+PI_div_2, neg_PI=PI * -1, neg_HALF_PI=HALF_PI *-1"
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=(a=(x)%%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%) / 100"
set "cos=(a=(15708 - x)%%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%)"
set /a "heartSize=1", "heartHei=13", "heartWid=16", "centerScreen=25"
for /l %%a in (0,250,%TWO_PI%) do (
set /a "gotPow=1", "normalize=1" & for /l %%b in (1,1,3) do set /a "gotPow*=!sin:x=%%a!", "normalize*=100"
set /a "x= heartSize * heartWid * gotPow / normalize + centerScreen"
set /a "y=-heartSize * (heartHei * !cos:x=%%a! - 5 * !cos:x=2*%%a! - 2 * !cos:x=3*%%a! - !cos:x=4*%%a!) / 10000 + centerScreen"
<nul set /p "=%esc%[!y!;!x!H%esc%[38;5;9mÛ"
)
pause >nul