[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[游戏娱乐] 贝塞尔曲线

本帖最后由 aa77dd@163.com 于 2016-10-2 17:32 编辑

523066680 的创意
http://www.code-by.org/viewtopic ... 7430da68d57ba60493c

我想 CMD 也能行, 测试于 WIN7 / XP

  1. @echo off & setlocal enabledelayedexpansion & color 0A & chcp 936
  2. set "hexWid=64" & set "hexHei=3c" & REM 100 x 60
  3. for /f "tokens=2 delims=[]" %%a in ('ver') do for /f "tokens=2 delims=. " %%a in ("%%a") do set /a "FullScreen=-((%%a-6)>>31)"
  4. if "%1"=="" (
  5.     for %%a in ( FontSize:00050003 FontFamily:00000000 WindowSize:00%hexHei%00%hexWid% ScreenColors:0000000a CodePage:000003a8 ScreenBufferSize:00%hexHei%00%hexWid% FullScreen:!FullScreen:-=!
  6.     ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do >nul reg add HKCU\Console\Bezier_CMD /v %%b /t reg_dword /d 0x%%c /f
  7.     start "Bezier_CMD" /max "%ComSpec%" /c %~s0 1 & exit
  8. ) else ( >nul reg delete HKCU\Console\Bezier_CMD /f )
  9. set "Path=%SystemRoot%\system32" & for /f "delims==" %%a in ('set') do if /i "%%a" neq "Path" if /i "%%a" neq "hexWid" if /i "%%a" neq "hexHei" set "%%a="
  10. set /a "pixel_w=3, pixel_h=5" & rem 字体像素高宽比, 请把 CMD 窗口字体尺寸设置成点阵 3X5
  11. set /a "Cols=wid=0x%hexWid%, lines=hei=0x%hexHei%, ctrl_wid=wid * 3 / 3, ctrl_hei=hei * 3 / 3, iMax=wid*hei"
  12. set /a "XC = Cols/2, YC = lines/2"
  13. (for /l %%i in (1 1 !wid!) do set "t= !t!") & (for /l %%i in (1 1 !hei!) do set "scr=!scr!!t!") & set "t="
  14. set "TAB= " & for /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "BS=%%a"
  15. set /a "buffwid = wid, linesWantBackAbove = hei - 1 + 1, cntBS = 2 + (buffwid + 7) / 8 * linesWantBackAbove"
  16. set "BSs=" & for /L %%a in (1 1 !cntBS!) do set "BSs=!BSs!%BS%"
  17. set "aLineBS=" & for /L %%a in (1 1 !wid!) do set "aLineBS=!aLineBS!%BS%"
  18. set "dic=QWERTYUIOPASDFGHJKLZXCVBNM@#$+[]{}" & set "sumLines=30" & rem sumLines 必须小于 dic 的长度, dic: 画笔用字符, 不要用某些可能引起语法副作用的字符
  19. set /a "DotPerLine=15, DotPerLineSQ=DotPerLine*DotPerLine, DotPerLineCube=DotPerLine*DotPerLineSQ"
  20. set /a "pathDensity=50, pathDensitySQ=pathDensity*pathDensity, pathDensityCube=pathDensitySQ*pathDensity"
  21. for /L %%h in (0 1 3) do for %%i in (0 1 3) do ^
  22. set /a "cx%%h_%%i=!random! %% ctrl_wid - (ctrl_wid>>1), cy%%h_%%i=!random! %% ctrl_hei - (ctrl_hei>>1)"
  23. REM 3次绘图曲线系数预算
  24. for /L %%j in (0 1 !DotPerLine!) do (
  25.     set /a "tr_%%j=DotPerLine-%%j,tr2_%%j=tr_%%j*tr_%%j,te2_%%j=%%j*%%j,t0_%%j=tr2_%%j*tr_%%j, t1_%%j=3*tr2_%%j*%%j, t2_%%j=3*tr_%%j*te2_%%j, t3_%%j=te2_%%j*%%j"
  26. )
  27. for /L %%# in (0) do (
  28.     for /L %%i in (1 1 !pathDensity!) do (
  29.         REM 画笔循环
  30.         set "dic=!dic:~1!!dic:~0,1!" & set "born=!dic:~%sumLines%,1!"
  31.         set /a "tr=pathDensity-%%i,tr2=tr*tr,te2=%%i*%%i,ct0=tr2*tr, ct1=3*tr2*%%i, ct2=3*tr*te2, ct3=te2*%%i"
  32.         for /L %%h in (0 1 3) do (
  33.             set /a "x%%h=(ct0*cx%%h_0+ct1*cx%%h_1+ct2*cx%%h_2+ct3*cx%%h_3)/pathDensityCube, y%%h=(ct0*cy%%h_0+ct1*cy%%h_1+ct2*cy%%h_2+ct3*cy%%h_3)/pathDensityCube"
  34.         )
  35.         REM title %%i/!pathDensity! {!x0!,!y0!},{!x1!,!y1!},{!x2!,!y2!},{!x3!,!y3!}
  36.         for /L %%j in (0 1 !DotPerLine!) do (
  37.             set /a "x=XC + (t0_%%j*x0+t1_%%j*x1+t2_%%j*x2+t3_%%j*x3)*pixel_h/(pixel_w*DotPerLineCube), y=YC + (t0_%%j*y0+t1_%%j*y1+t2_%%j*y2+t3_%%j*y3)/DotPerLineCube, inScr=(x-0^x-wid)&(y-0^y-hei)"
  38.             if !inScr! lss 0 (
  39.                 set /a "ind=x+y*wid+1, lenL=ind-1"
  40.                 for /f "tokens=1,2" %%a in ("!lenL! !ind!") do (set scr=!scr:~0,%%a!!born!!scr:~%%b!)
  41.             )
  42.         )
  43.         REM 擦除老线
  44.         for %%c in ("!dic:~0,1!") do set "scr=!scr:%%~c= !"
  45.         <nul set /p "=!aLineBS!" & (2>nul echo;%TAB%!BSs!) & <nul set /p "=%BS%"
  46.         <nul set /p "=%BS%!scr:~0,-1!"
  47.     )
  48.     for /L %%h in (0 1 3) do (
  49.         set /a "cx%%h_0=cx%%h_3, cy%%h_0=cy%%h_3, cx%%h_1 = (cx%%h_3 << 1) - cx%%h_2, cy%%h_1 = (cy%%h_3 << 1) - cy%%h_2"
  50.         for %%i in (2 3) do set /a "cx%%h_%%i=!random! %% ctrl_wid - (ctrl_wid>>1), cy%%h_%%i=!random! %% ctrl_hei - (ctrl_hei>>1)"
  51.     )
  52. )
  53. >nul pause
  54. exit
复制代码
5

评分人数

膜拜大神!!!
批处理与数学的结合啊

TOP

返回列表