Fast draw circle/ellipse in dos batch
Posted: 23 May 2014 10:01
Hi,
This is subroutine for display small circle/ellipse very fast.
Can be optimizing enogh (making a macro or other) and my be consider a prof of concept.
If you are necessary a file with a circle this is an option.
Tested on windows 7 32bit
EDIT: Add codepage.
einstein1969
This is subroutine for display small circle/ellipse very fast.
Can be optimizing enogh (making a macro or other) and my be consider a prof of concept.
If you are necessary a file with a circle this is an option.
Tested on windows 7 32bit
Code: Select all
@echo off
chcp 850
mode 80,43 >nul
cls
rem use font raster 8x8 for aspect ratio 1:1
rem Thanks at penpen and jeb!
(setlocal enableDelayedExpansion & for /F "delims==" %%f in ('set') do set "%%f="
call :init_circle
:: This use antiflicker using timers coaleshing. Work on windows 7
for /L %%\ in (0,1,18000) do (
if not "!OT!"=="!time:~10,1!" (
set /a "r=i %% 16-7, r=(r>>31|1)*r+2, i+=1"
call :circle !r! 1
set OT=!time:~10,1!
)
)
:: This is without antiflicker
for /L %%\ in (0,1,30) do (
set /a "r=i %% 16-7, r=(r>>31|1)*r+2, i+=1"
call :circle !r! 1
call :circle !r! 1*2/3
call :circle !r! 2
call :circle !r! 1*2/3
call :circle !r! 1
call :circle !r! 1*3/2
)
endlocal & goto :eof )
rem set "))=+%%y*%%y)/32)^^%1" : Setting a macro for partial formula. To reduce code dimension.
rem You can tune the number 32 for bigger o smaller circle and for thikness of circle and the radius. The %1 is the radius
:circle %1=radius %2=ratio/ellipse
(cls & type "%tmp%\circle.tmp.txt"
set "))=+%%y*%%y/%2)/32)^^(%~1)")
(set "))="
(for /L %%y in (-%md%,1,%md%) do (
set b=
for /L %%x in (-%md%,4,%md%) do (
set /a "a=10000+^!^!( (( %%x*%%x %))% ), a+=^!^!( (( (%%x+1)*(%%x+1) %))% )*10, a+=^!^!( (( (%%x+2)*(%%x+2) %))% )*100, a+=^!^!( (( (%%x+3)*(%%x+3) %))% )*1000"
for /F "tokens=1-4" %%f in ("!a:~-1! !a:~-2,1! !a:~-3,1! !a:~-4,1!") do set b=!b!!c:~%%f,1!!c:~%%g,1!!c:~%%h,1!!c:~%%i,1!
)
echo(!b!
)) > "%tmp%\circle.tmp.txt"
goto :eof )
:init_circle
rem maximum dimension of circle or windows square
set md=20
rem charatcher used for draw a full/empty pixel
set "c=Û "
goto :eof
EDIT: Add codepage.
einstein1969