本帖最后由 fatcat 于 2012-3-4 22:37 编辑
- @echo off & setlocal enabledelayedexpansion
- if "%1"=="" (
- >nul reg add hkcu\Console\mpc /v FontSize /t reg_dword /d 0xc0006 /f
- start "mpc" /max %comspec% /c %0 1&goto:eof
- ) else (>nul reg delete hkcu\Console\mpc /f)
- set /a sz=29, wid=2*sz+1, Cols=2*wid, iMax=wid*wid
- for /l %%i in (1 1 !iMax!) do set "scr= !scr!"
- set "emp=!scr!"
- color 0a & mode con cols=!Cols! lines=!wid!
-
- rem 取得以圆周轨迹为动态圆心坐标
- set /a xC=sz+1, yC=xC, r=14 & rem 指定圆心及半径
- set /a x=0, y=r, d=-r
- for /l %%i in (1 1 999) do (
- set /a x%%i=x, y%%i=y
- set /a x+=1, d+=1+(x"<<1)
- if !d! geq 0 set /a y-=1, d-=y"<<1
- if !y! lss !x! (set ie=%%i&goto :lb1)
- )
- :lb1
-
- title 动画模拟以圆周轨迹方式画一个圆
- set x=x&set y=y& set /a ib=1,step=1,ix=0,iy=2,ic=0,ict=-1
- for /l %%i in (0 1 7) do (
- set /a "sx=(3-ix&-1)>>31|1, ix+=1, ix%%=8, sy=(3-iy&-1)>>31|1, iy+=1, iy%%=8, ic+=1, ic%%=2
- if !ic! equ 0 (set tmp=!x!&set x=!y!& set y=!tmp!)
- for /f "tokens=1,2" %%X in ("!x! !y!") do for /l %%i in (!ib! !step! !ie!) do (
- set /a xd=!sx:1=!!%%X%%i!+xC, yd=!sy:1=!!%%Y%%i!+yC, ict+=1
- set xc!ict!=!xd!& set yc!ict!=!yd!
- set /a "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!)
- )
- cls &(<nul set /p=!scr:~0,-1!)
- )
- set tmp=!ib!&set ib=!ie!& set ie=!tmp!& set /a step=-step
- )
- pause
-
- title 随机生成一些圆或者弧
- set "scr=!emp!"
- set /a xC=25, yC=30, r=15
- 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"
- )
- cls &(<nul set /p=!scr:~0,-1!)
- pause
-
- title 圆的动画
- set r=14& set "scr=!emp!"
- set /a p1=-1, p2=p1+ict/3, p3=p1+2*ict/3, div=ict+1
- for /l %%i in (0 1 9999) do (
- set "scr=!emp!"
- set /a "p1+=1,p1%%=div,p2+=1,p2%%=div,p3+=1,p3%%=div"
- for %%j in (!p1! !p2! !p3!) do (
- set /a xC=!xc%%j!, yC=!yc%%j!
- call :mpc
- )
- cls &(<nul set /p=!scr:~0,-1!)
- )
- pause
- exit
- :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 /b
复制代码
|