 | @echo off & setlocal enabledelayedexpansion | | set /a sz=28, wid=2*sz+1, Cols=2*wid, iMax=wid*wid | | for /l %%i in (1 1 !iMax!) do set "scr= !scr!" | | color 0a & mode con cols=!Cols! lines=!wid! | | set /a xC=25, yC=30, r=15 & rem 指定圆心及半径 | | for /l %%n in (1 1 5) do ( | | call :mpc | | set /a "xC=!random!%%wid, yC=!random!%%wid, r=!random!%%(wid*2/3-10)+10" | | ) | | echo !scr!& pause & exit /b | | | | :mpc rem midpoint circle algorithm 中点画圆算法 | | set /a x=0, y=r, d=-r | | for /l %%i in (1 1 999) do ( | | for %%# in (1 2) do ( | | for %%x in (-!x! !x!) do for %%y in (-!y! !y!) do ( | | set /a xd=%%x+xC, yd=%%y+yC, "inScr=(xd-1^xd-wid)&(yd-1^yd-wid) | | if !inScr! lss 0 ( | | set /a ind=xd+yd*wid+1, lenL=ind-1, lenR=iMax-ind | | for /f "tokens=1,2,3" %%a in ("!lenL! !ind! !lenR!") do (set scr=!scr:~0,%%a!·!scr:~%%b,%%c!) | | ) | | ) | | set tmp=!x!&set x=!y!& set y=!tmp! | | ) | | set /a x+=1, d+=1+(x"<<1) | | if !d! geq 0 set /a y-=1, d-=y"<<1 | | if !y! lss !x! exit /b | | ) | | exit /bCOPY |
|